From acda44fd71e9260db4c3f07b404774173bf4b000 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Gardou?= Date: Sun, 4 Sep 2011 11:31:17 +0000 Subject: [PATCH 01/55] [WINETESTS/GDI32] - fix warnings svn path=/trunk/; revision=53571 --- rostests/winetests/gdi32/CMakeLists.txt | 2 ++ rostests/winetests/gdi32/metafile.c | 7 ++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/rostests/winetests/gdi32/CMakeLists.txt b/rostests/winetests/gdi32/CMakeLists.txt index 4d32dbabe7f..6259f6b2ae0 100644 --- a/rostests/winetests/gdi32/CMakeLists.txt +++ b/rostests/winetests/gdi32/CMakeLists.txt @@ -3,6 +3,8 @@ add_definitions( -D__ROS_LONG64__ -D_DLL -D__USE_CRTIMP) +remove_definitions(-DWINVER=0x502 -D_WIN32_IE=0x600 -D_WIN32_WINNT=0x502) + list(APPEND SOURCE bitmap.c brush.c diff --git a/rostests/winetests/gdi32/metafile.c b/rostests/winetests/gdi32/metafile.c index 2a80b974a41..39eacec9751 100755 --- a/rostests/winetests/gdi32/metafile.c +++ b/rostests/winetests/gdi32/metafile.c @@ -1427,14 +1427,15 @@ static int compare_emf_bits(const HENHMETAFILE mf, const unsigned char *bits, const ENHMETARECORD *emr1 = (const ENHMETARECORD *)(bits + offset1); const ENHMETARECORD *emr2 = (const ENHMETARECORD *)(buf + offset2); -#if 1 +if(1) skip("skipping match_emf_record(), bug 5393\n"); -#else +else +{ trace("%s: EMF record %u, size %u/record %u, size %u\n", desc, emr1->iType, emr1->nSize, emr2->iType, emr2->nSize); if (!match_emf_record(emr1, emr2, desc, ignore_scaling)) return -1; -#endif +} /* We have already bailed out if iType or nSize don't match */ offset1 += emr1->nSize; From 7a18610b019f071349ea0288eddb1edf8143ad4c Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Sun, 4 Sep 2011 12:01:27 +0000 Subject: [PATCH 02/55] [ADVAPI32] Pass service start arguments to ANSI services too. Clean up the service start code. svn path=/trunk/; revision=53572 --- reactos/dll/win32/advapi32/service/sctrl.c | 215 ++++++++++++--------- 1 file changed, 121 insertions(+), 94 deletions(-) diff --git a/reactos/dll/win32/advapi32/service/sctrl.c b/reactos/dll/win32/advapi32/service/sctrl.c index 53a9aef1514..c6dfcf20cdf 100644 --- a/reactos/dll/win32/advapi32/service/sctrl.c +++ b/reactos/dll/win32/advapi32/service/sctrl.c @@ -277,14 +277,123 @@ ScConnectControlPipe(HANDLE *hPipe) } +static DWORD +ScBuildUnicodeArgsVector(PSCM_CONTROL_PACKET ControlPacket, + LPDWORD lpArgCount, + LPWSTR **lpArgVector) +{ + LPWSTR *lpVector; + LPWSTR *lpArg; + DWORD i; + + *lpArgCount = 0; + *lpArgVector = NULL; + + if (ControlPacket->dwArgumentsCount > 0) + { + lpVector = HeapAlloc(GetProcessHeap(), + HEAP_ZERO_MEMORY, + ControlPacket->dwSize - ControlPacket->dwArgumentsOffset); + if (lpVector == NULL) + return ERROR_OUTOFMEMORY; + + memcpy(lpVector, + ((PBYTE)ControlPacket + ControlPacket->dwArgumentsOffset), + ControlPacket->dwSize - ControlPacket->dwArgumentsOffset); + + lpArg = lpVector; + for (i = 0; i < ControlPacket->dwArgumentsCount; i++) + { + *lpArg = (LPWSTR)((ULONG_PTR)lpArg + (ULONG_PTR)*lpArg); + lpArg++; + } + + *lpArgCount = ControlPacket->dwArgumentsCount; + *lpArgVector = lpVector; + } + + return ERROR_SUCCESS; +} + + +static DWORD +ScBuildAnsiArgsVector(PSCM_CONTROL_PACKET ControlPacket, + LPDWORD lpArgCount, + LPSTR **lpArgVector) +{ + LPSTR *lpVector; + LPSTR *lpPtr; + LPWSTR lpUnicodeString; + LPSTR lpAnsiString; + DWORD dwVectorSize; + DWORD dwUnicodeSize; + DWORD dwAnsiSize; + DWORD i; + + *lpArgCount = 0; + *lpArgVector = NULL; + + if (ControlPacket->dwArgumentsCount > 0) + { + dwVectorSize = ControlPacket->dwArgumentsCount * sizeof(LPWSTR); + + lpUnicodeString = (LPWSTR)((PBYTE)ControlPacket + + ControlPacket->dwArgumentsOffset + + dwVectorSize); + dwUnicodeSize = (ControlPacket->dwSize - + ControlPacket->dwArgumentsOffset - + dwVectorSize) / sizeof(WCHAR); + + dwAnsiSize = WideCharToMultiByte(CP_ACP, + 0, + lpUnicodeString, + dwUnicodeSize, + NULL, + 0, + NULL, + NULL); + + lpVector = HeapAlloc(GetProcessHeap(), + HEAP_ZERO_MEMORY, + dwVectorSize + dwAnsiSize); + if (lpVector == NULL) + return ERROR_OUTOFMEMORY; + + lpPtr = (LPSTR*)lpVector; + lpAnsiString = (LPSTR)((ULONG_PTR)lpVector + dwVectorSize); + + WideCharToMultiByte(CP_ACP, + 0, + lpUnicodeString, + dwUnicodeSize, + lpAnsiString, + dwAnsiSize, + NULL, + NULL); + + for (i = 0; i < ControlPacket->dwArgumentsCount; i++) + { + *lpPtr = lpAnsiString; + + lpPtr++; + lpAnsiString += (strlen(lpAnsiString) + 1); + } + + *lpArgCount = ControlPacket->dwArgumentsCount; + *lpArgVector = lpVector; + } + + return ERROR_SUCCESS; +} + + static DWORD ScStartService(PACTIVE_SERVICE lpService, PSCM_CONTROL_PACKET ControlPacket) { HANDLE ThreadHandle; DWORD ThreadId; - LPWSTR *lpArgW; - DWORD i; + DWORD dwError; TRACE("ScStartService() called\n"); TRACE("Size: %lu\n", ControlPacket->dwSize); @@ -293,105 +402,23 @@ ScStartService(PACTIVE_SERVICE lpService, /* Set the service status handle */ lpService->hServiceStatus = ControlPacket->hServiceStatus; + /* Build the arguments vector */ if (lpService->bUnicode == TRUE) { - lpService->ThreadParams.W.dwArgCount = ControlPacket->dwArgumentsCount; - lpService->ThreadParams.W.lpArgVector = NULL; - - if (ControlPacket->dwArgumentsOffset > 0) - { - lpService->ThreadParams.W.lpArgVector = - HeapAlloc(GetProcessHeap(), - HEAP_ZERO_MEMORY, - ControlPacket->dwSize - ControlPacket->dwArgumentsOffset); - if (lpService->ThreadParams.W.lpArgVector == NULL) - return ERROR_OUTOFMEMORY; - - memcpy(lpService->ThreadParams.W.lpArgVector, - ((PBYTE)ControlPacket + ControlPacket->dwArgumentsOffset), - ControlPacket->dwSize - ControlPacket->dwArgumentsOffset); - - lpArgW = lpService->ThreadParams.W.lpArgVector; - for (i = 0; i < lpService->ThreadParams.W.dwArgCount; i++) - { - *lpArgW = (LPWSTR)((ULONG_PTR)lpArgW + (ULONG_PTR)*lpArgW); - lpArgW++; - } - } + dwError = ScBuildUnicodeArgsVector(ControlPacket, + &lpService->ThreadParams.W.dwArgCount, + &lpService->ThreadParams.W.lpArgVector); } else { - /* FIXME */ - lpService->ThreadParams.A.dwArgCount = 0; - lpService->ThreadParams.A.lpArgVector = NULL; - -#if 0 - LPSTR *lpArgVector; - LPSTR Ptr; - LPSTR AnsiString; - DWORD AnsiLength; - - AnsiLength = WideCharToMultiByte(CP_ACP, - 0, - lpService->Arguments, - dwLength, - NULL, - 0, - NULL, - NULL); - if (AnsiLength == 0) - return ERROR_INVALID_PARAMETER; /* ? */ - - AnsiString = HeapAlloc(GetProcessHeap(), - 0, - AnsiLength + 1); - if (AnsiString == NULL) - return ERROR_OUTOFMEMORY; - - WideCharToMultiByte(CP_ACP, - 0, - lpService->Arguments, - dwLength, - AnsiString, - AnsiLength, - NULL, - NULL); - - AnsiString[AnsiLength] = ANSI_NULL; - - lpArgVector = HeapAlloc(GetProcessHeap(), - 0, - (dwArgCount + 1) * sizeof(LPSTR)); - if (lpArgVector == NULL) - { - HeapFree(GetProcessHeap(), - 0, - AnsiString); - return ERROR_OUTOFMEMORY; - } - - dwArgCount = 0; - Ptr = AnsiString; - while (*Ptr) - { - lpArgVector[dwArgCount] = Ptr; - - dwArgCount++; - Ptr += (strlen(Ptr) + 1); - } - lpArgVector[dwArgCount] = NULL; - - (lpService->ThreadParams.A.lpServiceMain)(dwArgCount, lpArgVector); - - HeapFree(GetProcessHeap(), - 0, - lpArgVector); - HeapFree(GetProcessHeap(), - 0, - AnsiString); -#endif + dwError = ScBuildAnsiArgsVector(ControlPacket, + &lpService->ThreadParams.A.dwArgCount, + &lpService->ThreadParams.A.lpArgVector); } + if (dwError != ERROR_SUCCESS) + return dwError; + /* Invoke the services entry point and implement the command loop */ ThreadHandle = CreateThread(NULL, 0, From e448d722f6beb4c1ddaeb313d8f464ec6c4ca31f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Gardou?= Date: Sun, 4 Sep 2011 12:08:54 +0000 Subject: [PATCH 03/55] [PSDK] - fix compilation for any fool wanting to use our headers outside of NT 5.2 scope svn path=/trunk/; revision=53573 --- reactos/include/psdk/wincon.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/reactos/include/psdk/wincon.h b/reactos/include/psdk/wincon.h index a7916b46834..7b62e2f42f9 100644 --- a/reactos/include/psdk/wincon.h +++ b/reactos/include/psdk/wincon.h @@ -5,6 +5,10 @@ extern "C" { #endif +#if (_WIN32_WINNT >= 0x0600) && !defined(NOGDI) +# include "wingdi.h" +#endif + #ifdef _MSC_VER #pragma warning(push) #pragma warning(disable:4820) @@ -137,12 +141,14 @@ typedef struct _INPUT_RECORD { #if (_WIN32_WINNT >= 0x0600) #define HISTORY_NO_DUP_FLAG 0x1 #define CONSOLE_OVERSTRIKE 0x1 +#ifndef NOGDI typedef struct _CONSOLE_HISTORY_INFO { UINT cbSize; UINT HistoryBufferSize; UINT NumberOfHistoryBuffers; DWORD dwFlags; } CONSOLE_HISTORY_INFO, *PCONSOLE_HISTORY_INFO; +#endif typedef struct _CONSOLE_SCREEN_BUFFER_INFOEX { ULONG cbSize; From 152a7cc18dfeff7ebc142394acfa295f886e6fbd Mon Sep 17 00:00:00 2001 From: Sylvain Petreolle Date: Sun, 4 Sep 2011 12:26:49 +0000 Subject: [PATCH 04/55] [WINETESTS] Allow to run skipped test in interactive mode. svn path=/trunk/; revision=53575 --- rostests/winetests/gdi32/metafile.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rostests/winetests/gdi32/metafile.c b/rostests/winetests/gdi32/metafile.c index 39eacec9751..fe9638c4141 100755 --- a/rostests/winetests/gdi32/metafile.c +++ b/rostests/winetests/gdi32/metafile.c @@ -1427,7 +1427,7 @@ static int compare_emf_bits(const HENHMETAFILE mf, const unsigned char *bits, const ENHMETARECORD *emr1 = (const ENHMETARECORD *)(bits + offset1); const ENHMETARECORD *emr2 = (const ENHMETARECORD *)(buf + offset2); -if(1) +if(!winetest_interactive) skip("skipping match_emf_record(), bug 5393\n"); else { From 92b4703b90a1d8ab368344c238d62672f79f69d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Gardou?= Date: Sun, 4 Sep 2011 13:01:38 +0000 Subject: [PATCH 05/55] [WINETESTS/URLMON] - fix warnings svn path=/trunk/; revision=53576 --- rostests/winetests/urlmon/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rostests/winetests/urlmon/CMakeLists.txt b/rostests/winetests/urlmon/CMakeLists.txt index aad867fbca6..609a9aae811 100644 --- a/rostests/winetests/urlmon/CMakeLists.txt +++ b/rostests/winetests/urlmon/CMakeLists.txt @@ -1,4 +1,6 @@ +remove_definitions(-DWINVER=0x502 -D_WIN32_IE=0x600 -D_WIN32_WINNT=0x502) + add_definitions( -D__ROS_LONG64__ -D_DLL -D__USE_CRTIMP) From f41f1865c69688df7b4e2e39537f0003cfc83a09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Gardou?= Date: Sun, 4 Sep 2011 13:09:16 +0000 Subject: [PATCH 06/55] [WINETESTS/WININET] - fix warnings svn path=/trunk/; revision=53577 --- rostests/winetests/wininet/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rostests/winetests/wininet/CMakeLists.txt b/rostests/winetests/wininet/CMakeLists.txt index e3a01707794..0717420123a 100644 --- a/rostests/winetests/wininet/CMakeLists.txt +++ b/rostests/winetests/wininet/CMakeLists.txt @@ -1,4 +1,6 @@ +remove_definitions(-DWINVER=0x502 -D_WIN32_IE=0x600 -D_WIN32_WINNT=0x502) + add_definitions( -D__ROS_LONG64__ -D_DLL -D__USE_CRTIMP) From acbe8f03e52eb26f9455bd76ce06cb40109c5147 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Gardou?= Date: Sun, 4 Sep 2011 14:09:14 +0000 Subject: [PATCH 07/55] [PSDK] - put NOGDI guard at the right place... svn path=/trunk/; revision=53578 --- reactos/include/psdk/wincon.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/reactos/include/psdk/wincon.h b/reactos/include/psdk/wincon.h index 7b62e2f42f9..505f03f9dbd 100644 --- a/reactos/include/psdk/wincon.h +++ b/reactos/include/psdk/wincon.h @@ -141,14 +141,13 @@ typedef struct _INPUT_RECORD { #if (_WIN32_WINNT >= 0x0600) #define HISTORY_NO_DUP_FLAG 0x1 #define CONSOLE_OVERSTRIKE 0x1 -#ifndef NOGDI + typedef struct _CONSOLE_HISTORY_INFO { UINT cbSize; UINT HistoryBufferSize; UINT NumberOfHistoryBuffers; DWORD dwFlags; } CONSOLE_HISTORY_INFO, *PCONSOLE_HISTORY_INFO; -#endif typedef struct _CONSOLE_SCREEN_BUFFER_INFOEX { ULONG cbSize; @@ -161,6 +160,7 @@ typedef struct _CONSOLE_SCREEN_BUFFER_INFOEX { COLORREF ColorTable[16]; } CONSOLE_SCREEN_BUFFER_INFOEX, *PCONSOLE_SCREEN_BUFFER_INFOEX; +#ifndef NOGDI typedef struct _CONSOLE_FONT_INFOEX { ULONG cbSize; DWORD nFont; @@ -170,6 +170,7 @@ typedef struct _CONSOLE_FONT_INFOEX { WCHAR FaceName[LF_FACESIZE]; } CONSOLE_FONT_INFOEX, *PCONSOLE_FONT_INFOEX; #endif +#endif BOOL WINAPI AllocConsole(void); #if (_WIN32_WINNT >= 0x0501) From 7f50216c3817070a61a2dd2cdd170ffeee751a15 Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Sun, 4 Sep 2011 14:42:08 +0000 Subject: [PATCH 08/55] [SERVICES] RStartServiceA: Convert the ANSI start arguments vector to a UNICODE vector and pass it to ScmStartService. Calls to StartServiceA can now be used to pass arguments to a starting service. svn path=/trunk/; revision=53579 --- reactos/base/system/services/rpcserver.c | 53 ++++++++++++++++++++++-- 1 file changed, 50 insertions(+), 3 deletions(-) diff --git a/reactos/base/system/services/rpcserver.c b/reactos/base/system/services/rpcserver.c index 6a7895992de..5f5e2d8d5e3 100644 --- a/reactos/base/system/services/rpcserver.c +++ b/reactos/base/system/services/rpcserver.c @@ -4086,6 +4086,9 @@ DWORD RStartServiceA( DWORD dwError = ERROR_SUCCESS; PSERVICE_HANDLE hSvc; PSERVICE lpService = NULL; + LPWSTR *lpVector = NULL; + DWORD i; + DWORD dwLength; DPRINT("RStartServiceA() called\n"); @@ -4119,12 +4122,56 @@ DWORD RStartServiceA( if (lpService->bDeleted) return ERROR_SERVICE_MARKED_FOR_DELETE; - /* FIXME: Convert argument vector to Unicode */ + /* Build a Unicode argument vector */ + if (argc > 0) + { + lpVector = HeapAlloc(GetProcessHeap(), + HEAP_ZERO_MEMORY, + argc * sizeof(LPWSTR)); + if (lpVector == NULL) + return ERROR_NOT_ENOUGH_MEMORY; + + for (i = 0; i < argc; i++) + { + dwLength = MultiByteToWideChar(CP_ACP, + 0, + ((LPSTR*)argv)[i], + -1, + NULL, + 0); + + lpVector[i] = HeapAlloc(GetProcessHeap(), + HEAP_ZERO_MEMORY, + dwLength * sizeof(WCHAR)); + if (lpVector[i] == NULL) + { + dwError = ERROR_NOT_ENOUGH_MEMORY; + goto done; + } + + MultiByteToWideChar(CP_ACP, + 0, + ((LPSTR*)argv)[i], + -1, + lpVector[i], + dwLength); + } + } /* Start the service */ - dwError = ScmStartService(lpService, 0, NULL); + dwError = ScmStartService(lpService, argc, lpVector); - /* FIXME: Free argument vector */ +done: + /* Free the Unicode argument vector */ + if (lpVector != NULL) + { + for (i = 0; i < argc; i++) + { + if (lpVector[i] != NULL) + HeapFree(GetProcessHeap(), 0, lpVector[i]); + } + HeapFree(GetProcessHeap(), 0, lpVector); + } return dwError; } From bde15eb421d29cf130b21653f930dd60a9e5c85b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Gardou?= Date: Sun, 4 Sep 2011 15:19:10 +0000 Subject: [PATCH 09/55] [ACTCXPRXY] - we have an entry point, provided by rpc proxy data svn path=/trunk/; revision=53580 --- reactos/dll/win32/actxprxy/CMakeLists.txt | 2 +- reactos/dll/win32/actxprxy/actxprxy.rbuild | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/reactos/dll/win32/actxprxy/CMakeLists.txt b/reactos/dll/win32/actxprxy/CMakeLists.txt index 9faeaf72240..d4898d1e41e 100644 --- a/reactos/dll/win32/actxprxy/CMakeLists.txt +++ b/reactos/dll/win32/actxprxy/CMakeLists.txt @@ -33,7 +33,7 @@ list(APPEND SOURCE add_library(actxprxy SHARED ${SOURCE}) -set_entrypoint(actxprxy 0) +set_module_type(actxprxy win32dll) target_link_libraries(actxprxy uuid diff --git a/reactos/dll/win32/actxprxy/actxprxy.rbuild b/reactos/dll/win32/actxprxy/actxprxy.rbuild index 68cd919bcb4..808f69474d2 100644 --- a/reactos/dll/win32/actxprxy/actxprxy.rbuild +++ b/reactos/dll/win32/actxprxy/actxprxy.rbuild @@ -1,7 +1,7 @@ - + . From 26a81f2aa2363a82591ca8e70a17d6b0e01063f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Gardou?= Date: Sun, 4 Sep 2011 15:29:15 +0000 Subject: [PATCH 10/55] [STI] - we have an entry point. svn path=/trunk/; revision=53581 --- reactos/dll/win32/sti/CMakeLists.txt | 2 +- reactos/dll/win32/sti/sti.rbuild | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/reactos/dll/win32/sti/CMakeLists.txt b/reactos/dll/win32/sti/CMakeLists.txt index bf59c851302..99bbb72ad7e 100644 --- a/reactos/dll/win32/sti/CMakeLists.txt +++ b/reactos/dll/win32/sti/CMakeLists.txt @@ -24,7 +24,7 @@ add_rpcproxy_files(sti_wia.idl) add_library(sti SHARED ${SOURCE}) -set_entrypoint(sti 0) +set_module_type(sti win32dll) target_link_libraries(sti wine diff --git a/reactos/dll/win32/sti/sti.rbuild b/reactos/dll/win32/sti/sti.rbuild index edce67acab8..51d2f67444a 100644 --- a/reactos/dll/win32/sti/sti.rbuild +++ b/reactos/dll/win32/sti/sti.rbuild @@ -1,7 +1,7 @@ - + . From cb386402ebcd78a9c4e6c811cbbe992a85a13b1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Gardou?= Date: Sun, 4 Sep 2011 15:37:42 +0000 Subject: [PATCH 11/55] [RPCRT4] - remove ros hack, obsoleted by r53580 and r53581 svn path=/trunk/; revision=53582 --- reactos/dll/win32/rpcrt4/cpsf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reactos/dll/win32/rpcrt4/cpsf.c b/reactos/dll/win32/rpcrt4/cpsf.c index bf04bb85de3..9375c40fa4c 100644 --- a/reactos/dll/win32/rpcrt4/cpsf.c +++ b/reactos/dll/win32/rpcrt4/cpsf.c @@ -241,7 +241,7 @@ HRESULT WINAPI NdrDllRegisterProxy(HMODULE hDll, TRACE("(%p,%p,%s)\n", hDll, pProxyFileList, debugstr_guid(pclsid)); - //if (!hDll) return E_HANDLE; + if (!hDll) return E_HANDLE; if (!*pProxyFileList) return E_NOINTERFACE; if (pclsid) From cb1f1bd5552dd1a60a4e4e6310b138c8fc0faac1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Gardou?= Date: Sun, 4 Sep 2011 15:58:48 +0000 Subject: [PATCH 12/55] [WIN32K] - Avoid invalid memory write. See issue #5969 for more details. svn path=/trunk/; revision=53583 --- reactos/subsystems/win32/win32k/ntuser/misc.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/reactos/subsystems/win32/win32k/ntuser/misc.c b/reactos/subsystems/win32/win32k/ntuser/misc.c index 036c0ceb0ce..0bb0b30d413 100644 --- a/reactos/subsystems/win32/win32k/ntuser/misc.c +++ b/reactos/subsystems/win32/win32k/ntuser/misc.c @@ -497,11 +497,14 @@ GetW32ThreadInfo(VOID) pti->pClientInfo = pci; _SEH2_TRY { - ProbeForWrite( Teb, - sizeof(TEB), - sizeof(ULONG)); + if(Teb) + { + ProbeForWrite( Teb, + sizeof(TEB), + sizeof(ULONG)); - Teb->Win32ThreadInfo = (PW32THREAD) pti; + Teb->Win32ThreadInfo = (PW32THREAD) pti; + } pci->ppi = ppi; pci->fsHooks = pti->fsHooks; From 9d3ef580638168064668ae9fd4b6d6f502374a1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Gardou?= Date: Sun, 4 Sep 2011 17:31:12 +0000 Subject: [PATCH 13/55] [CMAKE/KDBG] - fix warning svn path=/trunk/; revision=53584 --- reactos/ntoskrnl/kdbg/kdb_symbols.cmake.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reactos/ntoskrnl/kdbg/kdb_symbols.cmake.c b/reactos/ntoskrnl/kdbg/kdb_symbols.cmake.c index f176e78c0d8..1a8b728395a 100644 --- a/reactos/ntoskrnl/kdbg/kdb_symbols.cmake.c +++ b/reactos/ntoskrnl/kdbg/kdb_symbols.cmake.c @@ -653,7 +653,7 @@ static VOID KdbpSymFreeMem(PVOID Area) return ExFreePool(Area); } -static BOOLEAN KdbpSymReadMem(PVOID FileContext, PVOID TargetDebug, PVOID SourceMem, ULONG Size) +static BOOLEAN KdbpSymReadMem(PVOID FileContext, ULONG_PTR* TargetDebug, PVOID SourceMem, ULONG Size) { return NT_SUCCESS(KdbpSafeReadMemory(TargetDebug, SourceMem, Size)); } From e59cf523ac97a09a0b6a7aa573e1a2902dfe6f9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Gardou?= Date: Sun, 4 Sep 2011 17:32:30 +0000 Subject: [PATCH 14/55] [CMAKE] - enable -Werror by default on gcc build svn path=/trunk/; revision=53585 --- reactos/base/applications/winhlp32/CMakeLists.txt | 4 ++++ reactos/base/applications/wordpad/CMakeLists.txt | 4 ++++ reactos/base/applications/write/CMakeLists.txt | 4 ++++ reactos/cmake/gcc.cmake | 7 +++++++ reactos/dll/3rdparty/libtiff/CMakeLists.txt | 6 +++++- reactos/dll/3rdparty/libxslt/CMakeLists.txt | 4 ++++ reactos/dll/3rdparty/mesa32/CMakeLists.txt | 6 +++++- reactos/dll/directx/quartz/CMakeLists.txt | 4 ++++ reactos/dll/directx/wine/wined3d/CMakeLists.txt | 4 ++++ reactos/dll/win32/cabinet/CMakeLists.txt | 2 +- reactos/dll/win32/itss/CMakeLists.txt | 2 ++ reactos/dll/win32/jscript/CMakeLists.txt | 4 ++++ reactos/dll/win32/localspl/CMakeLists.txt | 4 ++++ reactos/dll/win32/mciseq/CMakeLists.txt | 7 ++++++- reactos/dll/win32/mciwave/CMakeLists.txt | 7 ++++++- reactos/dll/win32/rpcrt4/CMakeLists.txt | 4 ++++ reactos/dll/win32/shdocvw/CMakeLists.txt | 4 ++++ reactos/dll/win32/winhttp/CMakeLists.txt | 4 ++++ reactos/dll/win32/wininet/CMakeLists.txt | 4 ++++ reactos/lib/3rdparty/libxml2/CMakeLists.txt | 4 ++++ reactos/lib/drivers/lwip/CMakeLists.txt | 3 +++ reactos/lib/rossym_new/CMakeLists.txt | 1 + reactos/lib/sdk/crt/msvcrtex.cmake | 1 + 23 files changed, 89 insertions(+), 5 deletions(-) diff --git a/reactos/base/applications/winhlp32/CMakeLists.txt b/reactos/base/applications/winhlp32/CMakeLists.txt index 6f3b9e1b7d4..1391b0c993f 100644 --- a/reactos/base/applications/winhlp32/CMakeLists.txt +++ b/reactos/base/applications/winhlp32/CMakeLists.txt @@ -22,3 +22,7 @@ set_module_type(winhlp32 win32gui) target_link_libraries(winhlp32 wine) add_importlibs(winhlp32 user32 gdi32 shell32 comctl32 comdlg32 msvcrt kernel32 ntdll) add_cd_file(TARGET winhlp32 DESTINATION reactos FOR all) + +if(NOT MSVC) + allow_warnings(winhlp32) +endif() diff --git a/reactos/base/applications/wordpad/CMakeLists.txt b/reactos/base/applications/wordpad/CMakeLists.txt index d04e11ccbe5..62915f6dbcd 100644 --- a/reactos/base/applications/wordpad/CMakeLists.txt +++ b/reactos/base/applications/wordpad/CMakeLists.txt @@ -18,3 +18,7 @@ set_module_type(wordpad win32gui) target_link_libraries(wordpad wine uuid) add_importlibs(wordpad comdlg32 ole32 shell32 user32 gdi32 advapi32 comctl32 msvcrt kernel32 ntdll) add_cd_file(TARGET wordpad DESTINATION reactos/system32 FOR all) + +if(NOT MSVC) + allow_warnings(wordpad) +endif() diff --git a/reactos/base/applications/write/CMakeLists.txt b/reactos/base/applications/write/CMakeLists.txt index 48f6ff321af..943792268da 100644 --- a/reactos/base/applications/write/CMakeLists.txt +++ b/reactos/base/applications/write/CMakeLists.txt @@ -5,3 +5,7 @@ add_executable(write write.c rsrc.rc) set_module_type(write win32gui UNICODE) add_importlibs(write user32 gdi32 msvcrt kernel32) add_cd_file(TARGET write DESTINATION reactos/system32 FOR all) + +if(NOT MSVC) + allow_warnings(write) +endif() diff --git a/reactos/cmake/gcc.cmake b/reactos/cmake/gcc.cmake index 4149b5dd1a5..05b9ee6f458 100644 --- a/reactos/cmake/gcc.cmake +++ b/reactos/cmake/gcc.cmake @@ -5,6 +5,9 @@ add_compile_flags("-pipe -fms-extensions") # Debugging (Note: DWARF-4 on 4.5.1 when we ship) add_compile_flags("-gdwarf-2 -g2 -femit-struct-debug-detailed=none -feliminate-unused-debug-types") +# Do not allow warnings +add_compile_flags("-Werror") + # For some reason, cmake sets -fPIC, and we don't want it string(REPLACE "-fPIC" "" CMAKE_SHARED_LIBRARY_ASM_FLAGS ${CMAKE_SHARED_LIBRARY_ASM_FLAGS}) @@ -349,3 +352,7 @@ function(CreateBootSectorTarget2 _target_name _asm_file _binary_file _base_addre add_custom_target(${_target_name} ALL DEPENDS ${_binary_file}) endfunction() + +function(allow_warnings __module) + add_target_compile_flags(${__module} -Wno-error) +endfunction() diff --git a/reactos/dll/3rdparty/libtiff/CMakeLists.txt b/reactos/dll/3rdparty/libtiff/CMakeLists.txt index a83ca57ebd5..315e039b61b 100644 --- a/reactos/dll/3rdparty/libtiff/CMakeLists.txt +++ b/reactos/dll/3rdparty/libtiff/CMakeLists.txt @@ -50,8 +50,12 @@ add_library(libtiff SHARED tif_write.c tif_zip.c) -set_entrypoint(libtiff 0) +set_module_type(libtiff win32dll ENTRYPOINT 0) target_link_libraries(libtiff zlib getopt) add_importlibs(libtiff user32 msvcrt kernel32) add_dependencies(libtiff psdk) add_cd_file(TARGET libtiff DESTINATION reactos/system32 FOR all) + +if(NOT MSVC) + allow_warnings(libtiff) +endif() diff --git a/reactos/dll/3rdparty/libxslt/CMakeLists.txt b/reactos/dll/3rdparty/libxslt/CMakeLists.txt index 10df37c5b02..e90c979763c 100644 --- a/reactos/dll/3rdparty/libxslt/CMakeLists.txt +++ b/reactos/dll/3rdparty/libxslt/CMakeLists.txt @@ -44,3 +44,7 @@ endif() add_dependencies(libxslt psdk) add_pch(libxslt libxslt.h) add_cd_file(TARGET libxslt DESTINATION reactos/system32 FOR all) + +if(NOT MSVC) + allow_warnings(libxslt) +endif() diff --git a/reactos/dll/3rdparty/mesa32/CMakeLists.txt b/reactos/dll/3rdparty/mesa32/CMakeLists.txt index 32cf70fc86c..caf5bbcec49 100644 --- a/reactos/dll/3rdparty/mesa32/CMakeLists.txt +++ b/reactos/dll/3rdparty/mesa32/CMakeLists.txt @@ -260,7 +260,11 @@ endif() add_library(mesa32 SHARED ${SOURCE}) add_pch(mesa32 src/main/glheader.h) -set_entrypoint(mesa32 0) +set_module_type(mesa32 win32dll ENTRYPOINT 0) add_importlibs(mesa32 gdi32 user32 msvcrt kernel32 ntdll) add_dependencies(mesa32 psdk) add_cd_file(TARGET mesa32 DESTINATION reactos/system32 FOR all) + +if(NOT MSVC) + allow_warnings(mesa32) +endif() diff --git a/reactos/dll/directx/quartz/CMakeLists.txt b/reactos/dll/directx/quartz/CMakeLists.txt index aff19556112..aa1c426b924 100644 --- a/reactos/dll/directx/quartz/CMakeLists.txt +++ b/reactos/dll/directx/quartz/CMakeLists.txt @@ -72,3 +72,7 @@ add_importlibs(quartz add_pch(quartz quartz_private.h) add_cd_file(TARGET quartz DESTINATION reactos/system32 FOR all) + +if(NOT MSVC) + allow_warnings(quartz) +endif() diff --git a/reactos/dll/directx/wine/wined3d/CMakeLists.txt b/reactos/dll/directx/wine/wined3d/CMakeLists.txt index a7b742b28ed..dc5fd3cfdbf 100644 --- a/reactos/dll/directx/wine/wined3d/CMakeLists.txt +++ b/reactos/dll/directx/wine/wined3d/CMakeLists.txt @@ -70,3 +70,7 @@ add_dependencies(wined3d wineheaders) add_pch(wined3d wined3d_private.h) add_cd_file(TARGET wined3d DESTINATION reactos/system32 FOR all) add_importlib_target(wined3d.spec) + +if(NOT MSVC) + allow_warnings(wined3d) +endif() diff --git a/reactos/dll/win32/cabinet/CMakeLists.txt b/reactos/dll/win32/cabinet/CMakeLists.txt index f576efd211b..e90ef01ac4c 100644 --- a/reactos/dll/win32/cabinet/CMakeLists.txt +++ b/reactos/dll/win32/cabinet/CMakeLists.txt @@ -15,7 +15,7 @@ list(APPEND SOURCE add_library(cabinet SHARED ${SOURCE}) -set_entrypoint(cabinet 0) +set_module_type(cabinet win32dll ENTRYPOINT 0) target_link_libraries(cabinet wine) add_importlibs(cabinet kernel32 ntdll) add_importlib_target(cabinet.spec) diff --git a/reactos/dll/win32/itss/CMakeLists.txt b/reactos/dll/win32/itss/CMakeLists.txt index 188c2c37784..6e107078d90 100644 --- a/reactos/dll/win32/itss/CMakeLists.txt +++ b/reactos/dll/win32/itss/CMakeLists.txt @@ -24,6 +24,8 @@ set_module_type(itss win32dll) target_link_libraries(itss uuid wine) if(MSVC) target_link_libraries(itss itss_guid) +else() + allow_warnings(itss) endif() add_importlibs(itss diff --git a/reactos/dll/win32/jscript/CMakeLists.txt b/reactos/dll/win32/jscript/CMakeLists.txt index d346e64a206..b4d48696e18 100644 --- a/reactos/dll/win32/jscript/CMakeLists.txt +++ b/reactos/dll/win32/jscript/CMakeLists.txt @@ -62,3 +62,7 @@ add_importlibs(jscript add_pch(jscript jscript.h) add_dependencies(jscript jsglobal) add_cd_file(TARGET jscript DESTINATION reactos/system32 FOR all) + +if(NOT MSVC) + allow_warnings(jscript) +endif() diff --git a/reactos/dll/win32/localspl/CMakeLists.txt b/reactos/dll/win32/localspl/CMakeLists.txt index 5ce1b18826f..08808d0c55a 100644 --- a/reactos/dll/win32/localspl/CMakeLists.txt +++ b/reactos/dll/win32/localspl/CMakeLists.txt @@ -33,3 +33,7 @@ add_importlibs(localspl ntdll) add_cd_file(TARGET localspl DESTINATION reactos/system32 FOR all) + +if(NOT MSVC) + allow_warnings(localspl) +endif() diff --git a/reactos/dll/win32/mciseq/CMakeLists.txt b/reactos/dll/win32/mciseq/CMakeLists.txt index b6bba6b8e18..5b9fc45467a 100644 --- a/reactos/dll/win32/mciseq/CMakeLists.txt +++ b/reactos/dll/win32/mciseq/CMakeLists.txt @@ -10,8 +10,13 @@ list(APPEND SOURCE add_library(mciseq SHARED ${SOURCE}) -set_entrypoint(mciseq 0) +set_module_type(mciseq win32dll ENTRYPOINT 0) + target_link_libraries(mciseq wine) add_importlibs(mciseq winmm user32 kernel32 ntdll msvcrt) add_dependencies(mciseq psdk) add_cd_file(TARGET mciseq DESTINATION reactos/system32 FOR all) + +if(NOT MSVC) + allow_warnings(mciseq) +endif() diff --git a/reactos/dll/win32/mciwave/CMakeLists.txt b/reactos/dll/win32/mciwave/CMakeLists.txt index 48e6d5af48a..8a29a83caaa 100644 --- a/reactos/dll/win32/mciwave/CMakeLists.txt +++ b/reactos/dll/win32/mciwave/CMakeLists.txt @@ -13,8 +13,13 @@ list(APPEND SOURCE add_library(mciwave SHARED ${SOURCE}) -set_entrypoint(mciwave 0) +set_module_type(mciwave win32dll ENTRYPOINT 0) + target_link_libraries(mciwave wine) add_importlibs(mciwave user32 winmm msvcrt kernel32 ntdll) add_dependencies(mciwave psdk) add_cd_file(TARGET mciwave DESTINATION reactos/system32 FOR all) + +if(NOT MSVC) + allow_warnings(mciwave) +endif() diff --git a/reactos/dll/win32/rpcrt4/CMakeLists.txt b/reactos/dll/win32/rpcrt4/CMakeLists.txt index 46a2b70e57d..2f9d2d89754 100644 --- a/reactos/dll/win32/rpcrt4/CMakeLists.txt +++ b/reactos/dll/win32/rpcrt4/CMakeLists.txt @@ -50,3 +50,7 @@ add_delay_importlibs(rpcrt4 iphlpapi wininet secur32 user32) add_importlibs(rpcrt4 msvcrt advapi32 ws2_32 kernel32 ntdll) add_cd_file(TARGET rpcrt4 DESTINATION reactos/system32 FOR all) add_importlib_target(rpcrt4.spec) + +if(NOT MSVC) + allow_warnings(rpcrt4) +endif() diff --git a/reactos/dll/win32/shdocvw/CMakeLists.txt b/reactos/dll/win32/shdocvw/CMakeLists.txt index 1ad12e9f24e..1be4704b551 100644 --- a/reactos/dll/win32/shdocvw/CMakeLists.txt +++ b/reactos/dll/win32/shdocvw/CMakeLists.txt @@ -53,3 +53,7 @@ add_dependencies(shdocvw shdocvw_v1) add_pch(shdocvw shdocvw.h) add_cd_file(TARGET shdocvw DESTINATION reactos/system32 FOR all) add_importlib_target(shdocvw.spec) + +if(NOT MSVC) + allow_warnings(shdocvw) +endif() diff --git a/reactos/dll/win32/winhttp/CMakeLists.txt b/reactos/dll/win32/winhttp/CMakeLists.txt index 33777f232e5..dd2250be5e9 100644 --- a/reactos/dll/win32/winhttp/CMakeLists.txt +++ b/reactos/dll/win32/winhttp/CMakeLists.txt @@ -22,3 +22,7 @@ add_delay_importlibs(winhttp crypt32) add_importlibs(winhttp shlwapi wininet ws2_32 msvcrt advapi32 kernel32 ntdll) add_importlib_target(winhttp.spec) add_cd_file(TARGET winhttp DESTINATION reactos/system32 FOR all) + +if(NOT MSVC) + allow_warnings(winhttp) +endif() diff --git a/reactos/dll/win32/wininet/CMakeLists.txt b/reactos/dll/win32/wininet/CMakeLists.txt index 865ef7014a9..6ba338ecbbd 100644 --- a/reactos/dll/win32/wininet/CMakeLists.txt +++ b/reactos/dll/win32/wininet/CMakeLists.txt @@ -34,3 +34,7 @@ add_delay_importlibs(wininet secur32 crypt32) add_importlibs(wininet mpr shlwapi shell32 user32 advapi32 ws2_32 msvcrt kernel32 ntdll) add_cd_file(TARGET wininet DESTINATION reactos/system32 FOR all) add_importlib_target(wininet.spec) + +if(NOT MSVC) + allow_warnings(wininet) +endif() diff --git a/reactos/lib/3rdparty/libxml2/CMakeLists.txt b/reactos/lib/3rdparty/libxml2/CMakeLists.txt index 39ed9e74ab1..8d18f18d0f9 100644 --- a/reactos/lib/3rdparty/libxml2/CMakeLists.txt +++ b/reactos/lib/3rdparty/libxml2/CMakeLists.txt @@ -59,3 +59,7 @@ list(APPEND SOURCE add_library(libxml2 ${SOURCE}) target_link_libraries(libxml2 oldnames) add_dependencies(libxml2 psdk) + +if(NOT MSVC) + allow_warnings(libxml2) +endif() diff --git a/reactos/lib/drivers/lwip/CMakeLists.txt b/reactos/lib/drivers/lwip/CMakeLists.txt index e7e0e28cbb7..26c4594bfce 100644 --- a/reactos/lib/drivers/lwip/CMakeLists.txt +++ b/reactos/lib/drivers/lwip/CMakeLists.txt @@ -58,3 +58,6 @@ list(APPEND SOURCE add_library(lwip ${SOURCE}) add_dependencies(lwip bugcodes) +if(NOT MSVC) + allow_warnings(lwip) +endif() diff --git a/reactos/lib/rossym_new/CMakeLists.txt b/reactos/lib/rossym_new/CMakeLists.txt index 0a63d5b3ca3..3fa6f717030 100644 --- a/reactos/lib/rossym_new/CMakeLists.txt +++ b/reactos/lib/rossym_new/CMakeLists.txt @@ -22,4 +22,5 @@ else() add_library(rossym ${SOURCE}) add_pch(rossym precomp.h) add_dependencies(rossym psdk bugcodes) + allow_warnings(rossym) endif() diff --git a/reactos/lib/sdk/crt/msvcrtex.cmake b/reactos/lib/sdk/crt/msvcrtex.cmake index 9bc5dd0e47d..1ce79e18973 100644 --- a/reactos/lib/sdk/crt/msvcrtex.cmake +++ b/reactos/lib/sdk/crt/msvcrtex.cmake @@ -68,6 +68,7 @@ set_source_files_properties(startup/crtdll.c PROPERTIES COMPILE_DEFINITIONS CRTD if(NOT MSVC) target_link_libraries(msvcrtex oldnames) + allow_warnings(msvcrtex) endif() add_dependencies(msvcrtex psdk asm) From e293f3d468e4e574e019c42116d1892084137dbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Gardou?= Date: Sun, 4 Sep 2011 17:33:34 +0000 Subject: [PATCH 15/55] [CMAKE] - rostests side of r53585 svn path=/trunk/; revision=53586 --- rostests/tests/pseh2/CMakeLists.txt | 4 ++++ rostests/winetests/comctl32/CMakeLists.txt | 2 ++ rostests/winetests/fusion/CMakeLists.txt | 4 ++++ rostests/winetests/kernel32/CMakeLists.txt | 4 ++++ rostests/winetests/msvcrt/CMakeLists.txt | 2 ++ rostests/winetests/ntdll/CMakeLists.txt | 3 +++ rostests/winetests/powrprof/CMakeLists.txt | 4 ++++ rostests/winetests/rpcrt4/CMakeLists.txt | 7 ++++++- rostests/winetests/setupapi/CMakeLists.txt | 4 ++++ rostests/winetests/shdocvw/CMakeLists.txt | 4 ++++ rostests/winetests/user32/CMakeLists.txt | 4 ++++ rostests/winetests/winmm/CMakeLists.txt | 4 ++++ rostests/winetests/ws2_32/CMakeLists.txt | 4 ++++ 13 files changed, 49 insertions(+), 1 deletion(-) diff --git a/rostests/tests/pseh2/CMakeLists.txt b/rostests/tests/pseh2/CMakeLists.txt index bf5ece119ad..53080208653 100644 --- a/rostests/tests/pseh2/CMakeLists.txt +++ b/rostests/tests/pseh2/CMakeLists.txt @@ -6,3 +6,7 @@ target_link_libraries(pseh2_test wine ${PSEH_LIB}) set_module_type(pseh2_test win32cui) add_importlibs(pseh2_test msvcrt kernel32 ntdll) add_cd_file(TARGET pseh2_test DESTINATION reactos/bin FOR all) + +if(NOT MSVC) + allow_warnings(pseh2_test) +endif() diff --git a/rostests/winetests/comctl32/CMakeLists.txt b/rostests/winetests/comctl32/CMakeLists.txt index 78aa89973dc..34f36a2d0ab 100644 --- a/rostests/winetests/comctl32/CMakeLists.txt +++ b/rostests/winetests/comctl32/CMakeLists.txt @@ -39,6 +39,8 @@ target_link_libraries(comctl32_winetest wine) if(MSVC) target_link_libraries(comctl32_winetest uuid) +else() + allow_warnings(comctl32_winetest) endif() set_module_type(comctl32_winetest win32cui) diff --git a/rostests/winetests/fusion/CMakeLists.txt b/rostests/winetests/fusion/CMakeLists.txt index 7d0409d03cc..e265d5b2dbe 100644 --- a/rostests/winetests/fusion/CMakeLists.txt +++ b/rostests/winetests/fusion/CMakeLists.txt @@ -15,3 +15,7 @@ target_link_libraries(fusion_winetest wine) set_module_type(fusion_winetest win32cui) add_importlibs(fusion_winetest user32 msvcrt kernel32 ntdll) add_cd_file(TARGET fusion_winetest DESTINATION reactos/bin FOR all) + +if(NOT MSVC) + allow_warnings(fusion_winetest) +endif() diff --git a/rostests/winetests/kernel32/CMakeLists.txt b/rostests/winetests/kernel32/CMakeLists.txt index 30b0f22edf6..b18c9f7b557 100644 --- a/rostests/winetests/kernel32/CMakeLists.txt +++ b/rostests/winetests/kernel32/CMakeLists.txt @@ -3,6 +3,8 @@ add_definitions( -D__ROS_LONG64__ -D_DLL -D__USE_CRTIMP) +remove_definitions(-DWINVER=0x502 -D_WIN32_IE=0x600 -D_WIN32_WINNT=0x502) + set_rc_compiler() list(APPEND SOURCE @@ -49,4 +51,6 @@ target_link_libraries(kernel32_winetest wine) set_module_type(kernel32_winetest win32cui) add_importlibs(kernel32_winetest user32 advapi32 msvcrt kernel32 ntdll) +allow_warnings(kernel32_winetest) + add_cd_file(TARGET kernel32_winetest DESTINATION reactos/bin FOR all) \ No newline at end of file diff --git a/rostests/winetests/msvcrt/CMakeLists.txt b/rostests/winetests/msvcrt/CMakeLists.txt index f68840bd687..99163adac68 100644 --- a/rostests/winetests/msvcrt/CMakeLists.txt +++ b/rostests/winetests/msvcrt/CMakeLists.txt @@ -24,6 +24,8 @@ add_executable(msvcrt_winetest ${SOURCE}) if(MSVC) target_link_libraries(msvcrt_winetest oldnames) +else() + allow_warnings(msvcrt_winetest) endif() set_module_type(msvcrt_winetest win32cui) diff --git a/rostests/winetests/ntdll/CMakeLists.txt b/rostests/winetests/ntdll/CMakeLists.txt index 68c56bd557a..0fe16a31a38 100644 --- a/rostests/winetests/ntdll/CMakeLists.txt +++ b/rostests/winetests/ntdll/CMakeLists.txt @@ -29,3 +29,6 @@ add_executable(ntdll_winetest ${SOURCE}) set_module_type(ntdll_winetest win32cui) add_importlibs(ntdll_winetest user32 msvcrt kernel32 ntdll) add_cd_file(TARGET ntdll_winetest DESTINATION reactos/bin FOR all) +if(NOT MSVC) + allow_warnings(ntdll_winetest) +endif() diff --git a/rostests/winetests/powrprof/CMakeLists.txt b/rostests/winetests/powrprof/CMakeLists.txt index 1146223bcf7..3ae788bee91 100644 --- a/rostests/winetests/powrprof/CMakeLists.txt +++ b/rostests/winetests/powrprof/CMakeLists.txt @@ -8,3 +8,7 @@ add_executable(powrprof_winetest pwrprof.c testlist.c) set_module_type(powrprof_winetest win32cui) add_importlibs(powrprof_winetest advapi32 powrprof msvcrt kernel32 ntdll) add_cd_file(TARGET powrprof_winetest DESTINATION reactos/bin FOR all) + +if(NOT MSVC) + allow_warnings(powrprof_winetest) +endif() diff --git a/rostests/winetests/rpcrt4/CMakeLists.txt b/rostests/winetests/rpcrt4/CMakeLists.txt index 75b418df0f9..ad9383bcde4 100644 --- a/rostests/winetests/rpcrt4/CMakeLists.txt +++ b/rostests/winetests/rpcrt4/CMakeLists.txt @@ -1,5 +1,6 @@ -remove_definitions(-D_WIN32_WINNT=0x502) +remove_definitions(-DWINVER=0x502 -D_WIN32_IE=0x600 -D_WIN32_WINNT=0x502) + add_definitions(-D_WIN32_WINNT=0x500) add_definitions( @@ -44,3 +45,7 @@ target_link_libraries(rpcrt4_winetest set_module_type(rpcrt4_winetest win32cui) add_importlibs(rpcrt4_winetest ole32 rpcrt4 msvcrt kernel32 ntdll) add_cd_file(TARGET rpcrt4_winetest DESTINATION reactos/bin FOR all) + +if(NOT MSVC) + allow_warnings(rpcrt4_winetest) +endif() diff --git a/rostests/winetests/setupapi/CMakeLists.txt b/rostests/winetests/setupapi/CMakeLists.txt index ab220dd360b..65a5bd93dea 100644 --- a/rostests/winetests/setupapi/CMakeLists.txt +++ b/rostests/winetests/setupapi/CMakeLists.txt @@ -19,3 +19,7 @@ target_link_libraries(setupapi_winetest wine) set_module_type(setupapi_winetest win32cui) add_importlibs(setupapi_winetest advapi32 setupapi user32 msvcrt kernel32 ntdll) add_cd_file(TARGET setupapi_winetest DESTINATION reactos/bin FOR all) + +if(NOT MSVC) + allow_warnings(setupapi_winetest) +endif() diff --git a/rostests/winetests/shdocvw/CMakeLists.txt b/rostests/winetests/shdocvw/CMakeLists.txt index d4ec5befe4f..5bf15d81a79 100644 --- a/rostests/winetests/shdocvw/CMakeLists.txt +++ b/rostests/winetests/shdocvw/CMakeLists.txt @@ -15,3 +15,7 @@ target_link_libraries(shdocvw_winetest wine uuid) set_module_type(shdocvw_winetest win32cui) add_importlibs(shdocvw_winetest gdi32 shell32 ole32 oleaut32 user32 advapi32 msvcrt kernel32 ntdll) add_cd_file(TARGET shdocvw_winetest DESTINATION reactos/bin FOR all) + +if(NOT MSVC) + allow_warnings(shdocvw_winetest) +endif() diff --git a/rostests/winetests/user32/CMakeLists.txt b/rostests/winetests/user32/CMakeLists.txt index c1a45e01809..3c251c1d3aa 100644 --- a/rostests/winetests/user32/CMakeLists.txt +++ b/rostests/winetests/user32/CMakeLists.txt @@ -38,3 +38,7 @@ target_link_libraries(user32_winetest wine) set_module_type(user32_winetest win32cui) add_importlibs(user32_winetest user32 gdi32 advapi32 msvcrt kernel32 ntdll) add_cd_file(TARGET user32_winetest DESTINATION reactos/bin FOR all) + +if(NOT MSVC) + allow_warnings(user32_winetest) +endif() \ No newline at end of file diff --git a/rostests/winetests/winmm/CMakeLists.txt b/rostests/winetests/winmm/CMakeLists.txt index 4d24b9aa029..521c9609832 100644 --- a/rostests/winetests/winmm/CMakeLists.txt +++ b/rostests/winetests/winmm/CMakeLists.txt @@ -17,3 +17,7 @@ target_link_libraries(winmm_winetest wine dxguid) set_module_type(winmm_winetest win32cui) add_importlibs(winmm_winetest winmm user32 msvcrt kernel32 ntdll) add_cd_file(TARGET winmm_winetest DESTINATION reactos/bin FOR all) + +if(NOT MSVC) + allow_warnings(winmm_winetest) +endif() diff --git a/rostests/winetests/ws2_32/CMakeLists.txt b/rostests/winetests/ws2_32/CMakeLists.txt index 1001f21dca9..ec813611c09 100644 --- a/rostests/winetests/ws2_32/CMakeLists.txt +++ b/rostests/winetests/ws2_32/CMakeLists.txt @@ -8,3 +8,7 @@ target_link_libraries(ws2_32_winetest wine) set_module_type(ws2_32_winetest win32cui) add_importlibs(ws2_32_winetest ws2_32 user32 msvcrt kernel32 ntdll) add_cd_file(TARGET ws2_32_winetest DESTINATION reactos/bin FOR all) + +if(NOT MSVC) + allow_warnings(ws2_32_winetest) +endif() From 8f349a6383290fccedc783c1b26e2b243c748f90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Gardou?= Date: Sun, 4 Sep 2011 18:41:04 +0000 Subject: [PATCH 16/55] [CMAKE] - revert unwanted change from 53567 svn path=/trunk/; revision=53587 --- reactos/cmake/gcc.cmake | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/reactos/cmake/gcc.cmake b/reactos/cmake/gcc.cmake index 05b9ee6f458..7aba16ec976 100644 --- a/reactos/cmake/gcc.cmake +++ b/reactos/cmake/gcc.cmake @@ -302,6 +302,12 @@ if(PCH) DEPENDS ${_header_filename} ${ARGN}) get_target_property(_src_files ${_target_name} SOURCES) add_target_compile_flags(${_target_name} "-fpch-preprocess -Winvalid-pch -Wno-error=invalid-pch") + foreach(_item in ${_src_files}) + get_source_file_property(__src_lang ${_item} LANGUAGE) + if(__src_lang STREQUAL __lang) + set_source_files_properties(${_item} PROPERTIES OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${_gch_filename}) + endif() + endforeach() #set dependency checking : depends on precompiled header only which already depends on deeper header set_target_properties(${_target_name} PROPERTIES IMPLICIT_DEPENDS_INCLUDE_TRANSFORM "\"${_basename}\"=;<${_basename}>=") endmacro() From 1d8860502714b8eceeb1265db54b219ff84a58a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Gardou?= Date: Sun, 4 Sep 2011 20:27:48 +0000 Subject: [PATCH 17/55] [CMAKE/CRT] - disable pch for now svn path=/trunk/; revision=53588 --- reactos/lib/sdk/crt/crt.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reactos/lib/sdk/crt/crt.cmake b/reactos/lib/sdk/crt/crt.cmake index 6af16da7909..4f5a05b2850 100644 --- a/reactos/lib/sdk/crt/crt.cmake +++ b/reactos/lib/sdk/crt/crt.cmake @@ -442,5 +442,5 @@ endif() add_library(crt ${CRT_SOURCE}) target_link_libraries(crt chkstk) set_property(TARGET crt PROPERTY COMPILE_DEFINITIONS __MINGW_IMPORT=extern USE_MSVCRT_PREFIX _MSVCRT_LIB_ _MSVCRT_ _MT) -add_pch(crt precomp.h) +#add_pch(crt precomp.h) add_dependencies(crt psdk asm) From baf26fb9cd1f1103e6c3617d7b055bbaa9ae047f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Gardou?= Date: Sun, 4 Sep 2011 20:32:19 +0000 Subject: [PATCH 18/55] [PCMCIA] - remove #pragma once from pch svn path=/trunk/; revision=53589 --- reactos/drivers/bus/pcmcia/pcmcia.h | 1 - 1 file changed, 1 deletion(-) diff --git a/reactos/drivers/bus/pcmcia/pcmcia.h b/reactos/drivers/bus/pcmcia/pcmcia.h index 32dd5f28a06..b6536835da8 100644 --- a/reactos/drivers/bus/pcmcia/pcmcia.h +++ b/reactos/drivers/bus/pcmcia/pcmcia.h @@ -1,4 +1,3 @@ -#pragma once #include #include From 3dfda118e90d98a35d36dfe26b83e780f63b378d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Gardou?= Date: Sun, 4 Sep 2011 20:51:52 +0000 Subject: [PATCH 19/55] [ATAPI] - get rid of unused variable svn path=/trunk/; revision=53590 --- reactos/drivers/storage/ide/atapi/atapi.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/reactos/drivers/storage/ide/atapi/atapi.c b/reactos/drivers/storage/ide/atapi/atapi.c index fe3c9808c95..7988c85118f 100644 --- a/reactos/drivers/storage/ide/atapi/atapi.c +++ b/reactos/drivers/storage/ide/atapi/atapi.c @@ -1383,7 +1383,6 @@ Return Value: } else if (!(deviceExtension->DeviceFlags[i] & DFLAGS_CHANGER_INITED)){ ULONG j; - BOOLEAN isSanyo = FALSE; UCHAR vendorId[26]; // @@ -1415,7 +1414,6 @@ Return Value: deviceExtension->DeviceFlags[i] |= (DFLAGS_CHANGER_INITED | DFLAGS_SANYO_ATAPI_CHANGER); deviceExtension->DiscsPresent[i] = 3; - isSanyo = TRUE; } } } From b8e2175f8e4a3b35fa4c2251c60f1a31a0d235a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Gardou?= Date: Sun, 4 Sep 2011 21:04:26 +0000 Subject: [PATCH 20/55] [BUSLOGIC] - get rid of unused variable svn path=/trunk/; revision=53591 --- reactos/drivers/storage/port/buslogic/BusLogic958.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/reactos/drivers/storage/port/buslogic/BusLogic958.c b/reactos/drivers/storage/port/buslogic/BusLogic958.c index 0bf439e06b9..2a4d5fce67e 100644 --- a/reactos/drivers/storage/port/buslogic/BusLogic958.c +++ b/reactos/drivers/storage/port/buslogic/BusLogic958.c @@ -207,7 +207,7 @@ BT958HwFindAdapter(IN PVOID HwDeviceExtension, // static UCHAR k = 0; PACCESS_RANGE accessRange; // PCI_COMMON_CONFIG PCICommonConfig; - PUCHAR pciAddress, portFound; + PUCHAR pciAddress; char NumPort = 0; DebugPrint((TRACE,"\n BusLogic - Inside the Find Adapter Routine\n")); @@ -291,11 +291,9 @@ BT958HwFindAdapter(IN PVOID HwDeviceExtension, // Should we change this to double-word aligned to increase performance ConfigInfo->AlignmentMask = 0x0; - portFound = hcsp->IO_Address; - if (!Buslogic_InitBT958(deviceExtension,ConfigInfo)) // harware specific initializations. Find what's for our card { - ScsiPortLogError(deviceExtension, + (deviceExtension, NULL, 0, 0, From 9a5598685cd5d97e8d79648313615d005d194bd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Gardou?= Date: Sun, 4 Sep 2011 21:06:02 +0000 Subject: [PATCH 21/55] [CMAKE] - fix msvc build svn path=/trunk/; revision=53592 --- rostests/winetests/kernel32/CMakeLists.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/rostests/winetests/kernel32/CMakeLists.txt b/rostests/winetests/kernel32/CMakeLists.txt index b18c9f7b557..5a26ce15824 100644 --- a/rostests/winetests/kernel32/CMakeLists.txt +++ b/rostests/winetests/kernel32/CMakeLists.txt @@ -50,7 +50,8 @@ add_executable(kernel32_winetest ${SOURCE}) target_link_libraries(kernel32_winetest wine) set_module_type(kernel32_winetest win32cui) add_importlibs(kernel32_winetest user32 advapi32 msvcrt kernel32 ntdll) - -allow_warnings(kernel32_winetest) +if(NOT MSVC) + allow_warnings(kernel32_winetest) +endif() add_cd_file(TARGET kernel32_winetest DESTINATION reactos/bin FOR all) \ No newline at end of file From 5932142777ab7215a49cb9a4acd9726c8e454d85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Gardou?= Date: Sun, 4 Sep 2011 21:08:29 +0000 Subject: [PATCH 22/55] [BUSLOGIC] - woops, revert some accident of 53591 svn path=/trunk/; revision=53593 --- reactos/drivers/storage/port/buslogic/BusLogic958.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reactos/drivers/storage/port/buslogic/BusLogic958.c b/reactos/drivers/storage/port/buslogic/BusLogic958.c index 2a4d5fce67e..ed4ba615d98 100644 --- a/reactos/drivers/storage/port/buslogic/BusLogic958.c +++ b/reactos/drivers/storage/port/buslogic/BusLogic958.c @@ -293,7 +293,7 @@ BT958HwFindAdapter(IN PVOID HwDeviceExtension, if (!Buslogic_InitBT958(deviceExtension,ConfigInfo)) // harware specific initializations. Find what's for our card { - (deviceExtension, + ScsiPortLogError(deviceExtension, NULL, 0, 0, From b1b3c259e8319642311b4a88e0d77b8d6a35ec30 Mon Sep 17 00:00:00 2001 From: Amine Khaldi Date: Sun, 4 Sep 2011 21:52:37 +0000 Subject: [PATCH 23/55] [CMAKE] * Properly use add_target_compile_flags. svn path=/trunk/; revision=53594 --- reactos/cmake/gcc.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reactos/cmake/gcc.cmake b/reactos/cmake/gcc.cmake index 7aba16ec976..d134b378aff 100644 --- a/reactos/cmake/gcc.cmake +++ b/reactos/cmake/gcc.cmake @@ -360,5 +360,5 @@ function(CreateBootSectorTarget2 _target_name _asm_file _binary_file _base_addre endfunction() function(allow_warnings __module) - add_target_compile_flags(${__module} -Wno-error) + add_target_compile_flags(${__module} "-Wno-error") endfunction() From f34a7454a4d77ce4edf02acc32639634bd7aca24 Mon Sep 17 00:00:00 2001 From: James Tabor Date: Sun, 4 Sep 2011 21:54:57 +0000 Subject: [PATCH 24/55] [User32] - Fixed over check conditions for deleting regions in set window region. - Disabled offsets with window region. Fixes wine tests.. svn path=/trunk/; revision=53595 --- reactos/dll/win32/user32/windows/paint.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/reactos/dll/win32/user32/windows/paint.c b/reactos/dll/win32/user32/windows/paint.c index 0d90f232158..74e3c8af1e1 100644 --- a/reactos/dll/win32/user32/windows/paint.c +++ b/reactos/dll/win32/user32/windows/paint.c @@ -208,7 +208,7 @@ SetWindowRgn( if (!Hook) { Ret = NtUserSetWindowRgn(hWnd, hRgn, bRedraw); - if (hRgn && Ret) + if (Ret) DeleteObject(hRgn); return Ret; } @@ -285,10 +285,10 @@ GetWindowRgn( if (!Ret) return ERROR; - +/* if (hWnd != GetDesktopWindow()) // pWnd->fnid != FNID_DESKTOP) Ret = OffsetRgn(hRgn, -pWnd->rcWindow.left, -pWnd->rcWindow.top); - +*/ if (pWnd->ExStyle & WS_EX_LAYOUTRTL) MirrorRgn(hWnd, hRgn); @@ -319,10 +319,10 @@ GetWindowRgnBox( if (!Ret) return ERROR; - +/* if (hWnd != GetDesktopWindow()) // pWnd->fnid != FNID_DESKTOP) OffsetRect(lprc, -pWnd->rcWindow.left, -pWnd->rcWindow.top); - +*/ if (pWnd->ExStyle & WS_EX_LAYOUTRTL) MirrorWindowRect(pWnd, lprc); From 9ef1a74a8db6dd77080125bec3cb48a18ab4ce5b Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Mon, 5 Sep 2011 09:54:20 +0000 Subject: [PATCH 25/55] [NTOS/CONFIG] - Remove unnecessary assignments. Spotted by PVS and Dmitry Chapyshev. This may change the behaviour of that codepath, so test results are going to be observed. svn path=/trunk/; revision=53596 --- reactos/ntoskrnl/config/cmvalche.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/reactos/ntoskrnl/config/cmvalche.c b/reactos/ntoskrnl/config/cmvalche.c index 8c8c3618dd1..9f24c7e08cc 100644 --- a/reactos/ntoskrnl/config/cmvalche.c +++ b/reactos/ntoskrnl/config/cmvalche.c @@ -49,7 +49,6 @@ CmpGetValueListFromCache(IN PCM_KEY_CONTROL_BLOCK Kcb, PHHIVE Hive; PCACHED_CHILD_LIST ChildList; HCELL_INDEX CellToRelease; - PCM_KEY_NODE KeyNode; /* Set defaults */ *ValueListToRelease = HCELL_NIL; @@ -58,8 +57,6 @@ CmpGetValueListFromCache(IN PCM_KEY_CONTROL_BLOCK Kcb, /* Get the hive and value cache */ Hive = Kcb->KeyHive; ChildList = &Kcb->ValueCache; - KeyNode = (PCM_KEY_NODE)HvGetCell(Hive, Kcb->KeyCell); - ChildList = (PCACHED_CHILD_LIST)&KeyNode->ValueList; /* Check if the value is cached */ if (CmpIsValueCached(ChildList->ValueList)) @@ -212,7 +209,6 @@ CmpFindValueByNameFromCache(IN PCM_KEY_CONTROL_BLOCK Kcb, BOOLEAN IndexIsCached; ULONG i = 0; HCELL_INDEX Cell = HCELL_NIL; - PCM_KEY_NODE KeyNode; /* Set defaults */ *CellToRelease = HCELL_NIL; @@ -221,8 +217,6 @@ CmpFindValueByNameFromCache(IN PCM_KEY_CONTROL_BLOCK Kcb, /* Get the hive and child list */ Hive = Kcb->KeyHive; ChildList = &Kcb->ValueCache; - KeyNode = (PCM_KEY_NODE)HvGetCell(Hive, Kcb->KeyCell); - ChildList = (PCACHED_CHILD_LIST)&KeyNode->ValueList; /* Check if the child list has any entries */ if (ChildList->Count != 0) From ea601ab08c4040e00b2581c7acd7c8a5a6e5da38 Mon Sep 17 00:00:00 2001 From: Sylvain Petreolle Date: Mon, 5 Sep 2011 12:41:18 +0000 Subject: [PATCH 26/55] [CMAKE] Don't assume CMAKE_SHARED_LIBRARY_ASM_FLAGS exists. svn path=/trunk/; revision=53597 --- reactos/cmake/gcc.cmake | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/reactos/cmake/gcc.cmake b/reactos/cmake/gcc.cmake index d134b378aff..3c7be0f425d 100644 --- a/reactos/cmake/gcc.cmake +++ b/reactos/cmake/gcc.cmake @@ -9,7 +9,9 @@ add_compile_flags("-gdwarf-2 -g2 -femit-struct-debug-detailed=none -feliminate-u add_compile_flags("-Werror") # For some reason, cmake sets -fPIC, and we don't want it -string(REPLACE "-fPIC" "" CMAKE_SHARED_LIBRARY_ASM_FLAGS ${CMAKE_SHARED_LIBRARY_ASM_FLAGS}) +if(DEFINED CMAKE_SHARED_LIBRARY_ASM_FLAGS) + string(REPLACE "-fPIC" "" CMAKE_SHARED_LIBRARY_ASM_FLAGS ${CMAKE_SHARED_LIBRARY_ASM_FLAGS}) +endif() # Tuning if(ARCH MATCHES i386) From 197ed4b94ec8c71396e45b8ec37430635a91f78e Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Mon, 5 Sep 2011 14:27:48 +0000 Subject: [PATCH 27/55] [NTOS/EX] - Remove redundant check for a previous mode. Spotted by PVS. svn path=/trunk/; revision=53598 --- reactos/ntoskrnl/ex/sysinfo.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/reactos/ntoskrnl/ex/sysinfo.c b/reactos/ntoskrnl/ex/sysinfo.c index 837c9e6fc41..6c1a017957d 100644 --- a/reactos/ntoskrnl/ex/sysinfo.c +++ b/reactos/ntoskrnl/ex/sysinfo.c @@ -1948,17 +1948,10 @@ NtQuerySystemInformation(IN SYSTEM_INFORMATION_CLASS SystemInformationClass, FStatus = CallQS [SystemInformationClass].Query(SystemInformation, Length, &ResultLength); - if (UnsafeResultLength != NULL) - { - if (PreviousMode != KernelMode) - { - *UnsafeResultLength = ResultLength; - } - else - { - *UnsafeResultLength = ResultLength; - } - } + + /* Save the result length to the caller */ + if (UnsafeResultLength) + *UnsafeResultLength = ResultLength; } } _SEH2_EXCEPT(ExSystemExceptionFilter()) From 0f969dedca0c4fbb260476847e5b184f0fbc6e4f Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Mon, 5 Sep 2011 15:05:56 +0000 Subject: [PATCH 28/55] [NTOS] - Fix IoCheckEaBufferValidity (IntEaLength must be signed, otherwise loop exiting condition may not trigger). - SEH-protect ObQueryNameString (by Dmitry Chapyshev's request). svn path=/trunk/; revision=53599 --- reactos/ntoskrnl/io/iomgr/util.c | 3 +- reactos/ntoskrnl/ob/obname.c | 262 ++++++++++++++++++------------- 2 files changed, 153 insertions(+), 112 deletions(-) diff --git a/reactos/ntoskrnl/io/iomgr/util.c b/reactos/ntoskrnl/io/iomgr/util.c index c1164977a67..e2c0bcee0c1 100644 --- a/reactos/ntoskrnl/io/iomgr/util.c +++ b/reactos/ntoskrnl/io/iomgr/util.c @@ -166,7 +166,8 @@ IoCheckEaBufferValidity(IN PFILE_FULL_EA_INFORMATION EaBuffer, OUT PULONG ErrorOffset) { PFILE_FULL_EA_INFORMATION EaBufferEnd; - ULONG NextEaBufferOffset, IntEaLength; + ULONG NextEaBufferOffset; + LONG IntEaLength; PAGED_CODE(); diff --git a/reactos/ntoskrnl/ob/obname.c b/reactos/ntoskrnl/ob/obname.c index f3a91e63dda..b0d4ca59f2c 100644 --- a/reactos/ntoskrnl/ob/obname.c +++ b/reactos/ntoskrnl/ob/obname.c @@ -986,6 +986,7 @@ ObQueryNameString(IN PVOID Object, ULONG NameSize; PWCH ObjectName; BOOLEAN ObjectIsNamed; + NTSTATUS Status = STATUS_SUCCESS; /* Get the Kernel Meta-Structures */ ObjectHeader = OBJECT_TO_OBJECT_HEADER(Object); @@ -994,28 +995,57 @@ ObQueryNameString(IN PVOID Object, /* Check if a Query Name Procedure is available */ if (ObjectHeader->Type->TypeInfo.QueryNameProcedure) { - /* Call the procedure */ + /* Call the procedure inside SEH */ ObjectIsNamed = ((LocalInfo) && (LocalInfo->Name.Length > 0)); - return ObjectHeader->Type->TypeInfo.QueryNameProcedure(Object, + + _SEH2_TRY + { + Status = ObjectHeader->Type->TypeInfo.QueryNameProcedure(Object, ObjectIsNamed, ObjectNameInfo, Length, ReturnLength, KernelMode); + } + _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) + { + /* Return the exception code */ + Status = _SEH2_GetExceptionCode(); + } + _SEH2_END; + + return Status; } /* Check if the object doesn't even have a name */ if (!(LocalInfo) || !(LocalInfo->Name.Buffer)) { - /* We're returning the name structure */ - *ReturnLength = sizeof(OBJECT_NAME_INFORMATION); + Status = STATUS_SUCCESS; - /* Check if we were given enough space */ - if (*ReturnLength > Length) return STATUS_INFO_LENGTH_MISMATCH; + _SEH2_TRY + { + /* We're returning the name structure */ + *ReturnLength = sizeof(OBJECT_NAME_INFORMATION); - /* Return an empty buffer */ - RtlInitEmptyUnicodeString(&ObjectNameInfo->Name, NULL, 0); - return STATUS_SUCCESS; + /* Check if we were given enough space */ + if (*ReturnLength > Length) + { + Status = STATUS_INFO_LENGTH_MISMATCH; + } + else + { + /* Return an empty buffer */ + RtlInitEmptyUnicodeString(&ObjectNameInfo->Name, NULL, 0); + } + } + _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) + { + /* Return the exception code */ + Status = _SEH2_GetExceptionCode(); + } + _SEH2_END; + + return Status; } /* @@ -1025,126 +1055,136 @@ ObQueryNameString(IN PVOID Object, * enough right at the beginning, not work our way through * and find out at the end */ - if (Object == ObpRootDirectoryObject) + _SEH2_TRY { - /* Size of the '\' string */ - NameSize = sizeof(OBJ_NAME_PATH_SEPARATOR); - } - else - { - /* Get the Object Directory and add name of Object */ - ParentDirectory = LocalInfo->Directory; - NameSize = sizeof(OBJ_NAME_PATH_SEPARATOR) + LocalInfo->Name.Length; - - /* Loop inside the directory to get the top-most one (meaning root) */ - while ((ParentDirectory != ObpRootDirectoryObject) && (ParentDirectory)) + if (Object == ObpRootDirectoryObject) { - /* Get the Name Information */ - LocalInfo = OBJECT_HEADER_TO_NAME_INFO( - OBJECT_TO_OBJECT_HEADER(ParentDirectory)); + /* Size of the '\' string */ + NameSize = sizeof(OBJ_NAME_PATH_SEPARATOR); + } + else + { + /* Get the Object Directory and add name of Object */ + ParentDirectory = LocalInfo->Directory; + NameSize = sizeof(OBJ_NAME_PATH_SEPARATOR) + LocalInfo->Name.Length; - /* Add the size of the Directory Name */ - if (LocalInfo && LocalInfo->Directory) + /* Loop inside the directory to get the top-most one (meaning root) */ + while ((ParentDirectory != ObpRootDirectoryObject) && (ParentDirectory)) { - /* Size of the '\' string + Directory Name */ - NameSize += sizeof(OBJ_NAME_PATH_SEPARATOR) + - LocalInfo->Name.Length; + /* Get the Name Information */ + LocalInfo = OBJECT_HEADER_TO_NAME_INFO( + OBJECT_TO_OBJECT_HEADER(ParentDirectory)); - /* Move to next parent Directory */ - ParentDirectory = LocalInfo->Directory; - } - else - { - /* Directory with no name. We append "...\" */ - NameSize += sizeof(L"...") + sizeof(OBJ_NAME_PATH_SEPARATOR); - break; + /* Add the size of the Directory Name */ + if (LocalInfo && LocalInfo->Directory) + { + /* Size of the '\' string + Directory Name */ + NameSize += sizeof(OBJ_NAME_PATH_SEPARATOR) + + LocalInfo->Name.Length; + + /* Move to next parent Directory */ + ParentDirectory = LocalInfo->Directory; + } + else + { + /* Directory with no name. We append "...\" */ + NameSize += sizeof(L"...") + sizeof(OBJ_NAME_PATH_SEPARATOR); + break; + } } } - } - /* Finally, add the name of the structure and the null char */ - *ReturnLength = NameSize + - sizeof(OBJECT_NAME_INFORMATION) + - sizeof(UNICODE_NULL); + /* Finally, add the name of the structure and the null char */ + *ReturnLength = NameSize + + sizeof(OBJECT_NAME_INFORMATION) + + sizeof(UNICODE_NULL); - /* Check if we were given enough space */ - if (*ReturnLength > Length) return STATUS_INFO_LENGTH_MISMATCH; + /* Check if we were given enough space */ + if (*ReturnLength > Length) _SEH2_YIELD(return STATUS_INFO_LENGTH_MISMATCH); - /* - * Now we will actually create the name. We work backwards because - * it's easier to start off from the Name we have and walk up the - * parent directories. We use the same logic as Name Length calculation. - */ - LocalInfo = OBJECT_HEADER_TO_NAME_INFO(ObjectHeader); - ObjectName = (PWCH)((ULONG_PTR)ObjectNameInfo + *ReturnLength); - *--ObjectName = UNICODE_NULL; + /* + * Now we will actually create the name. We work backwards because + * it's easier to start off from the Name we have and walk up the + * parent directories. We use the same logic as Name Length calculation. + */ + LocalInfo = OBJECT_HEADER_TO_NAME_INFO(ObjectHeader); + ObjectName = (PWCH)((ULONG_PTR)ObjectNameInfo + *ReturnLength); + *--ObjectName = UNICODE_NULL; - /* Check if the object is actually the Root directory */ - if (Object == ObpRootDirectoryObject) - { - /* This is already the Root Directory, return "\\" */ - *--ObjectName = OBJ_NAME_PATH_SEPARATOR; - ObjectNameInfo->Name.Length = (USHORT)NameSize; - ObjectNameInfo->Name.MaximumLength = (USHORT)(NameSize + - sizeof(UNICODE_NULL)); - ObjectNameInfo->Name.Buffer = ObjectName; - return STATUS_SUCCESS; - } - else - { - /* Start by adding the Object's Name */ - ObjectName = (PWCH)((ULONG_PTR)ObjectName - - LocalInfo->Name.Length); - RtlCopyMemory(ObjectName, - LocalInfo->Name.Buffer, - LocalInfo->Name.Length); - - /* Now parse the Parent directories until we reach the top */ - ParentDirectory = LocalInfo->Directory; - while ((ParentDirectory != ObpRootDirectoryObject) && (ParentDirectory)) + /* Check if the object is actually the Root directory */ + if (Object == ObpRootDirectoryObject) { - /* Get the name information */ - LocalInfo = OBJECT_HEADER_TO_NAME_INFO( - OBJECT_TO_OBJECT_HEADER(ParentDirectory)); + /* This is already the Root Directory, return "\\" */ + *--ObjectName = OBJ_NAME_PATH_SEPARATOR; + ObjectNameInfo->Name.Length = (USHORT)NameSize; + ObjectNameInfo->Name.MaximumLength = (USHORT)(NameSize + + sizeof(UNICODE_NULL)); + ObjectNameInfo->Name.Buffer = ObjectName; + _SEH2_YIELD(return STATUS_SUCCESS); + } + else + { + /* Start by adding the Object's Name */ + ObjectName = (PWCH)((ULONG_PTR)ObjectName - + LocalInfo->Name.Length); + RtlCopyMemory(ObjectName, + LocalInfo->Name.Buffer, + LocalInfo->Name.Length); - /* Add the "\" */ + /* Now parse the Parent directories until we reach the top */ + ParentDirectory = LocalInfo->Directory; + while ((ParentDirectory != ObpRootDirectoryObject) && (ParentDirectory)) + { + /* Get the name information */ + LocalInfo = OBJECT_HEADER_TO_NAME_INFO( + OBJECT_TO_OBJECT_HEADER(ParentDirectory)); + + /* Add the "\" */ + *(--ObjectName) = OBJ_NAME_PATH_SEPARATOR; + + /* Add the Parent Directory's Name */ + if (LocalInfo && LocalInfo->Name.Buffer) + { + /* Add the name */ + ObjectName = (PWCH)((ULONG_PTR)ObjectName - + LocalInfo->Name.Length); + RtlCopyMemory(ObjectName, + LocalInfo->Name.Buffer, + LocalInfo->Name.Length); + + /* Move to next parent */ + ParentDirectory = LocalInfo->Directory; + } + else + { + /* Directory without a name, we add "..." */ + ObjectName = (PWCH)((ULONG_PTR)ObjectName - + sizeof(L"...") + + sizeof(UNICODE_NULL)); + RtlCopyMemory(ObjectName, + L"...", + sizeof(L"...") + sizeof(UNICODE_NULL)); + break; + } + } + + /* Add Root Directory Name */ *(--ObjectName) = OBJ_NAME_PATH_SEPARATOR; - - /* Add the Parent Directory's Name */ - if (LocalInfo && LocalInfo->Name.Buffer) - { - /* Add the name */ - ObjectName = (PWCH)((ULONG_PTR)ObjectName - - LocalInfo->Name.Length); - RtlCopyMemory(ObjectName, - LocalInfo->Name.Buffer, - LocalInfo->Name.Length); - - /* Move to next parent */ - ParentDirectory = LocalInfo->Directory; - } - else - { - /* Directory without a name, we add "..." */ - ObjectName = (PWCH)((ULONG_PTR)ObjectName - - sizeof(L"...") + sizeof(UNICODE_NULL)); - RtlCopyMemory(ObjectName, - L"...", - sizeof(L"...") + sizeof(UNICODE_NULL)); - break; - } + ObjectNameInfo->Name.Length = (USHORT)NameSize; + ObjectNameInfo->Name.MaximumLength = + (USHORT)(NameSize + sizeof(UNICODE_NULL)); + ObjectNameInfo->Name.Buffer = ObjectName; } - - /* Add Root Directory Name */ - *(--ObjectName) = OBJ_NAME_PATH_SEPARATOR; - ObjectNameInfo->Name.Length = (USHORT)NameSize; - ObjectNameInfo->Name.MaximumLength = (USHORT)(NameSize + - sizeof(UNICODE_NULL)); - ObjectNameInfo->Name.Buffer = ObjectName; } + _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) + { + /* Return the exception code */ + Status = _SEH2_GetExceptionCode(); + } + _SEH2_END; /* Return success */ - return STATUS_SUCCESS; + return Status; } VOID From f627019d71b1002814b2ac4adf5998a89b7ebd17 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Mon, 5 Sep 2011 15:20:07 +0000 Subject: [PATCH 29/55] [HAL] - Use functions instead of macros for irq<->vector<->irql translation, this will be neccessary, once apic support is there - Disable mp hal in rbuild for now, its broken anyway svn path=/trunk/; revision=53600 --- reactos/hal/halx86/directory.rbuild | 4 ++-- reactos/hal/halx86/include/hal.h | 2 -- reactos/hal/halx86/include/halirq.h | 34 ++++++++++------------------- reactos/hal/halx86/up/pic.c | 21 ++++++++++++++++++ 4 files changed, 35 insertions(+), 26 deletions(-) diff --git a/reactos/hal/halx86/directory.rbuild b/reactos/hal/halx86/directory.rbuild index 9c8c482a2c7..a40bca6119b 100644 --- a/reactos/hal/halx86/directory.rbuild +++ b/reactos/hal/halx86/directory.rbuild @@ -13,9 +13,9 @@ - + diff --git a/reactos/hal/halx86/include/hal.h b/reactos/hal/halx86/include/hal.h index 124d716b95f..ddf7518f2a8 100644 --- a/reactos/hal/halx86/include/hal.h +++ b/reactos/hal/halx86/include/hal.h @@ -55,13 +55,11 @@ #define TAG_BUS_HANDLER 'BusH' /* Internal HAL Headers */ -#include "apic.h" #include "bus.h" #include "halirq.h" #include "haldma.h" #include "halp.h" #include "mps.h" -#include "ioapic.h" #include "halacpi.h" /* EOF */ diff --git a/reactos/hal/halx86/include/halirq.h b/reactos/hal/halx86/include/halirq.h index 63dec6e62e8..8bde9191f02 100644 --- a/reactos/hal/halx86/include/halirq.h +++ b/reactos/hal/halx86/include/halirq.h @@ -4,29 +4,19 @@ #pragma once -#ifdef CONFIG_SMP +UCHAR +FASTCALL +HalpIrqToVector(UCHAR Irq); -#define FIRST_DEVICE_VECTOR (0x30) -#define FIRST_SYSTEM_VECTOR (0xef) +KIRQL +FASTCALL +HalpVectorToIrql(UCHAR Vector); -#define IRQ_BASE FIRST_DEVICE_VECTOR -#define NR_IRQS (FIRST_SYSTEM_VECTOR - FIRST_DEVICE_VECTOR) +UCHAR +FASTCALL +HalpVectorToIrq(UCHAR Vector); -/* - * FIXME: - * This does not work if we have more than 24 IRQs (ie. more than one I/O APIC) - */ -#define VECTOR2IRQ(vector) (23 - (vector - IRQ_BASE) / 8) -#define VECTOR2IRQL(vector) (PROFILE_LEVEL - VECTOR2IRQ(vector)) -#define IRQ2VECTOR(irq) (((23 - (irq)) * 8) + FIRST_DEVICE_VECTOR) +#define VECTOR2IRQ(vector) HalpVectorToIrq(vector) +#define VECTOR2IRQL(vector) HalpVectorToIrql(vector) +#define IRQ2VECTOR(irq) HalpIrqToVector(irq) -#else - -#define IRQ_BASE (0x30) -#define NR_IRQS (16) - -#define VECTOR2IRQ(vector) ((vector) - IRQ_BASE) -#define VECTOR2IRQL(vector) (PROFILE_LEVEL - VECTOR2IRQ(vector)) -#define IRQ2VECTOR(irq) ((irq) + IRQ_BASE) - -#endif diff --git a/reactos/hal/halx86/up/pic.c b/reactos/hal/halx86/up/pic.c index d441c1a4997..6a8929bf4a5 100644 --- a/reactos/hal/halx86/up/pic.c +++ b/reactos/hal/halx86/up/pic.c @@ -512,6 +512,27 @@ HalpInitializePICs(IN BOOLEAN EnableInterrupts) __writeeflags(EFlags); } +UCHAR +FASTCALL +HalpIrqToVector(UCHAR Irq) +{ + return (PRIMARY_VECTOR_BASE + Irq); +} + +UCHAR +FASTCALL +HalpVectorToIrq(UCHAR Vector) +{ + return (Vector - PRIMARY_VECTOR_BASE); +} + +KIRQL +FASTCALL +HalpVectorToIrql(UCHAR Vector) +{ + return (PROFILE_LEVEL - (Vector - PRIMARY_VECTOR_BASE)); +} + /* IRQL MANAGEMENT ************************************************************/ /* From 5770481f788c26dc00cfb48113a7ac0caa2fbe31 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Mon, 5 Sep 2011 15:28:49 +0000 Subject: [PATCH 30/55] Fix build svn path=/trunk/; revision=53601 --- reactos/hal/halx86/include/halirq.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/reactos/hal/halx86/include/halirq.h b/reactos/hal/halx86/include/halirq.h index 8bde9191f02..5304f5d1f6b 100644 --- a/reactos/hal/halx86/include/halirq.h +++ b/reactos/hal/halx86/include/halirq.h @@ -4,6 +4,12 @@ #pragma once +#ifdef _MINIHAL_ +#define VECTOR2IRQ(vector) ((vector) - PRIMARY_VECTOR_BASE) +#define VECTOR2IRQL(vector) (PROFILE_LEVEL - VECTOR2IRQ(vector)) +#define IRQ2VECTOR(irq) ((irq) + PRIMARY_VECTOR_BASE) +#else + UCHAR FASTCALL HalpIrqToVector(UCHAR Irq); @@ -20,3 +26,4 @@ HalpVectorToIrq(UCHAR Vector); #define VECTOR2IRQL(vector) HalpVectorToIrql(vector) #define IRQ2VECTOR(irq) HalpIrqToVector(irq) +#endif From 91cb92e54c72be66667d616eed76f9851a6e9461 Mon Sep 17 00:00:00 2001 From: Dmitry Gorbachev Date: Mon, 5 Sep 2011 15:36:33 +0000 Subject: [PATCH 31/55] [FAT32] Move the FAT sector buffer higher for RBuild builds, too. svn path=/trunk/; revision=53602 --- reactos/boot/freeldr/bootsect/fat32.asm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/reactos/boot/freeldr/bootsect/fat32.asm b/reactos/boot/freeldr/bootsect/fat32.asm index 81574b31bc2..787a2fc6091 100644 --- a/reactos/boot/freeldr/bootsect/fat32.asm +++ b/reactos/boot/freeldr/bootsect/fat32.asm @@ -443,14 +443,14 @@ LoadFatSector: je LoadFatSectorAlreadyLoaded mov DWORD [FatSectorInCache],eax - mov bx,7000h + mov bx,9000h mov es,bx - xor bx,bx ; We will load it to [7000:0000h] + xor bx,bx ; We will load it to [9000:0000h] mov cx,1 call ReadSectors LoadFatSectorAlreadyLoaded: - mov bx,7000h + mov bx,9000h mov es,bx pop ecx mov eax,DWORD [es:ecx] ; Get FAT entry From 26975c720b6344b1ccec248b54b54e96881c8347 Mon Sep 17 00:00:00 2001 From: Dmitry Gorbachev Date: Mon, 5 Sep 2011 15:37:35 +0000 Subject: [PATCH 32/55] [RSYM] .stab/.stabstr sections have no IMAGE_SCN_LNK_REMOVE flag now. svn path=/trunk/; revision=53603 --- reactos/tools/rsym/rsym.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/reactos/tools/rsym/rsym.c b/reactos/tools/rsym/rsym.c index 50aa2e39c0e..2c55fa7751d 100644 --- a/reactos/tools/rsym/rsym.c +++ b/reactos/tools/rsym/rsym.c @@ -557,7 +557,7 @@ CreateOutputFile(FILE *OutFile, void *InData, if ((0 == StartOfRawData || InSectionHeaders[Section].PointerToRawData < StartOfRawData) && 0 != InSectionHeaders[Section].PointerToRawData - && 0 == (InSectionHeaders[Section].Characteristics & IMAGE_SCN_LNK_REMOVE)) + && 0 != (strncmp(InSectionHeaders[Section].Name, ".stab", 5))) { StartOfRawData = InSectionHeaders[Section].PointerToRawData; } @@ -609,7 +609,7 @@ CreateOutputFile(FILE *OutFile, void *InData, OutRelocSection = NULL; for (Section = 0; Section < InFileHeader->NumberOfSections; Section++) { - if (0 == (InSectionHeaders[Section].Characteristics & IMAGE_SCN_LNK_REMOVE)) + if (0 != (strncmp(InSectionHeaders[Section].Name, ".stab", 5))) { *CurrentSectionHeader = InSectionHeaders[Section]; CurrentSectionHeader->PointerToLinenumbers = 0; From 238dec164e3c0a261e841f7f2e460dd0e0159477 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Gardou?= Date: Mon, 5 Sep 2011 19:08:11 +0000 Subject: [PATCH 33/55] [MSVCRT] - some fixes to spec file, based on a wine patch by Piotr Caban svn path=/trunk/; revision=53604 --- reactos/dll/win32/msvcrt/msvcrt.spec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/reactos/dll/win32/msvcrt/msvcrt.spec b/reactos/dll/win32/msvcrt/msvcrt.spec index 4bf6749eee7..d371cb27b55 100644 --- a/reactos/dll/win32/msvcrt/msvcrt.spec +++ b/reactos/dll/win32/msvcrt/msvcrt.spec @@ -992,10 +992,10 @@ # stub _vsprintf_p # stub _vsprintf_p_l # stub _vsprintf_s_l -@ cdecl _vswprintf(ptr long wstr ptr) _vsnwprintf +@ cdecl _vswprintf(ptr wstr ptr) @ cdecl _vswprintf_c(ptr long wstr ptr) _vsnwprintf # @ cdecl _vswprintf_c_l(ptr long wstr ptr ptr) _vsnwprintf_l -# @ cdecl _vswprintf_l(ptr long wstr ptr ptr) _vsnwprintf_l +# @ cdecl _vswprintf_l(ptr wstr ptr ptr) # @ cdecl _vswprintf_p_l(ptr long wstr ptr ptr) _vsnwprintf_l # @ cdecl _vswprintf_s_l(ptr long wstr ptr ptr) # stub _vwprintf_l From 6965d3d7461e10c3870f83558c4b9cc476111d3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Gardou?= Date: Mon, 5 Sep 2011 19:22:44 +0000 Subject: [PATCH 34/55] [MSVCRT] - comment out _vswprintf export until I get more time to fix this properly svn path=/trunk/; revision=53605 --- reactos/dll/win32/msvcrt/msvcrt.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reactos/dll/win32/msvcrt/msvcrt.spec b/reactos/dll/win32/msvcrt/msvcrt.spec index d371cb27b55..3b4a4a937a7 100644 --- a/reactos/dll/win32/msvcrt/msvcrt.spec +++ b/reactos/dll/win32/msvcrt/msvcrt.spec @@ -992,7 +992,7 @@ # stub _vsprintf_p # stub _vsprintf_p_l # stub _vsprintf_s_l -@ cdecl _vswprintf(ptr wstr ptr) +# @ cdecl _vswprintf(ptr wstr ptr) @ cdecl _vswprintf_c(ptr long wstr ptr) _vsnwprintf # @ cdecl _vswprintf_c_l(ptr long wstr ptr ptr) _vsnwprintf_l # @ cdecl _vswprintf_l(ptr wstr ptr ptr) From 4634d67e38bed19355c8f96251a2c978868cbee5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Gardou?= Date: Mon, 5 Sep 2011 19:36:07 +0000 Subject: [PATCH 35/55] [RBUILD] - qmgrprxy.dll has an entrypoint svn path=/trunk/; revision=53606 --- reactos/dll/win32/qmgrprxy/qmgrprxy.rbuild | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reactos/dll/win32/qmgrprxy/qmgrprxy.rbuild b/reactos/dll/win32/qmgrprxy/qmgrprxy.rbuild index cea10b90855..56de3523708 100644 --- a/reactos/dll/win32/qmgrprxy/qmgrprxy.rbuild +++ b/reactos/dll/win32/qmgrprxy/qmgrprxy.rbuild @@ -1,7 +1,7 @@ - + . From e6a91fe96a06d1f361be06fea451f36c661e5bb0 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Mon, 5 Sep 2011 22:18:56 +0000 Subject: [PATCH 36/55] [RTL] Add FPO information to some asm functions svn path=/trunk/; revision=53607 --- reactos/lib/rtl/i386/debug_asm.S | 34 +++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/reactos/lib/rtl/i386/debug_asm.S b/reactos/lib/rtl/i386/debug_asm.S index 39b6fa84236..7849ec7f0c9 100644 --- a/reactos/lib/rtl/i386/debug_asm.S +++ b/reactos/lib/rtl/i386/debug_asm.S @@ -22,24 +22,32 @@ PUBLIC _RtlpBreakWithStatusInstruction@0 .code -_DbgBreakPointNoBugCheck@0: +FUNC DbgBreakPointNoBugCheck@0 + FPO 0, 0, 0, 0, 0, FRAME_FPO int 3 ret +ENDFUNC DbgBreakPointNoBugCheck@0 -_DbgBreakPoint@0: _DbgUserBreakPoint@0: +FUNC DbgBreakPoint@0 + FPO 0, 0, 0, 0, 0, FRAME_FPO int 3 ret +ENDFUNC DbgBreakPoint@0 -_DbgBreakPointWithStatus@4: +FUNC DbgBreakPointWithStatus@4 + FPO 0, 1, 0, 0, 0, FRAME_FPO mov eax, [esp+4] +ENDFUNC DbgBreakPointWithStatus@4 -_RtlpBreakWithStatusInstruction@0: +FUNC RtlpBreakWithStatusInstruction@0 + FPO 0, 0, 0, 0, 0, FRAME_FPO int 3 ret 4 +ENDFUNC RtlpBreakWithStatusInstruction@0 - -_DebugService2@12: +FUNC DebugService2@12 + FPO 0, 3, 3, 0, 1, FRAME_NONFPO /* Setup the stack */ push ebp @@ -55,18 +63,19 @@ _DebugService2@12: /* Restore stack */ pop ebp ret 12 +ENDFUNC DebugService2@12 - -_DebugService@20: +FUNC DebugService@20 + FPO 0, 5, 3, 0, 1, FRAME_NONFPO /* Setup the stack */ push ebp mov ebp, esp - + /* Save the registers */ push ebx push edi - + /* Call the Interrupt */ mov eax, [ebp+8] mov ecx, [ebp+12] @@ -75,13 +84,14 @@ _DebugService@20: mov edi, [ebp+24] int HEX(2D) int 3 - + /* Restore registers */ pop edi pop ebx - + /* Return */ pop ebp ret 20 +ENDFUNC DebugService@20 END From 49149fb1c8d886599196f0b28b6e0c494ccbaa83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Gardou?= Date: Tue, 6 Sep 2011 17:31:25 +0000 Subject: [PATCH 37/55] [CMAKE] - get rid of set_entrypoint usage for "win32" dlls svn path=/trunk/; revision=53608 --- reactos/dll/win32/cfgmgr32/CMakeLists.txt | 2 +- reactos/dll/win32/comcat/CMakeLists.txt | 2 +- reactos/dll/win32/crtdll/CMakeLists.txt | 4 +--- reactos/dll/win32/dnsapi/CMakeLists.txt | 2 +- reactos/dll/win32/fmifs/CMakeLists.txt | 2 +- reactos/dll/win32/glu32/CMakeLists.txt | 2 +- reactos/dll/win32/imaadp32.acm/CMakeLists.txt | 2 +- reactos/dll/win32/lsasrv/CMakeLists.txt | 1 - reactos/dll/win32/lz32/CMakeLists.txt | 2 +- reactos/dll/win32/mcicda/CMakeLists.txt | 2 +- reactos/dll/win32/mlang/CMakeLists.txt | 2 +- reactos/dll/win32/mmdrv/CMakeLists.txt | 1 - reactos/dll/win32/msadp32.acm/CMakeLists.txt | 2 +- reactos/dll/win32/msg711.acm/CMakeLists.txt | 2 +- reactos/dll/win32/msgsm32.acm/CMakeLists.txt | 2 +- reactos/dll/win32/mshtml.tlb/CMakeLists.txt | 2 +- reactos/dll/win32/nddeapi/CMakeLists.txt | 2 +- reactos/dll/win32/ntdsapi/CMakeLists.txt | 2 +- reactos/dll/win32/odbccp32/CMakeLists.txt | 2 +- reactos/dll/win32/olecli32/CMakeLists.txt | 2 +- reactos/dll/win32/olepro32/CMakeLists.txt | 2 +- reactos/dll/win32/olesvr32/CMakeLists.txt | 2 +- reactos/dll/win32/pdh/CMakeLists.txt | 2 +- reactos/dll/win32/printui/CMakeLists.txt | 2 +- reactos/dll/win32/rasapi32/CMakeLists.txt | 2 +- reactos/dll/win32/rsabase/CMakeLists.txt | 2 +- reactos/dll/win32/shdoclc/CMakeLists.txt | 2 +- reactos/dll/win32/shfolder/CMakeLists.txt | 2 +- reactos/dll/win32/smdll/CMakeLists.txt | 2 +- reactos/dll/win32/softpub/CMakeLists.txt | 2 +- reactos/dll/win32/srclient/CMakeLists.txt | 2 +- reactos/dll/win32/stdole2.tlb/CMakeLists.txt | 2 +- reactos/dll/win32/stdole32.tlb/CMakeLists.txt | 2 +- reactos/dll/win32/sxs/CMakeLists.txt | 2 +- reactos/dll/win32/tapi32/CMakeLists.txt | 2 +- reactos/dll/win32/tapiui/CMakeLists.txt | 2 +- reactos/dll/win32/ufatx/CMakeLists.txt | 2 +- reactos/dll/win32/unicows/CMakeLists.txt | 2 +- reactos/dll/win32/updspapi/CMakeLists.txt | 2 +- reactos/dll/win32/version/CMakeLists.txt | 2 +- reactos/dll/win32/winemp3.acm/CMakeLists.txt | 2 +- reactos/dll/win32/winfax/CMakeLists.txt | 2 +- reactos/dll/win32/winmm/midimap/CMakeLists.txt | 2 +- reactos/dll/win32/wlanapi/CMakeLists.txt | 2 +- reactos/dll/win32/wmi/CMakeLists.txt | 2 +- 45 files changed, 43 insertions(+), 47 deletions(-) diff --git a/reactos/dll/win32/cfgmgr32/CMakeLists.txt b/reactos/dll/win32/cfgmgr32/CMakeLists.txt index ad1bdcb7ab1..54cadb935f3 100644 --- a/reactos/dll/win32/cfgmgr32/CMakeLists.txt +++ b/reactos/dll/win32/cfgmgr32/CMakeLists.txt @@ -8,7 +8,7 @@ list(APPEND SOURCE add_library(cfgmgr32 SHARED ${SOURCE}) -set_entrypoint(cfgmgr32 0) +set_module_type(cfgmgr32 win32dll ENTRYPOINT 0 ) add_importlibs(cfgmgr32 setupapi kernel32 ntdll) add_dependencies(cfgmgr32 psdk) add_cd_file(TARGET cfgmgr32 DESTINATION reactos/system32 FOR all) diff --git a/reactos/dll/win32/comcat/CMakeLists.txt b/reactos/dll/win32/comcat/CMakeLists.txt index 29a60062079..765307d6bf1 100644 --- a/reactos/dll/win32/comcat/CMakeLists.txt +++ b/reactos/dll/win32/comcat/CMakeLists.txt @@ -15,7 +15,7 @@ list(APPEND SOURCE add_library(comcat SHARED ${SOURCE}) -set_entrypoint(comcat 0) +set_module_type(comcat win32dll ENTRYPOINT 0 ) target_link_libraries(comcat uuid wine) diff --git a/reactos/dll/win32/crtdll/CMakeLists.txt b/reactos/dll/win32/crtdll/CMakeLists.txt index 942a34a840a..5444d68ae23 100644 --- a/reactos/dll/win32/crtdll/CMakeLists.txt +++ b/reactos/dll/win32/crtdll/CMakeLists.txt @@ -19,9 +19,7 @@ list(APPEND SOURCE add_library(crtdll SHARED ${SOURCE}) -set_module_type(crtdll win32dll) - -set_entrypoint(crtdll DllMain 12) +set_module_type(crtdll win32dll ENTRYPOINT DllMain 12) target_link_libraries(crtdll wine crt) diff --git a/reactos/dll/win32/dnsapi/CMakeLists.txt b/reactos/dll/win32/dnsapi/CMakeLists.txt index da10aab172c..5e89d65dc2f 100644 --- a/reactos/dll/win32/dnsapi/CMakeLists.txt +++ b/reactos/dll/win32/dnsapi/CMakeLists.txt @@ -21,7 +21,7 @@ list(APPEND SOURCE add_library(dnsapi SHARED ${SOURCE}) -set_entrypoint(dnsapi 0) +set_module_type(dnsapi win32dll ENTRYPOINT 0 ) target_link_libraries(dnsapi adns) add_importlibs(dnsapi user32 ws2_32 iphlpapi msvcrt kernel32 ntdll) add_pch(dnsapi dnsapi/precomp.h) diff --git a/reactos/dll/win32/fmifs/CMakeLists.txt b/reactos/dll/win32/fmifs/CMakeLists.txt index 469391c2d98..9f86250cc3e 100644 --- a/reactos/dll/win32/fmifs/CMakeLists.txt +++ b/reactos/dll/win32/fmifs/CMakeLists.txt @@ -15,7 +15,7 @@ list(APPEND SOURCE ${CMAKE_CURRENT_BINARY_DIR}/fmifs.def) add_library(fmifs SHARED ${SOURCE}) -set_entrypoint(fmifs InitializeFmIfs 12) +set_module_type(fmifs win32dll ENTRYPOINT InitializeFmIfs 12) add_importlibs(fmifs kernel32 ntdll) add_pch(fmifs precomp.h) add_dependencies(fmifs psdk) diff --git a/reactos/dll/win32/glu32/CMakeLists.txt b/reactos/dll/win32/glu32/CMakeLists.txt index 24f98502940..0a7077b6ddc 100644 --- a/reactos/dll/win32/glu32/CMakeLists.txt +++ b/reactos/dll/win32/glu32/CMakeLists.txt @@ -108,7 +108,7 @@ list(APPEND SOURCE add_library(glu32 SHARED ${SOURCE}) -set_entrypoint(glu32 0) +set_module_type(glu32 win32dll ENTRYPOINT 0 ) if(NOT MSVC) target_link_libraries(glu32 stlport -lsupc++ -lgcc -lmingw32 oldnames) diff --git a/reactos/dll/win32/imaadp32.acm/CMakeLists.txt b/reactos/dll/win32/imaadp32.acm/CMakeLists.txt index 772071b846b..030eeaddee2 100644 --- a/reactos/dll/win32/imaadp32.acm/CMakeLists.txt +++ b/reactos/dll/win32/imaadp32.acm/CMakeLists.txt @@ -10,7 +10,7 @@ list(APPEND SOURCE add_library(imaadp32.acm SHARED ${SOURCE}) -set_entrypoint(imaadp32.acm 0) +set_module_type(imaadp32.acm win32dll ENTRYPOINT 0 ) set_target_properties(imaadp32.acm PROPERTIES SUFFIX "") target_link_libraries(imaadp32.acm wine) add_importlibs(imaadp32.acm winmm user32 msvcrt kernel32 ntdll) diff --git a/reactos/dll/win32/lsasrv/CMakeLists.txt b/reactos/dll/win32/lsasrv/CMakeLists.txt index 28a53b731fe..8e98f23e592 100644 --- a/reactos/dll/win32/lsasrv/CMakeLists.txt +++ b/reactos/dll/win32/lsasrv/CMakeLists.txt @@ -24,7 +24,6 @@ list(APPEND SOURCE add_library(lsasrv SHARED ${SOURCE}) set_module_type(lsasrv win32dll ENTRYPOINT 0 UNICODE) -set_entrypoint(lsasrv 0) target_link_libraries(lsasrv wine ${PSEH_LIB}) add_importlibs(lsasrv rpcrt4 msvcrt kernel32 ntdll) add_pch(lsasrv lsasrv.h) diff --git a/reactos/dll/win32/lz32/CMakeLists.txt b/reactos/dll/win32/lz32/CMakeLists.txt index a120899e5d2..efa2369a102 100644 --- a/reactos/dll/win32/lz32/CMakeLists.txt +++ b/reactos/dll/win32/lz32/CMakeLists.txt @@ -10,7 +10,7 @@ list(APPEND SOURCE add_library(lz32 SHARED ${SOURCE}) -set_entrypoint(lz32 0) +set_module_type(lz32 win32dll ENTRYPOINT 0 ) target_link_libraries(lz32 wine) add_importlibs(lz32 kernel32 ntdll) diff --git a/reactos/dll/win32/mcicda/CMakeLists.txt b/reactos/dll/win32/mcicda/CMakeLists.txt index 3c01576d126..d94e9013766 100644 --- a/reactos/dll/win32/mcicda/CMakeLists.txt +++ b/reactos/dll/win32/mcicda/CMakeLists.txt @@ -10,7 +10,7 @@ list(APPEND SOURCE add_library(mcicda SHARED ${SOURCE}) -set_entrypoint(mcicda 0) +set_module_type(mcicda win32dll ENTRYPOINT 0 ) target_link_libraries(mcicda wine) add_importlibs(mcicda winmm user32 kernel32 ntdll) add_dependencies(mcicda psdk) diff --git a/reactos/dll/win32/mlang/CMakeLists.txt b/reactos/dll/win32/mlang/CMakeLists.txt index cdf641dae56..ba1a39846fb 100644 --- a/reactos/dll/win32/mlang/CMakeLists.txt +++ b/reactos/dll/win32/mlang/CMakeLists.txt @@ -15,7 +15,7 @@ list(APPEND SOURCE ${CMAKE_CURRENT_BINARY_DIR}/mlang.def) add_library(mlang SHARED ${SOURCE}) -set_entrypoint(mlang 0) +set_module_type(mlang win32dll ENTRYPOINT 0 ) target_link_libraries(mlang uuid wine) add_delay_importlibs(mlang oleaut32) diff --git a/reactos/dll/win32/mmdrv/CMakeLists.txt b/reactos/dll/win32/mmdrv/CMakeLists.txt index 8a906b4a400..cffd8b46795 100644 --- a/reactos/dll/win32/mmdrv/CMakeLists.txt +++ b/reactos/dll/win32/mmdrv/CMakeLists.txt @@ -17,7 +17,6 @@ list(APPEND SOURCE add_library(mmdrv SHARED ${SOURCE}) set_module_type(mmdrv win32dll ENTRYPOINT 0 UNICODE) -set_entrypoint(mmdrv 0) add_importlibs(mmdrv winmm user32 kernel32 ntdll) add_dependencies(mmdrv psdk) add_cd_file(TARGET mmdrv DESTINATION reactos/system32 FOR all) diff --git a/reactos/dll/win32/msadp32.acm/CMakeLists.txt b/reactos/dll/win32/msadp32.acm/CMakeLists.txt index 6a2f55874c3..9e8bcfe9135 100644 --- a/reactos/dll/win32/msadp32.acm/CMakeLists.txt +++ b/reactos/dll/win32/msadp32.acm/CMakeLists.txt @@ -10,7 +10,7 @@ list(APPEND SOURCE add_library(msadp32.acm SHARED ${SOURCE}) -set_entrypoint(msadp32.acm 0) +set_module_type(msadp32.acm win32dll ENTRYPOINT 0 ) set_target_properties(msadp32.acm PROPERTIES SUFFIX "") target_link_libraries(msadp32.acm wine) add_importlibs(msadp32.acm winmm user32 msvcrt kernel32 ntdll) diff --git a/reactos/dll/win32/msg711.acm/CMakeLists.txt b/reactos/dll/win32/msg711.acm/CMakeLists.txt index 4ffcd516a7c..47cd1366a8b 100644 --- a/reactos/dll/win32/msg711.acm/CMakeLists.txt +++ b/reactos/dll/win32/msg711.acm/CMakeLists.txt @@ -10,7 +10,7 @@ list(APPEND SOURCE add_library(msg711.acm SHARED ${SOURCE}) -set_entrypoint(msg711.acm 0) +set_module_type(msg711.acm win32dll ENTRYPOINT 0 ) set_target_properties(msg711.acm PROPERTIES SUFFIX "") target_link_libraries(msg711.acm wine) add_importlibs(msg711.acm winmm user32 msvcrt kernel32 ntdll) diff --git a/reactos/dll/win32/msgsm32.acm/CMakeLists.txt b/reactos/dll/win32/msgsm32.acm/CMakeLists.txt index d5fadf4b1c2..aecf1e1d880 100644 --- a/reactos/dll/win32/msgsm32.acm/CMakeLists.txt +++ b/reactos/dll/win32/msgsm32.acm/CMakeLists.txt @@ -10,7 +10,7 @@ list(APPEND SOURCE add_library(msgsm32.acm SHARED ${SOURCE}) -set_entrypoint(msgsm32.acm 0) +set_module_type(msgsm32.acm win32dll ENTRYPOINT 0 ) set_target_properties(msgsm32.acm PROPERTIES SUFFIX "") target_link_libraries(msgsm32.acm wine) add_importlibs(msgsm32.acm winmm user32 msvcrt kernel32 ntdll) diff --git a/reactos/dll/win32/mshtml.tlb/CMakeLists.txt b/reactos/dll/win32/mshtml.tlb/CMakeLists.txt index 01e7364085c..f3bd5ee5302 100644 --- a/reactos/dll/win32/mshtml.tlb/CMakeLists.txt +++ b/reactos/dll/win32/mshtml.tlb/CMakeLists.txt @@ -8,7 +8,7 @@ include_directories(${REACTOS_SOURCE_DIR}/include/reactos/wine) add_library(mshtml.tlb SHARED rsrc.rc) -set_entrypoint(mshtml.tlb 0) +set_module_type(mshtml.tlb win32dll ENTRYPOINT 0 ) set_target_properties(mshtml.tlb PROPERTIES SUFFIX "") add_dependencies(mshtml.tlb mshtml__tlb) add_cd_file(TARGET mshtml.tlb DESTINATION reactos/system32 FOR all) diff --git a/reactos/dll/win32/nddeapi/CMakeLists.txt b/reactos/dll/win32/nddeapi/CMakeLists.txt index a085f6bf6d0..b62840a2b83 100644 --- a/reactos/dll/win32/nddeapi/CMakeLists.txt +++ b/reactos/dll/win32/nddeapi/CMakeLists.txt @@ -10,7 +10,7 @@ list(APPEND SOURCE ${CMAKE_CURRENT_BINARY_DIR}/nddeapi.def) add_library(nddeapi SHARED ${SOURCE}) -set_entrypoint(nddeapi 0) +set_module_type(nddeapi win32dll ENTRYPOINT 0 ) target_link_libraries(nddeapi wine) diff --git a/reactos/dll/win32/ntdsapi/CMakeLists.txt b/reactos/dll/win32/ntdsapi/CMakeLists.txt index 60f13dbc4d2..924821967f6 100644 --- a/reactos/dll/win32/ntdsapi/CMakeLists.txt +++ b/reactos/dll/win32/ntdsapi/CMakeLists.txt @@ -10,7 +10,7 @@ list(APPEND SOURCE ${CMAKE_CURRENT_BINARY_DIR}/ntdsapi.def) add_library(ntdsapi SHARED ${SOURCE}) -set_entrypoint(ntdsapi 0) +set_module_type(ntdsapi win32dll ENTRYPOINT 0 ) target_link_libraries(ntdsapi wine) diff --git a/reactos/dll/win32/odbccp32/CMakeLists.txt b/reactos/dll/win32/odbccp32/CMakeLists.txt index 16e60613f59..054991cfe63 100644 --- a/reactos/dll/win32/odbccp32/CMakeLists.txt +++ b/reactos/dll/win32/odbccp32/CMakeLists.txt @@ -11,7 +11,7 @@ list(APPEND SOURCE add_library(odbccp32 SHARED ${SOURCE}) -set_entrypoint(odbccp32 0) +set_module_type(odbccp32 win32dll ENTRYPOINT 0 ) target_link_libraries(odbccp32 uuid wine) add_importlibs(odbccp32 diff --git a/reactos/dll/win32/olecli32/CMakeLists.txt b/reactos/dll/win32/olecli32/CMakeLists.txt index fa9032389e3..468a80accb4 100644 --- a/reactos/dll/win32/olecli32/CMakeLists.txt +++ b/reactos/dll/win32/olecli32/CMakeLists.txt @@ -11,7 +11,7 @@ list(APPEND SOURCE ${CMAKE_CURRENT_BINARY_DIR}/olecli32.def) add_library(olecli32 SHARED ${SOURCE}) -set_entrypoint(olecli32 0) +set_module_type(olecli32 win32dll ENTRYPOINT 0 ) target_link_libraries(olecli32 wine) diff --git a/reactos/dll/win32/olepro32/CMakeLists.txt b/reactos/dll/win32/olepro32/CMakeLists.txt index 3dda022eeb3..4c83b168938 100644 --- a/reactos/dll/win32/olepro32/CMakeLists.txt +++ b/reactos/dll/win32/olepro32/CMakeLists.txt @@ -11,7 +11,7 @@ list(APPEND SOURCE add_library(olepro32 SHARED ${SOURCE}) -set_entrypoint(olepro32 0) +set_module_type(olepro32 win32dll ENTRYPOINT 0 ) target_link_libraries(olepro32 wine) diff --git a/reactos/dll/win32/olesvr32/CMakeLists.txt b/reactos/dll/win32/olesvr32/CMakeLists.txt index dbfc68a3ef4..3521cb66ff2 100644 --- a/reactos/dll/win32/olesvr32/CMakeLists.txt +++ b/reactos/dll/win32/olesvr32/CMakeLists.txt @@ -11,7 +11,7 @@ list(APPEND SOURCE add_library(olesvr32 SHARED ${SOURCE}) -set_entrypoint(olesvr32 0) +set_module_type(olesvr32 win32dll ENTRYPOINT 0 ) target_link_libraries(olesvr32 wine) diff --git a/reactos/dll/win32/pdh/CMakeLists.txt b/reactos/dll/win32/pdh/CMakeLists.txt index 6a814245ccb..edd3534c193 100644 --- a/reactos/dll/win32/pdh/CMakeLists.txt +++ b/reactos/dll/win32/pdh/CMakeLists.txt @@ -14,7 +14,7 @@ list(APPEND SOURCE ${CMAKE_CURRENT_BINARY_DIR}/pdh.def) add_library(pdh SHARED ${SOURCE}) -set_entrypoint(pdh 0) +set_module_type(pdh win32dll ENTRYPOINT 0 ) target_link_libraries(pdh wine) diff --git a/reactos/dll/win32/printui/CMakeLists.txt b/reactos/dll/win32/printui/CMakeLists.txt index 72777f17c6d..34151efc37a 100644 --- a/reactos/dll/win32/printui/CMakeLists.txt +++ b/reactos/dll/win32/printui/CMakeLists.txt @@ -12,7 +12,7 @@ list(APPEND SOURCE ${CMAKE_CURRENT_BINARY_DIR}/printui.def) add_library(printui SHARED ${SOURCE}) -set_entrypoint(printui 0) +set_module_type(printui win32dll ENTRYPOINT 0 ) target_link_libraries(printui wine) diff --git a/reactos/dll/win32/rasapi32/CMakeLists.txt b/reactos/dll/win32/rasapi32/CMakeLists.txt index f3d3728b568..a3954286467 100644 --- a/reactos/dll/win32/rasapi32/CMakeLists.txt +++ b/reactos/dll/win32/rasapi32/CMakeLists.txt @@ -11,7 +11,7 @@ list(APPEND SOURCE ${CMAKE_CURRENT_BINARY_DIR}/rasapi32.def) add_library(rasapi32 SHARED ${SOURCE}) -set_entrypoint(rasapi32 0) +set_module_type(rasapi32 win32dll ENTRYPOINT 0 ) target_link_libraries(rasapi32 wine) diff --git a/reactos/dll/win32/rsabase/CMakeLists.txt b/reactos/dll/win32/rsabase/CMakeLists.txt index d9060f0e99d..644eae6c3bd 100644 --- a/reactos/dll/win32/rsabase/CMakeLists.txt +++ b/reactos/dll/win32/rsabase/CMakeLists.txt @@ -10,7 +10,7 @@ list(APPEND SOURCE add_library(rsabase SHARED ${SOURCE}) -set_entrypoint(rsabase 0) +set_module_type(rsabase win32dll ENTRYPOINT 0 ) target_link_libraries(rsabase wine) add_importlibs(rsabase rsaenh ntdll) add_cd_file(TARGET rsabase DESTINATION reactos/system32 FOR all) diff --git a/reactos/dll/win32/shdoclc/CMakeLists.txt b/reactos/dll/win32/shdoclc/CMakeLists.txt index fe4dcba4daf..843c88a3916 100644 --- a/reactos/dll/win32/shdoclc/CMakeLists.txt +++ b/reactos/dll/win32/shdoclc/CMakeLists.txt @@ -7,7 +7,7 @@ spec2def(shdoclc.dll shdoclc.spec) add_library(shdoclc SHARED rsrc.rc ${CMAKE_CURRENT_BINARY_DIR}/shdoclc.def) -set_entrypoint(shdoclc 0) +set_module_type(shdoclc win32dll ENTRYPOINT 0 ) target_link_libraries(shdoclc wine) diff --git a/reactos/dll/win32/shfolder/CMakeLists.txt b/reactos/dll/win32/shfolder/CMakeLists.txt index 92b32eb30ec..e973f7cae9f 100644 --- a/reactos/dll/win32/shfolder/CMakeLists.txt +++ b/reactos/dll/win32/shfolder/CMakeLists.txt @@ -10,7 +10,7 @@ list(APPEND SOURCE add_library(shfolder SHARED ${SOURCE}) -set_entrypoint(shfolder 0) +set_module_type(shfolder win32dll ENTRYPOINT 0 ) target_link_libraries(shfolder wine) add_importlibs(shfolder shell32 kernel32 ntdll) diff --git a/reactos/dll/win32/smdll/CMakeLists.txt b/reactos/dll/win32/smdll/CMakeLists.txt index 6a8026f1fc5..e12d8a4ea63 100644 --- a/reactos/dll/win32/smdll/CMakeLists.txt +++ b/reactos/dll/win32/smdll/CMakeLists.txt @@ -12,7 +12,7 @@ list(APPEND SOURCE add_library(smdll SHARED ${SOURCE}) target_link_libraries(smdll smlib) -set_entrypoint(smdll DllMainCRTStartup 12) +set_module_type(smdll nativedll ENTRYPOINT DllMainCRTStartup 12) add_importlibs(smdll ntdll) add_pch(smdll precomp.h) add_dependencies(smdll psdk) diff --git a/reactos/dll/win32/softpub/CMakeLists.txt b/reactos/dll/win32/softpub/CMakeLists.txt index a4fb73cfbea..72bcd45dbe2 100644 --- a/reactos/dll/win32/softpub/CMakeLists.txt +++ b/reactos/dll/win32/softpub/CMakeLists.txt @@ -7,7 +7,7 @@ spec2def(softpub.dll softpub.spec) add_library(softpub SHARED softpub.rc ${CMAKE_CURRENT_BINARY_DIR}/softpub.def) -set_entrypoint(softpub 0) +set_module_type(softpub win32dll ENTRYPOINT 0 ) target_link_libraries(softpub wine) diff --git a/reactos/dll/win32/srclient/CMakeLists.txt b/reactos/dll/win32/srclient/CMakeLists.txt index e6088bb1453..995f2b395ca 100644 --- a/reactos/dll/win32/srclient/CMakeLists.txt +++ b/reactos/dll/win32/srclient/CMakeLists.txt @@ -7,7 +7,7 @@ list(APPEND SOURCE ${CMAKE_CURRENT_BINARY_DIR}/srclient.def) add_library(srclient SHARED ${SOURCE}) -set_entrypoint(srclient 0) +set_module_type(srclient win32dll ENTRYPOINT 0 ) add_importlibs(srclient kernel32 ntdll) add_dependencies(srclient psdk) diff --git a/reactos/dll/win32/stdole2.tlb/CMakeLists.txt b/reactos/dll/win32/stdole2.tlb/CMakeLists.txt index 16b15175704..75ac0e19f09 100644 --- a/reactos/dll/win32/stdole2.tlb/CMakeLists.txt +++ b/reactos/dll/win32/stdole2.tlb/CMakeLists.txt @@ -12,7 +12,7 @@ list(APPEND SOURCE add_library(stdole2.tlb SHARED ${SOURCE}) -set_entrypoint(stdole2.tlb 0) +set_module_type(stdole2.tlb win32dll ENTRYPOINT 0 ) set_target_properties(stdole2.tlb PROPERTIES SUFFIX "") add_dependencies(stdole2.tlb std_ole_v2) add_cd_file(TARGET stdole2.tlb DESTINATION reactos/system32 FOR all) diff --git a/reactos/dll/win32/stdole32.tlb/CMakeLists.txt b/reactos/dll/win32/stdole32.tlb/CMakeLists.txt index b563d273fc5..b4d1fbe9197 100644 --- a/reactos/dll/win32/stdole32.tlb/CMakeLists.txt +++ b/reactos/dll/win32/stdole32.tlb/CMakeLists.txt @@ -12,7 +12,7 @@ list(APPEND SOURCE add_library(stdole32.tlb SHARED ${SOURCE}) -set_entrypoint(stdole32.tlb 0) +set_module_type(stdole32.tlb win32dll ENTRYPOINT 0 ) set_target_properties(stdole32.tlb PROPERTIES SUFFIX "") add_dependencies(stdole32.tlb std_ole_v1) diff --git a/reactos/dll/win32/sxs/CMakeLists.txt b/reactos/dll/win32/sxs/CMakeLists.txt index 74e5742fe6e..4e23ad77755 100644 --- a/reactos/dll/win32/sxs/CMakeLists.txt +++ b/reactos/dll/win32/sxs/CMakeLists.txt @@ -10,7 +10,7 @@ list(APPEND SOURCE ${CMAKE_CURRENT_BINARY_DIR}/sxs.def) add_library(sxs SHARED ${SOURCE}) -set_entrypoint(sxs 0) +set_module_type(sxs win32dll ENTRYPOINT 0 ) target_link_libraries(sxs wine) diff --git a/reactos/dll/win32/tapi32/CMakeLists.txt b/reactos/dll/win32/tapi32/CMakeLists.txt index 41017c22ee5..c896e373add 100644 --- a/reactos/dll/win32/tapi32/CMakeLists.txt +++ b/reactos/dll/win32/tapi32/CMakeLists.txt @@ -14,7 +14,7 @@ list(APPEND SOURCE add_library(tapi32 SHARED ${SOURCE}) -set_entrypoint(tapi32 0) +set_module_type(tapi32 win32dll ENTRYPOINT 0 ) target_link_libraries(tapi32 wine) diff --git a/reactos/dll/win32/tapiui/CMakeLists.txt b/reactos/dll/win32/tapiui/CMakeLists.txt index a9bb4f5d442..b75dd8de35f 100644 --- a/reactos/dll/win32/tapiui/CMakeLists.txt +++ b/reactos/dll/win32/tapiui/CMakeLists.txt @@ -2,6 +2,6 @@ set_rc_compiler() add_library(tapiui SHARED tapiui.rc) -set_entrypoint(tapiui 0) +set_module_type(tapiui win32dll ENTRYPOINT 0 ) add_dependencies(tapiui psdk) add_cd_file(TARGET tapiui DESTINATION reactos/system32 FOR all) diff --git a/reactos/dll/win32/ufatx/CMakeLists.txt b/reactos/dll/win32/ufatx/CMakeLists.txt index 1c8704e7551..8304306bbce 100644 --- a/reactos/dll/win32/ufatx/CMakeLists.txt +++ b/reactos/dll/win32/ufatx/CMakeLists.txt @@ -7,7 +7,7 @@ list(APPEND SOURCE add_library(ufatx SHARED ${SOURCE}) -set_entrypoint(ufatx 0) +set_module_type(ufatx win32dll ENTRYPOINT 0 ) target_link_libraries(ufatx vfatxlib) add_importlibs(ufatx ntdll) diff --git a/reactos/dll/win32/unicows/CMakeLists.txt b/reactos/dll/win32/unicows/CMakeLists.txt index a8ef2fab00e..2c5e7d2aa59 100644 --- a/reactos/dll/win32/unicows/CMakeLists.txt +++ b/reactos/dll/win32/unicows/CMakeLists.txt @@ -7,7 +7,7 @@ list(APPEND SOURCE add_library(unicows SHARED ${SOURCE}) -set_entrypoint(unicows 0) +set_module_type(unicows win32dll ENTRYPOINT 0 ) add_importlibs(unicows avicap32 diff --git a/reactos/dll/win32/updspapi/CMakeLists.txt b/reactos/dll/win32/updspapi/CMakeLists.txt index 456ccde58f2..b68662925e0 100644 --- a/reactos/dll/win32/updspapi/CMakeLists.txt +++ b/reactos/dll/win32/updspapi/CMakeLists.txt @@ -10,7 +10,7 @@ list(APPEND SOURCE ${CMAKE_CURRENT_BINARY_DIR}/updspapi.def) add_library(updspapi SHARED ${SOURCE}) -set_entrypoint(updspapi 0) +set_module_type(updspapi win32dll ENTRYPOINT 0 ) target_link_libraries(updspapi wine) diff --git a/reactos/dll/win32/version/CMakeLists.txt b/reactos/dll/win32/version/CMakeLists.txt index beaf8ba13cc..faf0680239c 100644 --- a/reactos/dll/win32/version/CMakeLists.txt +++ b/reactos/dll/win32/version/CMakeLists.txt @@ -13,7 +13,7 @@ list(APPEND SOURCE add_library(version SHARED ${SOURCE}) -set_entrypoint(version 0) +set_module_type(version win32dll ENTRYPOINT 0 ) target_link_libraries(version wine) add_importlibs(version lz32 kernel32 ntdll) diff --git a/reactos/dll/win32/winemp3.acm/CMakeLists.txt b/reactos/dll/win32/winemp3.acm/CMakeLists.txt index a7f7e01edf3..cd00d82218d 100644 --- a/reactos/dll/win32/winemp3.acm/CMakeLists.txt +++ b/reactos/dll/win32/winemp3.acm/CMakeLists.txt @@ -13,7 +13,7 @@ add_library(winemp3.acm SHARED mpegl3.c ${CMAKE_CURRENT_BINARY_DIR}/winemp3.def) -set_entrypoint(winemp3.acm 0) +set_module_type(winemp3.acm win32dll ENTRYPOINT 0 ) set_target_properties(winemp3.acm PROPERTIES SUFFIX "") target_link_libraries(winemp3.acm wine libmpg123 oldnames) diff --git a/reactos/dll/win32/winfax/CMakeLists.txt b/reactos/dll/win32/winfax/CMakeLists.txt index ced03a8fb41..5c001863c26 100644 --- a/reactos/dll/win32/winfax/CMakeLists.txt +++ b/reactos/dll/win32/winfax/CMakeLists.txt @@ -8,7 +8,7 @@ list(APPEND SOURCE add_library(winfax SHARED ${SOURCE}) -set_entrypoint(winfax 0) +set_module_type(winfax win32dll ENTRYPOINT 0 ) add_importlibs(winfax kernel32 ntdll) add_dependencies(winfax psdk) diff --git a/reactos/dll/win32/winmm/midimap/CMakeLists.txt b/reactos/dll/win32/winmm/midimap/CMakeLists.txt index 701c69e735f..0e31cdd4887 100644 --- a/reactos/dll/win32/winmm/midimap/CMakeLists.txt +++ b/reactos/dll/win32/winmm/midimap/CMakeLists.txt @@ -8,7 +8,7 @@ add_library(midimap SHARED midimap.rc ${CMAKE_CURRENT_BINARY_DIR}/midimap.def) -set_entrypoint(midimap 0) +set_module_type(midimap win32dll ENTRYPOINT 0 ) target_link_libraries(midimap uuid wine) diff --git a/reactos/dll/win32/wlanapi/CMakeLists.txt b/reactos/dll/win32/wlanapi/CMakeLists.txt index 5c040013b8a..1f87bd30765 100644 --- a/reactos/dll/win32/wlanapi/CMakeLists.txt +++ b/reactos/dll/win32/wlanapi/CMakeLists.txt @@ -13,7 +13,7 @@ list(APPEND SOURCE add_library(wlanapi SHARED ${SOURCE}) -set_entrypoint(wlanapi 0) +set_module_type(wlanapi win32dll ENTRYPOINT 0 ) target_link_libraries(wlanapi wine diff --git a/reactos/dll/win32/wmi/CMakeLists.txt b/reactos/dll/win32/wmi/CMakeLists.txt index d80d3eedc3b..7d37a29e7c3 100644 --- a/reactos/dll/win32/wmi/CMakeLists.txt +++ b/reactos/dll/win32/wmi/CMakeLists.txt @@ -7,7 +7,7 @@ list(APPEND SOURCE add_library(wmi SHARED ${SOURCE}) -set_entrypoint(wmi 0) +set_module_type(wmi win32dll ENTRYPOINT 0 ) add_importlibs(wmi advapi32) add_dependencies(wmi psdk) From 2020d7c71f6f9030fbb75586a34231872ae57575 Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Tue, 6 Sep 2011 19:17:54 +0000 Subject: [PATCH 38/55] [MUP] - Any attempt to open or create a file on a remote machine will return STATUS_BAD_NETWORK_PATH. This means the server is not available. Trying to create \\testserver\testshare\testdir\test.txt fails just like on Windows XP. - Add service key and values for the MUP driver. Add the driver to the File System group because adding it to the Network group, like on Windows XP, does not load the driver. svn path=/trunk/; revision=53609 --- reactos/boot/bootdata/hivesys_i386.inf | 11 ++++++++++- reactos/drivers/filesystems/mup/create.c | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/reactos/boot/bootdata/hivesys_i386.inf b/reactos/boot/bootdata/hivesys_i386.inf index 3132ba68a6e..95d7a1561ec 100644 --- a/reactos/boot/bootdata/hivesys_i386.inf +++ b/reactos/boot/bootdata/hivesys_i386.inf @@ -1349,6 +1349,15 @@ HKLM,"SYSTEM\CurrentControlSet\Services\Msfs","ImagePath",0x00020000,"system32\d HKLM,"SYSTEM\CurrentControlSet\Services\Msfs","Start",0x00010001,0x00000001 HKLM,"SYSTEM\CurrentControlSet\Services\Msfs","Type",0x00010001,0x00000002 +; Multiple UNC provider driver +HKLM,"SYSTEM\CurrentControlSet\Services\Mup","Description",0x00000000,"Multiple UNC Provider (MUP)" +HKLM,"SYSTEM\CurrentControlSet\Services\Mup","ErrorControl",0x00010001,0x00000001 +;HKLM,"SYSTEM\CurrentControlSet\Services\Mup","Group",0x00000000,"Network" +HKLM,"SYSTEM\CurrentControlSet\Services\Mup","Group",0x00000000,"File System" +HKLM,"SYSTEM\CurrentControlSet\Services\Mup","ImagePath",0x00020000,"system32\drivers\mup.sys" +HKLM,"SYSTEM\CurrentControlSet\Services\Mup","Start",0x00010001,0x00000000 +HKLM,"SYSTEM\CurrentControlSet\Services\Mup","Type",0x00010001,0x00000002 + ; NDIS driver - the only boot-start network driver HKLM,"SYSTEM\CurrentControlSet\Services\Ndis","ErrorControl",0x00010001,0x00000001 HKLM,"SYSTEM\CurrentControlSet\Services\Ndis","Group",0x00000000,"NDIS" @@ -1747,6 +1756,6 @@ HKLM,"SYSTEM\Setup","SystemPartition",0x00000000,"\Device\Harddisk0\Partition1" HKLM,"SYSTEM\Setup","SystemSetupInProgress",0x00010001,0x00000001 ; Debug channels -;HKLM,"SYSTEM\CurrentControlSet\Control\Session Manager\Environment","DEBUGCHANNEL",0x00020000,"+ole,+rpc" +;HKLM,"SYSTEM\CurrentControlSet\Control\Session Manager\Environment","DEBUGCHANNEL",0x00020000,"+advapi,+testsvc,+wkssvc" ; EOF diff --git a/reactos/drivers/filesystems/mup/create.c b/reactos/drivers/filesystems/mup/create.c index 127a0756e5c..ed35368dd64 100644 --- a/reactos/drivers/filesystems/mup/create.c +++ b/reactos/drivers/filesystems/mup/create.c @@ -54,7 +54,7 @@ MupCreate(PDEVICE_OBJECT DeviceObject, DPRINT("FileName: '%wZ'\n", &FileObject->FileName); - Status = STATUS_ACCESS_DENIED; + Status = STATUS_BAD_NETWORK_PATH; Irp->IoStatus.Information = (NT_SUCCESS(Status)) ? FILE_OPENED : 0; Irp->IoStatus.Status = Status; From b5198d7d39a47f10ecf80e154c77082c25a5d2f2 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Tue, 6 Sep 2011 21:01:49 +0000 Subject: [PATCH 39/55] [HAL] Start implementing APIC support, which is needed for both SMP and x64. It will use the local APIC + I/O APIC for interrupt control, the RTC instead of the PIT for the timer interrupt (PIT doesn't always work with I/O APIC), the APIC timer for profiling and finally the TSC for the performance counter and KeStallExecutionProcessor. The code is incomplete and doesn't work yet svn path=/trunk/; revision=53611 --- reactos/hal/halx86/apic/apic.c | 693 ++++++++++++++++++++++++++++ reactos/hal/halx86/apic/apic.h | 271 +++++++++++ reactos/hal/halx86/apic/apictimer.c | 84 ++++ reactos/hal/halx86/apic/apictrap.S | 36 ++ reactos/hal/halx86/apic/rtctimer.c | 144 ++++++ reactos/hal/halx86/apic/tsc.c | 140 ++++++ reactos/hal/halx86/apic/tsc.h | 15 + reactos/hal/halx86/apic/tsccal.S | 39 ++ 8 files changed, 1422 insertions(+) create mode 100644 reactos/hal/halx86/apic/apic.c create mode 100644 reactos/hal/halx86/apic/apic.h create mode 100644 reactos/hal/halx86/apic/apictimer.c create mode 100644 reactos/hal/halx86/apic/apictrap.S create mode 100644 reactos/hal/halx86/apic/rtctimer.c create mode 100644 reactos/hal/halx86/apic/tsc.c create mode 100644 reactos/hal/halx86/apic/tsc.h create mode 100644 reactos/hal/halx86/apic/tsccal.S diff --git a/reactos/hal/halx86/apic/apic.c b/reactos/hal/halx86/apic/apic.c new file mode 100644 index 00000000000..7837a35c10d --- /dev/null +++ b/reactos/hal/halx86/apic/apic.c @@ -0,0 +1,693 @@ +/* + * PROJECT: ReactOS HAL + * LICENSE: GNU GPL - See COPYING in the top level directory + * FILE: hal/halx86/generic/apic.c + * PURPOSE: HAL APIC Management and Control Code + * PROGRAMMERS: Timo Kreuzer (timo.kreuzer@reactos.org) + * REFERENCES: http://www.joseflores.com/docs/ExploringIrql.html + * http://www.codeproject.com/KB/system/soviet_kernel_hack.aspx + * http://bbs.unixmap.net/thread-2022-1-1.html + */ + +/* INCLUDES *******************************************************************/ + +#include +#define NDEBUG +#include + +#include "apic.h" + +/* GLOBALS ********************************************************************/ + +UCHAR HalpVectorToIndex[256]; + +#ifndef _M_AMD64 +static const UCHAR +HalpIRQLtoTPR[32] = +{ + 0x00, /* 0 PASSIVE_LEVEL */ + 0x3d, /* 1 APC_LEVEL */ + 0x41, /* 2 DISPATCH_LEVEL */ + 0x41, /* 3 \ */ + 0x51, /* 4 \ */ + 0x61, /* 5 | */ + 0x71, /* 6 | */ + 0x81, /* 7 | */ + 0x91, /* 8 | */ + 0xa1, /* 9 | */ + 0xb1, /* 10 | */ + 0xb1, /* 11 | */ + 0xb1, /* 12 | */ + 0xb1, /* 13 | */ + 0xb1, /* 14 | */ + 0xb1, /* 15 DEVICE IRQL */ + 0xb1, /* 16 | */ + 0xb1, /* 17 | */ + 0xb1, /* 18 | */ + 0xb1, /* 19 | */ + 0xb1, /* 20 | */ + 0xb1, /* 21 | */ + 0xb1, /* 22 | */ + 0xb1, /* 23 | */ + 0xb1, /* 24 | */ + 0xb1, /* 25 / */ + 0xb1, /* 26 / */ + 0xc1, /* 27 PROFILE_LEVEL */ + 0xd1, /* 28 CLOCK2_LEVEL */ + 0xe1, /* 29 IPI_LEVEL */ + 0xef, /* 30 POWER_LEVEL */ + 0xff, /* 31 HIGH_LEVEL */ +}; + +static const KIRQL +HalVectorToIRQL[16] = +{ + 0, /* 00 PASSIVE_LEVEL */ + 0xff, /* 10 */ + 0xff, /* 20 */ + 1, /* 3D APC_LEVEL */ + 2, /* 41 DISPATCH_LEVEL */ + 4, /* 50 \ */ + 5, /* 60 \ */ + 6, /* 70 | */ + 7, /* 80 DEVICE IRQL */ + 8, /* 90 | */ + 9, /* A0 / */ + 10, /* B0 / */ + 27, /* C1 PROFILE_LEVEL */ + 28, /* D1 CLOCK2_LEVEL */ + 29, /* E1 IPI_LEVEL / EF POWER_LEVEL */ + 31, /* FF HIGH_LEVEL */ +}; +#endif + +/* PRIVATE FUNCTIONS **********************************************************/ + +ULONG +FORCEINLINE +IOApicRead(UCHAR Register) +{ + /* Select the register, then do the read */ + *(volatile ULONG *)(IOAPIC_BASE + IOAPIC_IOREGSEL) = Register; + return *(volatile ULONG *)(IOAPIC_BASE + IOAPIC_IOWIN); +} + +VOID +FORCEINLINE +IOApicWrite(UCHAR Register, ULONG Value) +{ + /* Select the register, then do the write */ + *(volatile ULONG *)(IOAPIC_BASE + IOAPIC_IOREGSEL) = Register; + *(volatile ULONG *)(IOAPIC_BASE + IOAPIC_IOWIN) = Value; +} + +KIRQL +FORCEINLINE +ApicGetProcessorIrql(VOID) +{ + /* Read the TPR and convert it to an IRQL */ + return TprToIrql(ApicRead(APIC_PPR)); +} + +KIRQL +FORCEINLINE +ApicGetCurrentIrql(VOID) +{ + /* Read the TPR and convert it to an IRQL */ + return TprToIrql(ApicRead(APIC_TPR)); +} + +VOID +FORCEINLINE +ApicSetCurrentIrql(KIRQL Irql) +{ + /* Convert IRQL and write the TPR */ + ApicWrite(APIC_TPR, IrqlToTpr(Irql)); +} + +UCHAR +FASTCALL +HalpIrqToVector(UCHAR Irq) +{ + IOAPIC_REDIRECTION_REGISTER ReDirReg; + + /* Read low dword of the redirection entry */ + ReDirReg.Long0 = IOApicRead(IOAPIC_REDTBL + 2 * Irq); + + /* Return the vector */ + return (UCHAR)ReDirReg.Vector; +} + +KIRQL +FASTCALL +HalpVectorToIrql(UCHAR Vector) +{ + return TprToIrql(Vector >> 2); +} + +UCHAR +FASTCALL +HalpVectorToIrq(UCHAR Vector) +{ + return HalpVectorToIndex[Vector]; +} + +VOID +NTAPI +HalpInitializeLegacyPIC(VOID) +{ + I8259_ICW1 Icw1; + I8259_ICW2 Icw2; + I8259_ICW3 Icw3; + I8259_ICW4 Icw4; + + /* Initialize ICW1 for master, interval 8, edge-triggered mode with ICW4 */ + Icw1.NeedIcw4 = TRUE; + Icw1.OperatingMode = Cascade; + Icw1.Interval = Interval8; + Icw1.InterruptMode = EdgeTriggered; + Icw1.Init = TRUE; + Icw1.InterruptVectorAddress = 0; + __outbyte(PIC1_CONTROL_PORT, Icw1.Bits); + + /* ICW2 - interrupt vector offset */ + Icw2.Bits = PRIMARY_VECTOR_BASE; + __outbyte(PIC1_DATA_PORT, Icw2.Bits); + + /* Connect slave to IRQ 2 */ + Icw3.Bits = 0; + Icw3.SlaveIrq2 = TRUE; + __outbyte(PIC1_DATA_PORT, Icw3.Bits); + + /* Enable 8086 mode, non-automatic EOI, non-buffered mode, non special fully nested mode */ + Icw4.SystemMode = New8086Mode; + Icw4.EoiMode = NormalEoi; + Icw4.BufferedMode = NonBuffered; + Icw4.SpecialFullyNestedMode = FALSE; + Icw4.Reserved = 0; + __outbyte(PIC1_DATA_PORT, Icw4.Bits); + + /* Mask all interrupts */ + __outbyte(PIC1_DATA_PORT, 0xFF); + + /* Initialize ICW1 for slave, interval 8, edge-triggered mode with ICW4 */ + Icw1.NeedIcw4 = TRUE; + Icw1.InterruptMode = EdgeTriggered; + Icw1.OperatingMode = Cascade; + Icw1.Interval = Interval8; + Icw1.Init = TRUE; + Icw1.InterruptVectorAddress = 0; /* This is only used in MCS80/85 mode */ + __outbyte(PIC2_CONTROL_PORT, Icw1.Bits); + + /* Set interrupt vector base */ + Icw2.Bits = PRIMARY_VECTOR_BASE + 8; + __outbyte(PIC2_DATA_PORT, Icw2.Bits); + + /* Slave ID */ + Icw3.Bits = 0; + Icw3.SlaveId = 2; + __outbyte(PIC2_DATA_PORT, Icw3.Bits); + + /* Enable 8086 mode, non-automatic EOI, non-buffered mode, non special fully nested mode */ + Icw4.SystemMode = New8086Mode; + Icw4.EoiMode = NormalEoi; + Icw4.BufferedMode = NonBuffered; + Icw4.SpecialFullyNestedMode = FALSE; + Icw4.Reserved = 0; + __outbyte(PIC2_DATA_PORT, Icw4.Bits); + + /* Mask all interrupts */ + __outbyte(PIC2_DATA_PORT, 0xFF); +} + + +VOID +ApicInitializeLocalApic(ULONG Cpu) +{ + APIC_BASE_ADRESS_REGISTER BaseRegister; + APIC_SPURIOUS_INERRUPT_REGISTER SpIntRegister; + LVT_REGISTER LvtEntry; + + /* Enable the APIC if it wasn't yet */ + BaseRegister.Long = __readmsr(MSR_APIC_BASE); + BaseRegister.Enable = 1; + BaseRegister.BootStrapCPUCore = (Cpu == 0); + __writemsr(MSR_APIC_BASE, BaseRegister.Long); + + DPRINT1("ApicBase for Cpu %u PhysicalAddress = %p\n", Cpu, BaseRegister.BaseAddress); + DPRINT1("ApicVersion = 0x%lx\n", ApicRead(0x30)); + + /* Set spurious vector and SoftwareEnable to 1 */ + SpIntRegister.Long = ApicRead(APIC_SIVR); + SpIntRegister.Vector = APIC_SPURIOUS_VECTOR; + SpIntRegister.SoftwareEnable = 1; + SpIntRegister.FocusCPUCoreChecking = 0; + ApicWrite(APIC_SIVR, SpIntRegister.Long); + + /* Set the spurious ISR */ + KeRegisterInterruptHandler(APIC_SPURIOUS_VECTOR, ApicSpuriousService); + + /* Create a template LVT */ + LvtEntry.Long = 0; + LvtEntry.Vector = 0xFF; + LvtEntry.MessageType = APIC_MT_Fixed; + LvtEntry.DeliveryStatus = 0; + LvtEntry.RemoteIRR = 0; + LvtEntry.TriggerMode = APIC_TGM_Edge; + LvtEntry.Mask = 1; + LvtEntry.TimerMode = 0; + + /* Initalize and mask LVTs */ + ApicWrite(APIC_TMRLVTR, LvtEntry.Long); + ApicWrite(APIC_THRMLVTR, LvtEntry.Long); + ApicWrite(APIC_PCLVTR, LvtEntry.Long); + ApicWrite(APIC_EXT0LVTR, LvtEntry.Long); + ApicWrite(APIC_EXT1LVTR, LvtEntry.Long); + ApicWrite(APIC_EXT2LVTR, LvtEntry.Long); + ApicWrite(APIC_EXT3LVTR, LvtEntry.Long); + + /* LINT0 */ + LvtEntry.Vector = APIC_SPURIOUS_VECTOR; + LvtEntry.MessageType = APIC_MT_ExtInt; + ApicWrite(APIC_LINT0, LvtEntry.Long); + + /* Enable LINT1 (NMI) */ + LvtEntry.Mask = 0; + LvtEntry.Vector = APIC_NMI_VECTOR; + LvtEntry.MessageType = APIC_MT_NMI; + LvtEntry.TriggerMode = APIC_TGM_Level; + ApicWrite(APIC_LINT1, LvtEntry.Long); + + /* Enable error LVTR */ + LvtEntry.Vector = APIC_ERROR_VECTOR; + LvtEntry.MessageType = APIC_MT_Fixed; + ApicWrite(APIC_ERRLVTR, LvtEntry.Long); + + DPRINT1("Error code = 0x%lx\n", ApicRead(0x280)); +} + +VOID +NTAPI +ApicInitializeProcessor( + IN ULONG ProcessorNumber, + IN PLOADER_PARAMETER_BLOCK LoaderBlock) +{ + DPRINT1("ApicInitializeProcessor(%ld)\n", ProcessorNumber); + + /* Initialize the local APIC for this cpu */ + ApicInitializeLocalApic(ProcessorNumber); + + /* Initialize the timer */ + ApicInitializeTimer(ProcessorNumber); + +} + +VOID +FORCEINLINE +ApicWriteIORedirectionEntry( + UCHAR Index, + IOAPIC_REDIRECTION_REGISTER ReDirReg) +{ + IOApicWrite(IOAPIC_REDTBL + 2 * Index, ReDirReg.Long0); + IOApicWrite(IOAPIC_REDTBL + 2 * Index + 1, ReDirReg.Long1); +} + +IOAPIC_REDIRECTION_REGISTER +FORCEINLINE +ApicReadIORedirectionEntry( + UCHAR Index) +{ + IOAPIC_REDIRECTION_REGISTER ReDirReg; + + ReDirReg.Long0 = IOApicRead(IOAPIC_REDTBL + 2 * Index); + ReDirReg.Long1 = IOApicRead(IOAPIC_REDTBL + 2 * Index + 1); + + return ReDirReg; +} + +UCHAR +NTAPI +HalpAllocateSystemInterrupt( + IN UCHAR Irq, + IN KIRQL Irql) +{ + IOAPIC_REDIRECTION_REGISTER ReDirReg; + IN UCHAR Vector; + + /* Start with low vector */ + Vector = IrqlToTpr(Irql); + + /* Find an empty vector */ + while (HalpVectorToIndex[Vector] != 0xFF) + { + Vector++; + + /* Check if we went over the edge */ + if (TprToIrql(Vector) > Irql) + { + /* Nothing free, return failure */ + return 0; + } + } + + /* Save irq in the table */ + HalpVectorToIndex[Vector] = Irq; + + /* Setup a redirection entry */ + ReDirReg.Vector = Vector; + ReDirReg.DeliveryMode = APIC_MT_LowestPriority; + ReDirReg.DestinationMode = APIC_DM_Logical; + ReDirReg.DeliveryStatus = 0; + ReDirReg.Polarity = 0; + ReDirReg.RemoteIRR = 0; + ReDirReg.TriggerMode = APIC_TGM_Edge; + ReDirReg.Mask = 1; + ReDirReg.Reserved = 0; + ReDirReg.Destination = 0; + + /* Initialize entry */ + IOApicWrite(IOAPIC_REDTBL + 2 * Irq, ReDirReg.Long0); + IOApicWrite(IOAPIC_REDTBL + 2 * Irq + 1, ReDirReg.Long1); + + return Vector; +} + +VOID +NTAPI +ApicInitializeIOApic(VOID) +{ + PHARDWARE_PTE Pte; + IOAPIC_REDIRECTION_REGISTER ReDirReg; + UCHAR Index; + ULONG Vector; + + /* Map the I/O Apic page */ + Pte = HalAddressToPte(IOAPIC_BASE); + Pte->PageFrameNumber = IOAPIC_PHYS_BASE / PAGE_SIZE; + Pte->Valid = 1; + Pte->Write = 1; + Pte->Owner = 1; + Pte->CacheDisable = 1; + Pte->Global = 1; + _ReadWriteBarrier(); + + /* Setup a redirection entry */ + ReDirReg.Vector = 0xFF; + ReDirReg.DeliveryMode = APIC_MT_Fixed; + ReDirReg.DestinationMode = APIC_DM_Physical; + ReDirReg.DeliveryStatus = 0; + ReDirReg.Polarity = 0; + ReDirReg.RemoteIRR = 0; + ReDirReg.TriggerMode = APIC_TGM_Edge; + ReDirReg.Mask = 1; + ReDirReg.Reserved = 0; + ReDirReg.Destination = 0; + + /* Loop all table entries */ + for (Index = 0; Index < 24; Index++) + { + /* Initialize entry */ + IOApicWrite(IOAPIC_REDTBL + 2 * Index, ReDirReg.Long0); + IOApicWrite(IOAPIC_REDTBL + 2 * Index + 1, ReDirReg.Long1); + } + + /* Init the vactor to index table */ + for (Vector = 0; Vector <= 255; Vector++) + { + HalpVectorToIndex[Vector] = 0xFF; + } + + // HACK: Allocate all IRQs, should rather do that on demand + for (Index = 0; Index <= 15; Index++) + { + /* Map the IRQs to IRQLs like with the PIC */ + HalpAllocateSystemInterrupt(Index, 27 - Index); + } + + /* Enable the timer interrupt */ + ReDirReg.Vector = APIC_CLOCK_VECTOR; + ReDirReg.DestinationMode = APIC_DM_Logical; + ReDirReg.TriggerMode = APIC_TGM_Edge; + ReDirReg.Mask = 0; + IOApicWrite(IOAPIC_REDTBL + 2 * APIC_CLOCK_INDEX, ReDirReg.Long0); + +} + +VOID +NTAPI +HalpInitializePICs(IN BOOLEAN EnableInterrupts) +{ + ULONG_PTR EFlags; + + /* Save EFlags and disable interrupts */ + EFlags = __readeflags(); + _disable(); + + /* Initialize the local APIC for this cpu */ + ApicInitializeLocalApic(0); + + /* Initialize and mask the PIC */ + HalpInitializeLegacyPIC(); + + /* Initialize the I/O APIC */ + ApicInitializeIOApic(); + ApicWrite(APIC_EOI, 0); + + /* Register interrupt handlers */ + KeRegisterInterruptHandler(APIC_CLOCK_VECTOR, HalpClockInterrupt); + KeRegisterInterruptHandler(APC_VECTOR, HalpApcInterrupt); + KeRegisterInterruptHandler(DPC_VECTOR, HalpDispatchInterrupt); + + // HACK, since we messed with the value, should init the local apic in + // HalInitializeProcessor instead + ApicSetCurrentIrql(APC_LEVEL); + ASSERT(ApicGetProcessorIrql() <= APC_LEVEL); + +__debugbreak(); + +HalpInitializeClock(); +//HalpCalibrateStallExecution(); +_enable(); +for (;;); + + + /* Restore interrupt state */ + if (EnableInterrupts) EFlags |= EFLAGS_INTERRUPT_MASK; + __writeeflags(EFlags); +} + +VOID +DECLSPEC_NORETURN +FASTCALL +HalpApcInterruptHandler(IN PKTRAP_FRAME TrapFrame) +{ + ASSERT(ApicGetCurrentIrql() < APC_LEVEL); + ASSERT(ApicGetProcessorIrql() == APC_LEVEL); + + UNIMPLEMENTED; + ASSERT(FALSE); +} + +VOID +DECLSPEC_NORETURN +FASTCALL +HalpDispatchInterruptHandler(IN PKTRAP_FRAME TrapFrame) +{ + KIRQL OldIrql = ApicGetCurrentIrql(); +__debugbreak(); + ASSERT(OldIrql < DISPATCH_LEVEL); + ASSERT(ApicGetProcessorIrql() == DISPATCH_LEVEL); + + ApicSetCurrentIrql(DISPATCH_LEVEL); + + /* Enable interrupts and call the kernel's DPC interrupt handler */ + _enable(); + KiDispatchInterrupt(); + _disable(); + + ApicSetCurrentIrql(OldIrql); + + ApicWrite(APIC_EOI, 0); + + /* Exit the interrupt */ + KiEoiHelper(TrapFrame); +} + + +/* PUBLIC FUNCTIONS ***********************************************************/ + +VOID +FASTCALL +HalRequestSoftwareInterrupt(IN KIRQL Irql) +{ + APIC_COMMAND_REGISTER CommandRegister; + + /* Setup the command register */ + CommandRegister.Long0 = 0; + CommandRegister.Vector = IrqlToTpr(Irql); + CommandRegister.MessageType = APIC_MT_Fixed; + CommandRegister.TriggerMode = APIC_TGM_Edge; + CommandRegister.DestinationShortHand = APIC_DSH_Self; + + /* Write the low dword to send the interrupt */ + ApicWrite(APIC_ICR0, CommandRegister.Long0); +} + +VOID +FASTCALL +HalClearSoftwareInterrupt( + IN KIRQL Irql) +{ + /* Nothing to do */ +} + +BOOLEAN +NTAPI +HalEnableSystemInterrupt( + IN UCHAR Vector, + IN KIRQL Irql, + IN KINTERRUPT_MODE InterruptMode) +{ + IOAPIC_REDIRECTION_REGISTER ReDirReg; + UCHAR Index; + ASSERT(Irql <= HIGH_LEVEL); + ASSERT((IrqlToTpr(Irql) & 0xF0) == (Vector & 0xF0)); + + Index = HalpVectorToIndex[Vector]; + + /* Read lower dword of redirection entry */ + ReDirReg.Long0 = IOApicRead(IOAPIC_REDTBL + 2 * Index); + + ReDirReg.Vector = Vector; + ReDirReg.DeliveryMode = APIC_MT_LowestPriority; + ReDirReg.DestinationMode = APIC_DM_Logical; + ReDirReg.TriggerMode = 1 - InterruptMode; + ReDirReg.Mask = FALSE; + + /* Write back lower dword */ + IOApicWrite(IOAPIC_REDTBL + 2 * Irql, ReDirReg.Long0); + + return TRUE; +} + +VOID +NTAPI +HalDisableSystemInterrupt( + IN UCHAR Vector, + IN KIRQL Irql) +{ + IOAPIC_REDIRECTION_REGISTER ReDirReg; + UCHAR Index; + ASSERT(Irql <= HIGH_LEVEL); + + Index = HalpVectorToIndex[Vector]; + + /* Read lower dword of redirection entry */ + ReDirReg.Long0 = IOApicRead(IOAPIC_REDTBL + 2 * Index); + + /* Mask it */ + ReDirReg.Mask = 1; + + /* Write back lower dword */ + IOApicWrite(IOAPIC_REDTBL + 2 * Irql, ReDirReg.Long0); +} + +BOOLEAN +NTAPI +HalBeginSystemInterrupt( + IN KIRQL Irql, + IN UCHAR Vector, + OUT PKIRQL OldIrql) +{ + /* Get the current IRQL */ + *OldIrql = ApicGetCurrentIrql(); + + /* Set the new IRQL */ + ApicSetCurrentIrql(Irql); + + /* Turn on interrupts */ + _enable(); + + /* Success */ + return TRUE; +} + +VOID +NTAPI +HalEndSystemInterrupt( + IN KIRQL OldIrql, + IN PKTRAP_FRAME TrapFrame) +{ + /* Restore the old IRQL */ + ApicSetCurrentIrql(OldIrql); + + /* Write 0 to the EndOfInterruptRegister for level triggered ints */ + ApicWrite(APIC_EOI, 0); +} + +#ifndef _M_AMD64 + +KIRQL +NTAPI +KeGetCurrentIrql(VOID) +{ + /* Read the current TPR and convert it to an IRQL */ + return ApicGetCurrentIrql(); +} + +VOID +FASTCALL +KfLowerIrql( + IN KIRQL OldIrql) +{ +#if DBG + /* Validate correct lower */ + if (OldIrql > ApicGetCurrentIrql()) + { + /* Crash system */ + KeBugCheck(IRQL_NOT_LESS_OR_EQUAL); + } +#endif + /* Convert the new IRQL to a TPR value and write the register */ + ApicSetCurrentIrql(OldIrql); +} + +KIRQL +FASTCALL +KfRaiseIrql( + IN KIRQL NewIrql) +{ + KIRQL OldIrql; + + /* Read the current TPR and convert it to an IRQL */ + OldIrql = ApicGetCurrentIrql(); +#if DBG + /* Validate correct raise */ + if (OldIrql > NewIrql) + { + /* Crash system */ + KeBugCheck(IRQL_NOT_GREATER_OR_EQUAL); + } +#endif + /* Convert the new IRQL to a TPR value and write the register */ + ApicSetCurrentIrql(NewIrql); + + return OldIrql; +} + +KIRQL +NTAPI +KeRaiseIrqlToDpcLevel(VOID) +{ + return KfRaiseIrql(DISPATCH_LEVEL); +} + +KIRQL +NTAPI +KeRaiseIrqlToSynchLevel(VOID) +{ + return KfRaiseIrql(SYNCH_LEVEL); +} + +#endif /* !_M_AMD64 */ + diff --git a/reactos/hal/halx86/apic/apic.h b/reactos/hal/halx86/apic/apic.h new file mode 100644 index 00000000000..3f9f62c515c --- /dev/null +++ b/reactos/hal/halx86/apic/apic.h @@ -0,0 +1,271 @@ + +#ifdef _M_AMD64 +#define APIC_BASE 0xfffffffffee00000ULL; +#define ZERO_VECTOR 0x00 // IRQL 00 +#define APC_VECTOR 0x3D // IRQL 01 +#define APIC_SPURIOUS_VECTOR 0x3f +#define DPC_VECTOR 0x41 // IRQL 02 +#define APIC_GENERIC_VECTOR 0xC1 // IRQL 27 +#define APIC_CLOCK_VECTOR 0xD1 // IRQL 28 +#define APIC_SYNCH_VECTOR 0xD1 // IRQL 28 +#define APIC_IPI_VECTOR 0xE1 // IRQL 29 +#define APIC_ERROR_VECTOR 0xE3 +#define POWERFAIL_VECTOR 0xEF // IRQL 30 +#define APIC_PROFILE_VECTOR 0xFD // IRQL 31 +#define APIC_NMI_VECTOR 0xFF +#define IrqlToTpr(Irql) (Irql << 4) +#define TprToIrql(Tpr) (Tpr >> 4) +#else +#define APIC_BASE 0xFFFE0000 +#define IOAPIC_BASE 0xFFFE1000 // checkme +#define IOAPIC_PHYS_BASE 0xFEC00000 +#define ZERO_VECTOR 0x00 // IRQL 00 +#define APIC_SPURIOUS_VECTOR 0x1f +#define APC_VECTOR 0x3D // IRQL 01 +#define DPC_VECTOR 0x41 // IRQL 02 +#define APIC_GENERIC_VECTOR 0xC1 // IRQL 27 +#define APIC_CLOCK_VECTOR 0xD1 // IRQL 28 +#define APIC_SYNCH_VECTOR 0xD1 // IRQL 28 +#define APIC_IPI_VECTOR 0xE1 // IRQL 29 +#define APIC_ERROR_VECTOR 0xE3 +#define POWERFAIL_VECTOR 0xEF // IRQL 30 +#define APIC_PROFILE_VECTOR 0xFD // IRQL 31 +#define APIC_NMI_VECTOR 0xFF +#define IrqlToTpr(Irql) (HalpIRQLtoTPR[Irql]) +#define TprToIrql(Tpr) (HalVectorToIRQL[Tpr >> 4]) +#endif + +#define MSR_APIC_BASE 0x0000001B +#define APIC_CLOCK_INDEX 8 + + +/* APIC Register Address Map */ +#define APIC_ID 0x0020 /* Local APIC ID Register (R/W) */ +#define APIC_VER 0x0030 /* Local APIC Version Register (R) */ +#define APIC_TPR 0x0080 /* Task Priority Register (R/W) */ +#define APIC_APR 0x0090 /* Arbitration Priority Register (R) */ +#define APIC_PPR 0x00A0 /* Processor Priority Register (R) */ +#define APIC_EOI 0x00B0 /* EOI Register (W) */ +#define APIC_RRR 0x00C0 /* Remote Read Register () */ +#define APIC_LDR 0x00D0 /* Logical Destination Register (R/W) */ +#define APIC_DFR 0x00E0 /* Destination Format Register (0-27 R, 28-31 R/W) */ +#define APIC_SIVR 0x00F0 /* Spurious Interrupt Vector Register (0-3 R, 4-9 R/W) */ +#define APIC_ISR 0x0100 /* Interrupt Service Register 0-255 (R) */ +#define APIC_TMR 0x0180 /* Trigger Mode Register 0-255 (R) */ +#define APIC_IRR 0x0200 /* Interrupt Request Register 0-255 (r) */ +#define APIC_ESR 0x0280 /* Error Status Register (R) */ +#define APIC_ICR0 0x0300 /* Interrupt Command Register 0-31 (R/W) */ +#define APIC_ICR1 0x0310 /* Interrupt Command Register 32-63 (R/W) */ +#define APIC_TMRLVTR 0x0320 /* Timer Local Vector Table (R/W) */ +#define APIC_THRMLVTR 0x0330 /* Thermal Local Vector Table */ +#define APIC_PCLVTR 0x0340 /* Performance Counter Local Vector Table (R/W) */ +#define APIC_LINT0 0x0350 /* LINT0 Local Vector Table (R/W) */ +#define APIC_LINT1 0x0360 /* LINT1 Local Vector Table (R/W) */ +#define APIC_ERRLVTR 0x0370 /* Error Local Vector Table (R/W) */ +#define APIC_TICR 0x0380 /* Initial Count Register for Timer (R/W) */ +#define APIC_TCCR 0x0390 /* Current Count Register for Timer (R) */ +#define APIC_TDCR 0x03E0 /* Timer Divide Configuration Register (R/W) */ +#define APIC_EAFR 0x0400 /* extended APIC Feature register (R/W) */ +#define APIC_EACR 0x0410 /* Extended APIC Control Register (R/W) */ +#define APIC_SEOI 0x0420 /* Specific End Of Interrupt Register (W) */ +#define APIC_EXT0LVTR 0x0500 /* Extended Interrupt 0 Local Vector Table */ +#define APIC_EXT1LVTR 0x0510 /* Extended Interrupt 1 Local Vector Table */ +#define APIC_EXT2LVTR 0x0520 /* Extended Interrupt 2 Local Vector Table */ +#define APIC_EXT3LVTR 0x0530 /* Extended Interrupt 3 Local Vector Table */ + +enum +{ + APIC_MT_Fixed = 0, + APIC_MT_LowestPriority = 1, + APIC_MT_SMI = 2, + APIC_MT_RemoteRead = 3, + APIC_MT_NMI = 4, + APIC_MT_INIT = 5, + APIC_MT_Startup = 6, + APIC_MT_ExtInt = 7, +}; + +enum +{ + APIC_TGM_Edge, + APIC_TGM_Level +}; + +enum +{ + APIC_DM_Physical, + APIC_DM_Logical +}; + +enum +{ + APIC_DSH_Destination, + APIC_DSH_Self, + APIC_DSH_AllIncludingSelf, + APIC_DSH_AllExclusingSelf +}; + +enum +{ + TIMER_DV_DivideBy2 = 0, + TIMER_DV_DivideBy4 = 1, + TIMER_DV_DivideBy8 = 2, + TIMER_DV_DivideBy16 = 3, + TIMER_DV_DivideBy32 = 8, + TIMER_DV_DivideBy64 = 9, + TIMER_DV_DivideBy128 = 10, + TIMER_DV_DivideBy1 = 11, +}; + + +typedef union _APIC_BASE_ADRESS_REGISTER +{ + ULONG64 Long; + struct + { + ULONG64 Reserved1:8; + ULONG64 BootStrapCPUCore:1; + ULONG64 Reserved2:2; + ULONG64 Enable:1; + ULONG64 BaseAddress:40; + ULONG64 ReservedMBZ:12; + }; +} APIC_BASE_ADRESS_REGISTER; + +typedef union _APIC_SPURIOUS_INERRUPT_REGISTER +{ + ULONG Long; + struct + { + ULONG Vector:8; + ULONG SoftwareEnable:1; + ULONG FocusCPUCoreChecking:1; + ULONG ReservedMBZ:22; + }; +} APIC_SPURIOUS_INERRUPT_REGISTER; + +typedef union +{ + ULONG Long; + struct + { + ULONG Version:8; + ULONG ReservedMBZ:8; + ULONG MaxLVT:8; + ULONG ReservedMBZ1:7; + ULONG ExtRegSpacePresent:1; + }; +} APIC_VERSION_REGISTER; + +typedef union +{ + ULONG Long; + struct + { + ULONG Version:1; + ULONG SEOIEnable:1; + ULONG ExtApicIdEnable:1; + ULONG ReservedMBZ:29; + }; +} APIC_EXTENDED_CONTROL_REGISTER; + +typedef union _APIC_COMMAND_REGISTER +{ + ULONGLONG LongLong; + struct + { + ULONG Long0; + ULONG Long1; + }; + struct + { + ULONGLONG Vector:8; + ULONGLONG MessageType:3; + ULONGLONG DestinationMode:1; + ULONGLONG DeliveryStatus:1; + ULONGLONG ReservedMBZ:1; + ULONGLONG Level:1; + ULONGLONG TriggerMode:1; + ULONGLONG RemoteReadStatus:2; + ULONGLONG DestinationShortHand:2; + ULONGLONG Reserved2MBZ:36; + ULONGLONG Destination:8; + }; +} APIC_COMMAND_REGISTER; + +typedef union +{ + ULONG Long; + struct + { + ULONG Vector:8; + ULONG MessageType:3; + ULONG ReservedMBZ:1; + ULONG DeliveryStatus:1; + ULONG Reserved1MBZ:1; + ULONG RemoteIRR:1; + ULONG TriggerMode:1; + ULONG Mask:1; + ULONG TimerMode:1; + ULONG Reserved2MBZ:13; + }; +} LVT_REGISTER; + + +enum +{ + IOAPIC_IOREGSEL = 0x00, + IOAPIC_IOWIN = 0x10 +}; + +enum +{ + IOAPIC_ID = 0x00, + IOAPIC_VER = 0x01, + IOAPIC_ARB = 0x02, + IOAPIC_REDTBL = 0x28 +}; + +typedef union _IOAPIC_REDIRECTION_REGISTER +{ + ULONGLONG LongLong; + struct + { + ULONG Long0; + ULONG Long1; + }; + struct + { + ULONGLONG Vector:8; + ULONGLONG DeliveryMode:3; + ULONGLONG DestinationMode:1; + ULONGLONG DeliveryStatus:1; + ULONGLONG Polarity:1; + ULONGLONG RemoteIRR:1; + ULONGLONG TriggerMode:1; + ULONGLONG Mask:1; + ULONGLONG Reserved:39; + ULONGLONG Destination:8; + }; +} IOAPIC_REDIRECTION_REGISTER; + +ULONG +FORCEINLINE +ApicRead(ULONG Offset) +{ + return *(volatile ULONG *)(APIC_BASE + Offset); +} + +VOID +FORCEINLINE +ApicWrite(ULONG Offset, ULONG Value) +{ + *(volatile ULONG *)(APIC_BASE + Offset) = Value; +} + +VOID +NTAPI +ApicInitializeTimer(ULONG Cpu); + +VOID ApicSpuriousService(VOID); + diff --git a/reactos/hal/halx86/apic/apictimer.c b/reactos/hal/halx86/apic/apictimer.c new file mode 100644 index 00000000000..cc0231623f2 --- /dev/null +++ b/reactos/hal/halx86/apic/apictimer.c @@ -0,0 +1,84 @@ +/* + * PROJECT: ReactOS HAL + * LICENSE: GPL - See COPYING in the top level directory + * FILE: hal/halx86/apic/apictimer.c + * PURPOSE: System Profiling + * PROGRAMMERS: Timo Kreuzer (timo.kreuzer@reactos.org) + */ + +/* INCLUDES ******************************************************************/ + +#include +#define NDEBUG +#include + +#include "apic.h" + +extern LARGE_INTEGER HalpCpuClockFrequency; + +/* TIMER FUNCTIONS ************************************************************/ + +VOID +NTAPI +ApicSetTimerInterval(ULONG MicroSeconds) +{ + LVT_REGISTER LvtEntry; + ULONGLONG TimerInterval; + + /* Calculate the Timer interval */ + TimerInterval = HalpCpuClockFrequency.QuadPart * MicroSeconds / 1000000; + + /* Set the count interval */ + ApicWrite(APIC_TICR, (ULONG)TimerInterval); + + /* Set to periodic */ + LvtEntry.Long = 0; + LvtEntry.TimerMode = 1; + LvtEntry.Vector = APIC_PROFILE_VECTOR; + LvtEntry.Mask = 0; + ApicWrite(APIC_TMRLVTR, LvtEntry.Long); + +} + +VOID +NTAPI +ApicInitializeTimer(ULONG Cpu) +{ + + /* Initialize the TSC */ + //HalpInitializeTsc(); + + /* Set clock multiplier to 1 */ + ApicWrite(APIC_TDCR, TIMER_DV_DivideBy1); + + ApicSetTimerInterval(1000); + +// KeSetTimeIncrement +} + + +/* PUBLIC FUNCTIONS ***********************************************************/ + +VOID +NTAPI +HalStartProfileInterrupt(IN KPROFILE_SOURCE ProfileSource) +{ + UNIMPLEMENTED; + return; +} + +VOID +NTAPI +HalStopProfileInterrupt(IN KPROFILE_SOURCE ProfileSource) +{ + UNIMPLEMENTED; + return; +} + +ULONG_PTR +NTAPI +HalSetProfileInterval(IN ULONG_PTR Interval) +{ + UNIMPLEMENTED; + return Interval; +} diff --git a/reactos/hal/halx86/apic/apictrap.S b/reactos/hal/halx86/apic/apictrap.S new file mode 100644 index 00000000000..63d79e834e2 --- /dev/null +++ b/reactos/hal/halx86/apic/apictrap.S @@ -0,0 +1,36 @@ +/* + * FILE: hal/halx86/apic/apictrap.S + * COPYRIGHT: See COPYING in the top level directory + * PURPOSE: System Traps, Entrypoints and Exitpoints + * PROGRAMMER: Timo Kreuzer (timo.kreuzer@reactos.org) + * NOTE: See asmmacro.S for the shared entry/exit code. + */ + +/* INCLUDES ******************************************************************/ + +#include +#include + +#ifdef _M_AMD64 +#include +PUBLIC ApicSpuriousService +#else +#include +PUBLIC _ApicSpuriousService +#endif + +.code + +TRAP_ENTRY HalpTrap0D, 0 +TRAP_ENTRY HalpApcInterrupt, KI_SOFTWARE_TRAP +TRAP_ENTRY HalpDispatchInterrupt, KI_PUSH_FAKE_ERROR_CODE +TRAP_ENTRY HalpClockInterrupt, KI_PUSH_FAKE_ERROR_CODE +TRAP_ENTRY HalpProfileInterrupt, KI_PUSH_FAKE_ERROR_CODE + +FUNC ApicSpuriousService + int 3 + iret +ENDFUNC ApicSpuriousService + + +END diff --git a/reactos/hal/halx86/apic/rtctimer.c b/reactos/hal/halx86/apic/rtctimer.c new file mode 100644 index 00000000000..3160681aec0 --- /dev/null +++ b/reactos/hal/halx86/apic/rtctimer.c @@ -0,0 +1,144 @@ +/* + * PROJECT: ReactOS HAL + * LICENSE: GNU GPL - See COPYING in the top level directory + * FILE: hal/halx86/generic/apic.c + * PURPOSE: HAL APIC Management and Control Code + * PROGRAMMERS: Timo Kreuzer (timo.kreuzer@reactos.org) + * REFERENCES: + */ + +/* INCLUDES *******************************************************************/ + +#include +#define NDEBUG +#include + + +/* GLOBALS ********************************************************************/ + +const UCHAR HalpClockVector = 0xD1; +BOOLEAN HalpClockSetMSRate; +UCHAR HalpNextMSRate; +UCHAR HalpCurrentRate = 9; +ULONG HalpCurrentTimeIncrement; +static UCHAR RtcLargestClockRate = 10; + + +ULONG +FORCEINLINE +RtcClockRateToIncrement(UCHAR Rate) +{ + ULONG Freqency = ((32768 << 1) >> Rate); + return (1000000 + (Freqency/2)) / Freqency; +} + +VOID +RtcSetClockRate(UCHAR ClockRate) +{ + ULONG_PTR EFlags; + UCHAR RegisterA; + + /* Disable interrupts */ + EFlags = __readeflags(); + _disable(); + + // TODO: disable NMI + + /* Read value of register A */ + RegisterA = HalpReadCmos(RTC_REGISTER_A); + + /* Change lower 4 bits to new rate */ + RegisterA &= 0xF0; + RegisterA |= ClockRate; + + /* Write the new value */ + HalpWriteCmos(RTC_REGISTER_A, RegisterA); + + /* Restore interrupts if they were previously enabled */ + __writeeflags(EFlags); +} + + +VOID +NTAPI +INIT_FUNCTION +HalpInitializeClock(VOID) +{ + UCHAR RegisterB; + // TODO: disable NMI + + /* Enable the periodic interrupt in the CMOS */ + RegisterB = HalpReadCmos(RTC_REGISTER_B); + HalpWriteCmos(RTC_REGISTER_B, RegisterB | RTC_REG_B_PI); + + // RtcSetClockRate(HalpCurrentRate); +} + +VOID +FASTCALL +HalpClockInterruptHandler(IN PKTRAP_FRAME TrapFrame) +{ + ULONG LastIncrement; + KIRQL Irql; + + /* Enter trap */ + KiEnterInterruptTrap(TrapFrame); +__debugbreak(); + /* Start the interrupt */ + if (HalBeginSystemInterrupt(CLOCK2_LEVEL, PRIMARY_VECTOR_BASE, &Irql)) + { + /* Read register C, so that the next interrupt can happen */ + HalpReadCmos(RTC_REGISTER_C);; + + /* Save increment */ + LastIncrement = HalpCurrentTimeIncrement; + + /* Check if someone changed the time rate */ + if (HalpClockSetMSRate) + { + /* Update the global values */ + HalpCurrentRate = HalpNextMSRate; + HalpCurrentTimeIncrement = RtcClockRateToIncrement(HalpCurrentRate); + + /* Set new clock rate */ + RtcSetClockRate(HalpCurrentRate); + + /* We're done */ + HalpClockSetMSRate = FALSE; + } + + /* Update the system time -- the kernel will exit this trap */ + KeUpdateSystemTime(TrapFrame, LastIncrement, Irql); + } + + /* Spurious, just end the interrupt */ + KiEoiHelper(TrapFrame); +} + +VOID +FASTCALL +HalpProfileInterruptHandler(IN PKTRAP_FRAME TrapFrame) +{ + __debugbreak(); +} + +ULONG +NTAPI +HalSetTimeIncrement(IN ULONG Increment) +{ + UCHAR Rate; + + /* Lookup largest value below given Increment */ + for (Rate = 2; Rate < RtcLargestClockRate; Rate++) + { + /* Check if this is the largest rate possible */ + if (RtcClockRateToIncrement(Rate + 1) > Increment) break; + } + + /* Set the rate and tell HAL we want to change it */ + HalpNextMSRate = Rate; + HalpClockSetMSRate = TRUE; + + /* Return the real increment */ + return RtcClockRateToIncrement(Rate); +} diff --git a/reactos/hal/halx86/apic/tsc.c b/reactos/hal/halx86/apic/tsc.c new file mode 100644 index 00000000000..14d5c1fba7f --- /dev/null +++ b/reactos/hal/halx86/apic/tsc.c @@ -0,0 +1,140 @@ +/* + * PROJECT: ReactOS HAL + * LICENSE: GPL - See COPYING in the top level directory + * FILE: hal/halamd64/generic/tsc.c + * PURPOSE: HAL Routines for TSC handling + * PROGRAMMERS: Timo Kreuzer (timo.kreuzer@reactos.org) + */ + +/* INCLUDES ******************************************************************/ + +#include +#define NDEBUG +#include + +#include "tsc.h" + +LARGE_INTEGER HalpCpuClockFrequency = {INITIAL_STALL_COUNT * 1000000}; + +UCHAR TscCalibrationPhase; +LARGE_INTEGER TscCalibrationArray[NUM_SAMPLES]; +extern const UCHAR HalpClockVector; + +/* PRIVATE FUNCTIONS *********************************************************/ + +VOID +NTAPI +HalpInitializeTsc() +{ + ULONG_PTR Flags; + KIDTENTRY OldIdtEntry, *IdtPointer; + PKPCR Pcr = KeGetPcr(); + + /* Check if the CPU supports RDTSC */ + if (!(KeGetCurrentPrcb()->FeatureBits & KF_RDTSC)) + { + KeBugCheck(HAL_INITIALIZATION_FAILED); + } + + /* Save flags and disable interrupts */ + Flags = __readeflags(); + _disable(); + +__debugbreak(); + + /* Initialze the PIT */ + //HalpInitializePIT(); + + /* Save old IDT entry */ + IdtPointer = KiGetIdtEntry(Pcr, HalpClockVector); + OldIdtEntry = *IdtPointer; + + /* Set the calibration ISR */ + KeRegisterInterruptHandler(HalpClockVector, TscCalibrationISR); + + /* Reset TSC value to 0 */ + __writemsr(MSR_RDTSC, 0); + + /* Enable the timer interupt */ + HalEnableSystemInterrupt(HalpClockVector, CLOCK_LEVEL, Latched); + + /* Wait for completion */ + _enable(); + while (TscCalibrationPhase < NUM_SAMPLES) _ReadWriteBarrier(); + _disable(); + + /* Disable the timer interupt */ + HalDisableSystemInterrupt(HalpClockVector, CLOCK_LEVEL); + + /* Restore old IDT entry */ + *IdtPointer = OldIdtEntry; + + // do linear regression + + + /* Restore flags */ + __writeeflags(Flags); + +} + +VOID +NTAPI +HalpCalibrateStallExecution(VOID) +{ + // Timer interrupt is now active + + HalpInitializeTsc(); + + KeGetPcr()->StallScaleFactor = (ULONG)(HalpCpuClockFrequency.QuadPart / 1000000); +} + +/* PUBLIC FUNCTIONS ***********************************************************/ + +LARGE_INTEGER +NTAPI +KeQueryPerformanceCounter( + OUT PLARGE_INTEGER PerformanceFrequency OPTIONAL) +{ + LARGE_INTEGER Result; + + /* Make sure it's calibrated */ + ASSERT(HalpCpuClockFrequency.QuadPart != 0); + + /* Does the caller want the frequency? */ + if (PerformanceFrequency) + { + /* Return tsc frequency */ + *PerformanceFrequency = HalpCpuClockFrequency; + } + + /* Return the current value */ + Result.QuadPart = __rdtsc(); + return Result; +} + +VOID +NTAPI +KeStallExecutionProcessor(ULONG MicroSeconds) +{ + ULONG64 StartTime, EndTime; + + /* Get the initial time */ + StartTime = __rdtsc(); + + /* Calculate the ending time */ + EndTime = StartTime + HalpCpuClockFrequency.QuadPart * MicroSeconds; + + /* Loop until time is elapsed */ + while (__rdtsc() < EndTime); +} + +VOID +NTAPI +HalCalibratePerformanceCounter( + IN volatile PLONG Count, + IN ULONGLONG NewCount) +{ + UNIMPLEMENTED; + ASSERT(FALSE); +} + diff --git a/reactos/hal/halx86/apic/tsc.h b/reactos/hal/halx86/apic/tsc.h new file mode 100644 index 00000000000..3cda723401a --- /dev/null +++ b/reactos/hal/halx86/apic/tsc.h @@ -0,0 +1,15 @@ + + +#define NUM_SAMPLES 4 +#define MSR_RDTSC 0x10 + +#ifndef __ASM__ + +void TscCalibrationISR(void); +extern LARGE_INTEGER HalpCpuClockFrequency; +VOID NTAPI HalpInitializeTsc(); + + +#define KiGetIdtEntry(Pcr, Vector) &((Pcr)->IDT[Vector]) + +#endif diff --git a/reactos/hal/halx86/apic/tsccal.S b/reactos/hal/halx86/apic/tsccal.S new file mode 100644 index 00000000000..a3d7c0f8d72 --- /dev/null +++ b/reactos/hal/halx86/apic/tsccal.S @@ -0,0 +1,39 @@ + +#include +#include "tsc.h" + +.code + +EXTERN _TscCalibrationPhase:BYTE +EXTERN _TscCalibrationArray:QWORD + +PUBLIC _TscCalibrationISR +_TscCalibrationISR: + push eax + push ecx + push edx + + /* The first thing we do is read the current TSC value */ + rdtsc + + /* Read the current phase */ + movzx ecx, byte ptr ds:[_TscCalibrationPhase] + + /* Check if we're already done */ + cmp cl, NUM_SAMPLES + jnb _CalibrationISR_Exit + + /* Store the current value */ + mov dword ptr _TscCalibrationArray[ecx * 2], eax + mov dword ptr _TscCalibrationArray[ecx * 2 + 4], edx + + /* Advance phase */ + inc byte ptr ds:[_TscCalibrationPhase] + +_CalibrationISR_Exit: + pop edx + pop ecx + pop eax + iretd + +END From a4c1f7e52aeec090ac1d5ea9a40f52401889d9cc Mon Sep 17 00:00:00 2001 From: Rafal Harabien Date: Wed, 7 Sep 2011 09:51:13 +0000 Subject: [PATCH 40/55] [MKHIVE] - Fix max key name length, max value name length, max value data length properties of registry key not being set correctly - Fixes #6042 - regedit on LiveCD shows keys and values now svn path=/trunk/; revision=53614 --- reactos/tools/mkhive/cmi.c | 23 +++++++++++++++++++++++ reactos/tools/mkhive/registry.c | 3 +++ 2 files changed, 26 insertions(+) diff --git a/reactos/tools/mkhive/cmi.c b/reactos/tools/mkhive/cmi.c index 98914edbf3f..bb8f48fba9c 100644 --- a/reactos/tools/mkhive/cmi.c +++ b/reactos/tools/mkhive/cmi.c @@ -388,6 +388,19 @@ CmiAddSubKey( if (NT_SUCCESS(Status)) { ParentKeyCell->SubKeyCounts[Storage]++; + if (Packable) + { + if (NameLength*sizeof(WCHAR) > ParentKeyCell->MaxNameLen) + ParentKeyCell->MaxNameLen = NameLength*sizeof(WCHAR); + } + else + { + if (NameLength > ParentKeyCell->MaxNameLen) + ParentKeyCell->MaxNameLen = NameLength; + } + if (NewKeyCell->ClassLength > ParentKeyCell->MaxClassLen) + ParentKeyCell->MaxClassLen = NewKeyCell->ClassLength; + *pSubKeyCell = NewKeyCell; *pBlockOffset = NKBOffset; } @@ -720,6 +733,16 @@ CmiAddValueKey( ValueListCell->ValueOffset[KeyCell->ValueList.Count] = NewValueCellOffset; KeyCell->ValueList.Count++; + if (NewValueCell->Flags & VALUE_COMP_NAME) + { + if (NewValueCell->NameLength*sizeof(WCHAR) > KeyCell->MaxValueNameLen) + KeyCell->MaxValueNameLen = NewValueCell->NameLength*sizeof(WCHAR); + } + else + { + if (NewValueCell->NameLength > KeyCell->MaxValueNameLen) + KeyCell->MaxValueNameLen = NewValueCell->NameLength; + } HvMarkCellDirty(&RegistryHive->Hive, KeyCellOffset, FALSE); HvMarkCellDirty(&RegistryHive->Hive, KeyCell->ValueList.List, FALSE); diff --git a/reactos/tools/mkhive/registry.c b/reactos/tools/mkhive/registry.c index 07339afe3f1..82915eb1fb0 100644 --- a/reactos/tools/mkhive/registry.c +++ b/reactos/tools/mkhive/registry.c @@ -448,6 +448,9 @@ RegSetValueExW( HvMarkCellDirty(&Key->RegistryHive->Hive, ValueCellOffset, FALSE); } + if (cbData > Key->KeyCell->MaxValueDataLen) + Key->KeyCell->MaxValueDataLen = cbData; + HvMarkCellDirty(&Key->RegistryHive->Hive, Key->KeyCellOffset, FALSE); DPRINT("Return status 0x%08x\n", Status); From 29f16ed6c44006476770786ab8c48dddde4b0da9 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Wed, 7 Sep 2011 10:14:48 +0000 Subject: [PATCH 41/55] [HAL] Rename HalpAcquireSystemHardwareSpinLock to HalpAcquireCmosSpinLock svn path=/trunk/; revision=53615 --- reactos/hal/halx86/generic/beep.c | 10 +++++----- reactos/hal/halx86/generic/cmos.c | 14 +++++++------- reactos/hal/halx86/generic/profil.c | 2 +- reactos/hal/halx86/generic/reboot.c | 2 +- reactos/hal/halx86/generic/spinlock.c | 2 +- reactos/hal/halx86/generic/systimer.S | 8 ++++---- reactos/hal/halx86/include/halp.h | 2 +- 7 files changed, 20 insertions(+), 20 deletions(-) diff --git a/reactos/hal/halx86/generic/beep.c b/reactos/hal/halx86/generic/beep.c index 70612cd0be5..f1bc9634099 100644 --- a/reactos/hal/halx86/generic/beep.c +++ b/reactos/hal/halx86/generic/beep.c @@ -29,7 +29,7 @@ HalMakeBeep(IN ULONG Frequency) // // Acquire CMOS Lock // - HalpAcquireSystemHardwareSpinLock(); + HalpAcquireCmosSpinLock(); // // Turn the timer off by disconnecting its output pin and speaker gate @@ -58,7 +58,7 @@ HalMakeBeep(IN ULONG Frequency) // Program the PIT for binary mode // TimerControl.BcdMode = FALSE; - + // // Program the PIT to generate a square wave (Mode 3) on channel 2. // Channel 0 is used for the IRQ0 clock interval timer, and channel @@ -76,17 +76,17 @@ HalMakeBeep(IN ULONG Frequency) // TimerControl.OperatingMode = PitOperatingMode3; TimerControl.Channel = PitChannel2; - + // // Set the access mode that we'll use to program the reload value. // TimerControl.AccessMode = PitAccessModeLowHigh; - + // // Now write the programming bits // __outbyte(TIMER_CONTROL_PORT, TimerControl.Bits); - + // // Next we write the reload value for channel 2 // diff --git a/reactos/hal/halx86/generic/cmos.c b/reactos/hal/halx86/generic/cmos.c index 6a3a9ec47a3..4eba603ff7f 100644 --- a/reactos/hal/halx86/generic/cmos.c +++ b/reactos/hal/halx86/generic/cmos.c @@ -57,7 +57,7 @@ HalpGetCmosData(IN ULONG BusNumber, if (!Length) return 0; /* Acquire CMOS Lock */ - HalpAcquireSystemHardwareSpinLock(); + HalpAcquireCmosSpinLock(); /* Check if this is simple CMOS */ if (BusNumber == 0) @@ -111,7 +111,7 @@ HalpSetCmosData(IN ULONG BusNumber, if (!Length) return 0; /* Acquire CMOS Lock */ - HalpAcquireSystemHardwareSpinLock(); + HalpAcquireCmosSpinLock(); /* Check if this is simple CMOS */ if (BusNumber == 0) @@ -179,7 +179,7 @@ HalGetEnvironmentVariable(IN PCH Name, if (_stricmp(Name, "LastKnownGood")) return ENOENT; /* Acquire CMOS Lock */ - HalpAcquireSystemHardwareSpinLock(); + HalpAcquireCmosSpinLock(); /* Query the current value */ Val = HalpReadCmos(RTC_REGISTER_B) & 0x01; @@ -220,7 +220,7 @@ HalSetEnvironmentVariable(IN PCH Name, if (!_stricmp(Value, "TRUE")) { /* It's true, acquire CMOS lock */ - HalpAcquireSystemHardwareSpinLock(); + HalpAcquireCmosSpinLock(); /* Read the current value and add the flag */ Val = HalpReadCmos(RTC_REGISTER_B) | 1; @@ -228,7 +228,7 @@ HalSetEnvironmentVariable(IN PCH Name, else if (!_stricmp(Value, "FALSE")) { /* It's false, acquire CMOS lock */ - HalpAcquireSystemHardwareSpinLock(); + HalpAcquireCmosSpinLock(); /* Read the current value and mask out the flag */ Val = HalpReadCmos(RTC_REGISTER_B) & ~1; @@ -255,7 +255,7 @@ NTAPI HalQueryRealTimeClock(OUT PTIME_FIELDS Time) { /* Acquire CMOS Lock */ - HalpAcquireSystemHardwareSpinLock(); + HalpAcquireCmosSpinLock(); /* Loop while update is in progress */ while ((HalpReadCmos(RTC_REGISTER_A)) & RTC_REG_A_UIP); @@ -290,7 +290,7 @@ NTAPI HalSetRealTimeClock(IN PTIME_FIELDS Time) { /* Acquire CMOS Lock */ - HalpAcquireSystemHardwareSpinLock(); + HalpAcquireCmosSpinLock(); /* Loop while update is in progress */ while ((HalpReadCmos(RTC_REGISTER_A)) & RTC_REG_A_UIP); diff --git a/reactos/hal/halx86/generic/profil.c b/reactos/hal/halx86/generic/profil.c index b145942d9ab..186d009b869 100644 --- a/reactos/hal/halx86/generic/profil.c +++ b/reactos/hal/halx86/generic/profil.c @@ -25,7 +25,7 @@ HalStopProfileInterrupt(IN KPROFILE_SOURCE ProfileSource) UCHAR StatusB; /* Acquire the CMOS lock */ - HalpAcquireSystemHardwareSpinLock(); + HalpAcquireCmosSpinLock(); /* Read Status Register B */ StatusB = HalpReadCmos(RTC_REGISTER_B); diff --git a/reactos/hal/halx86/generic/reboot.c b/reactos/hal/halx86/generic/reboot.c index c7eda5e96c1..068cc17a8af 100644 --- a/reactos/hal/halx86/generic/reboot.c +++ b/reactos/hal/halx86/generic/reboot.c @@ -50,7 +50,7 @@ HalpReboot(VOID) ((PUSHORT)ZeroPageMapping)[0x239] = 0x1234; /* Lock CMOS Access (and disable interrupts) */ - HalpAcquireSystemHardwareSpinLock(); + HalpAcquireCmosSpinLock(); /* Setup control register B */ WRITE_PORT_UCHAR((PUCHAR)0x70, 0x0B); diff --git a/reactos/hal/halx86/generic/spinlock.c b/reactos/hal/halx86/generic/spinlock.c index c397bf09598..554e85f59dc 100644 --- a/reactos/hal/halx86/generic/spinlock.c +++ b/reactos/hal/halx86/generic/spinlock.c @@ -224,7 +224,7 @@ KeTryToAcquireQueuedSpinLock(IN KSPIN_LOCK_QUEUE_NUMBER LockNumber, VOID NTAPI -HalpAcquireSystemHardwareSpinLock(VOID) +HalpAcquireCmosSpinLock(VOID) { ULONG Flags; diff --git a/reactos/hal/halx86/generic/systimer.S b/reactos/hal/halx86/generic/systimer.S index 5e76763e3ef..d3caa478fee 100644 --- a/reactos/hal/halx86/generic/systimer.S +++ b/reactos/hal/halx86/generic/systimer.S @@ -11,7 +11,7 @@ #include -EXTERN _HalpAcquireSystemHardwareSpinLock@0:PROC +EXTERN _HalpAcquireCmosSpinLock@0:PROC EXTERN _HalpReleaseCmosSpinLock@0:PROC EXTERN _DbgBreakPoint@0:PROC @@ -98,7 +98,7 @@ _HalpCalibrateStallExecution@0: mov dword ptr [ebp-12], 0 /* Acquire CMOS lock */ - call _HalpAcquireSystemHardwareSpinLock@0 + call _HalpAcquireCmosSpinLock@0 /* Now initialize register A on the CMOS */ mov ax, HEX(2D00) OR CMOS_REGISTER_A @@ -186,7 +186,7 @@ OnlyOnePersonCanWriteHalCode: push offset Looper /* Acquire CMOS lock */ - call _HalpAcquireSystemHardwareSpinLock@0 + call _HalpAcquireCmosSpinLock@0 /* Now initialize register A on the CMOS */ mov ax, HEX(2D00) OR CMOS_REGISTER_A @@ -271,7 +271,7 @@ FoundFactor: mov eax, HEX(13) /* Acquire CMOS lock */ - call _HalpAcquireSystemHardwareSpinLock@0 + call _HalpAcquireCmosSpinLock@0 /* Now initialize register A on the CMOS */ mov ax, HEX(2D00) OR CMOS_REGISTER_A diff --git a/reactos/hal/halx86/include/halp.h b/reactos/hal/halx86/include/halp.h index a4c58c09202..9e9e4c4f714 100644 --- a/reactos/hal/halx86/include/halp.h +++ b/reactos/hal/halx86/include/halp.h @@ -722,7 +722,7 @@ HalpWriteCmos( // VOID NTAPI -HalpAcquireSystemHardwareSpinLock( +HalpAcquireCmosSpinLock( VOID ); From 6c556c3422b8bf8988b502691966b46763a28ef5 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Wed, 7 Sep 2011 12:00:29 +0000 Subject: [PATCH 42/55] [HAL] - move v86 code out of trap.S into v86.S (APIC uses a different trap entry file), compile it directly in the dll instead of a lib to be able to silence linker warnings - Group files in HAL_PIC_SOURCE and HAL_APIC_SOURCE, you just need to replace PIC with APIC to build the hal with APIC support (we can later use it to build the other hals: halapic, halaacpi, halmacpi, halmps) - use apic on amd64 builds - give halacpi its own resource file - silence MSVC linker warnings svn path=/trunk/; revision=53616 --- reactos/hal/halx86/CMakeLists.txt | 56 ++++++++++++++++++--------- reactos/hal/halx86/acpi/halacpi.rc | 5 +++ reactos/hal/halx86/generic/trap.S | 24 ------------ reactos/hal/halx86/generic/v86.S | 41 ++++++++++++++++++++ reactos/hal/halx86/hal_generic.rbuild | 1 + 5 files changed, 84 insertions(+), 43 deletions(-) create mode 100644 reactos/hal/halx86/acpi/halacpi.rc create mode 100644 reactos/hal/halx86/generic/v86.S diff --git a/reactos/hal/halx86/CMakeLists.txt b/reactos/hal/halx86/CMakeLists.txt index cd51150028b..c15d4858b35 100644 --- a/reactos/hal/halx86/CMakeLists.txt +++ b/reactos/hal/halx86/CMakeLists.txt @@ -15,7 +15,6 @@ list(APPEND HAL_GENERIC_SOURCE generic/drive.c generic/memory.c generic/misc.c - generic/profil.c generic/reboot.c generic/sysinfo.c generic/usage.c) @@ -23,10 +22,7 @@ list(APPEND HAL_GENERIC_SOURCE if(ARCH MATCHES i386) list(APPEND HAL_GENERIC_SOURCE generic/bios.c - generic/timer.c - generic/portio.c - generic/systimer.S - generic/trap.S) + generic/portio.c) endif() add_library(lib_hal_generic ${HAL_GENERIC_SOURCE}) @@ -58,11 +54,28 @@ add_library(lib_hal_acpi ${HAL_ACPI_SOURCE}) #add_pch(lib_hal_acpi include/hal.h) target_link_libraries(lib_hal_acpi lib_hal_generic) -if(ARCH MATCHES i386) - list(APPEND HAL_UP_SOURCE - up/pic.c - up/processor.c) +list(APPEND HAL_UP_SOURCE + generic/spinlock.c + generic/halinit.c + up/halinit_up.c + up/processor.c) +list(APPEND HAL_PIC_SOURCE + generic/profil.c + generic/timer.c + generic/systimer.S + generic/trap.S + up/pic.c) + +list(APPEND HAL_APIC_SOURCE + apic/apic.c + apic/apictimer.c + apic/apictrap.S + apic/rtctimer.c + apic/tsc.c + apic/tsccal.S) + +if(ARCH MATCHES i386) list(APPEND MINI_HAL_SOURCE generic/portio.c generic/systimer.S @@ -94,10 +107,9 @@ if(ARCH MATCHES i386) # hal add_library(hal SHARED ${HAL_UP_SOURCE} - up/halinit_up.c + ${HAL_PIC_SOURCE} + generic/v86.S up/halup.rc - generic/spinlock.c - generic/halinit.c ${CMAKE_CURRENT_BINARY_DIR}/hal.def) target_link_libraries(hal lib_hal_generic lib_hal_legacy libcntpr) add_importlibs(hal ntoskrnl) @@ -107,15 +119,17 @@ if(ARCH MATCHES i386) set_subsystem(hal native) set_image_base(hal 0x00010000) add_cd_file(TARGET hal DESTINATION reactos/system32 NO_CAB FOR all) + if(MSVC) + add_target_link_flags(hal "/ignore:4216 /ignore:4078") + endif() # hal acpi spec2def(halacpi.dll ../hal.spec halacpi) add_library(halacpi SHARED ${HAL_UP_SOURCE} - up/halinit_up.c - up/halup.rc - generic/spinlock.c - generic/halinit.c + ${HAL_PIC_SOURCE} + generic/v86.S + acpi/halacpi.rc ${CMAKE_CURRENT_BINARY_DIR}/halacpi.def) target_link_libraries(halacpi lib_hal_generic lib_hal_acpi libcntpr) add_importlibs(halacpi ntoskrnl) @@ -125,6 +139,9 @@ if(ARCH MATCHES i386) set_image_base(halacpi 0x00010000) set_property(TARGET halacpi PROPERTY COMPILE_DEFINITIONS CONFIG_ACPI) add_cd_file(TARGET halacpi DESTINATION reactos/system32 NO_CAB FOR all) + if(MSVC) + add_target_link_flags(halacpi "/ignore:4216 /ignore:4078") + endif() # mini_hal add_library(mini_hal ${MINI_HAL_SOURCE}) @@ -138,13 +155,11 @@ elseif(ARCH MATCHES amd64) list(APPEND HAL_SOURCE ${HAL_GENERIC_SOURCE} ${HAL_ACPI_SOURCE} - ${HAL_UP_SOURCE} + ${HAL_APIC_SOURCE} generic/spinlock.c generic/halinit.c amd64/x86bios.c amd64/halinit.c - amd64/stubs.c - amd64/systimer.S amd64/processor.c ${CMAKE_CURRENT_BINARY_DIR}/hal.def) @@ -158,6 +173,9 @@ elseif(ARCH MATCHES amd64) set_image_base(hal 0x00010000) add_importlibs(hal ntoskrnl) target_link_libraries(hal libcntpr) + if(MSVC) + add_target_link_flags(hal "/ignore:4216") + endif() add_cd_file(TARGET hal DESTINATION reactos/system32 NO_CAB FOR all) diff --git a/reactos/hal/halx86/acpi/halacpi.rc b/reactos/hal/halx86/acpi/halacpi.rc new file mode 100644 index 00000000000..bffe6347545 --- /dev/null +++ b/reactos/hal/halx86/acpi/halacpi.rc @@ -0,0 +1,5 @@ +#define REACTOS_VERSION_DLL +#define REACTOS_STR_FILE_DESCRIPTION "X86 Uniprocessor Hardware Abstraction Layer\0" +#define REACTOS_STR_INTERNAL_NAME "halacpi\0" +#define REACTOS_STR_ORIGINAL_FILENAME "halacpi.dll\0" +#include diff --git a/reactos/hal/halx86/generic/trap.S b/reactos/hal/halx86/generic/trap.S index d0e1c6cf1b5..89da49af68d 100644 --- a/reactos/hal/halx86/generic/trap.S +++ b/reactos/hal/halx86/generic/trap.S @@ -20,28 +20,4 @@ TRAP_ENTRY HalpApcInterrupt, KI_SOFTWARE_TRAP TRAP_ENTRY HalpClockInterrupt, KI_PUSH_FAKE_ERROR_CODE TRAP_ENTRY HalpProfileInterrupt, KI_PUSH_FAKE_ERROR_CODE -PUBLIC @HalpExitToV86@4 -@HalpExitToV86@4: - /* Point esp to the iret frame and return */ - lea esp, [ecx + KTRAP_FRAME_EIP] - iretd - -/* Here starts the real mode code */ -.code16 -PUBLIC _HalpRealModeStart -_HalpRealModeStart: - /* INT 0x10: AH = 0 (Set video Mode), AL = 0x12 (Mode 12) */ - mov eax, HEX(12) - int HEX(10) - - /* BOP */ - .byte HEX(C4), HEX(C4) - -/* The real mode stack */ -.align 4 -.space 2048 -_HalpRealModeEnd: -PUBLIC _HalpRealModeEnd -.endcode16 - END diff --git a/reactos/hal/halx86/generic/v86.S b/reactos/hal/halx86/generic/v86.S new file mode 100644 index 00000000000..aa059b6fd09 --- /dev/null +++ b/reactos/hal/halx86/generic/v86.S @@ -0,0 +1,41 @@ +/* + * FILE: hal/halx86/generic/v86.S + * COPYRIGHT: See COPYING in the top level directory + * PURPOSE: System Traps, Entrypoints and Exitpoints + * PROGRAMMER: Timo Kreuzer (timo.kreuzer@reactos.org) + * NOTE: See asmmacro.S for the shared entry/exit code. + */ + +/* INCLUDES ******************************************************************/ + +#include + +#include + +.code + +PUBLIC @HalpExitToV86@4 +@HalpExitToV86@4: + /* Point esp to the iret frame and return */ + lea esp, [ecx + KTRAP_FRAME_EIP] + iretd + +/* Here starts the real mode code */ +.code16 +PUBLIC _HalpRealModeStart +_HalpRealModeStart: + /* INT 0x10: AH = 0 (Set video Mode), AL = 0x12 (Mode 12) */ + mov eax, HEX(12) + int HEX(10) + + /* BOP */ + .byte HEX(C4), HEX(C4) + +/* The real mode stack */ +.align 4 +.space 2048 +_HalpRealModeEnd: +PUBLIC _HalpRealModeEnd +.endcode16 + +END diff --git a/reactos/hal/halx86/hal_generic.rbuild b/reactos/hal/halx86/hal_generic.rbuild index 4df6fa48866..9ee9a425e11 100644 --- a/reactos/hal/halx86/hal_generic.rbuild +++ b/reactos/hal/halx86/hal_generic.rbuild @@ -24,6 +24,7 @@ portio.c systimer.S trap.S + v86.S From 7c062d812ba3dfd8feef350b7cd973d7d2d0dfd0 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Wed, 7 Sep 2011 13:43:54 +0000 Subject: [PATCH 43/55] [NTOSKRNL] Make KeNumberProcessors internally an UCHAR and move it into krnlinit.c instead of having it once per architecture. Fixes a bunch of MSVC warnings. svn path=/trunk/; revision=53618 --- reactos/ntoskrnl/include/ntoskrnl.h | 2 + reactos/ntoskrnl/ke/amd64/cpu.c | 1 - reactos/ntoskrnl/ke/arm/cpu.c | 1 - reactos/ntoskrnl/ke/i386/cpu.c | 109 ++++++++++++++-------------- reactos/ntoskrnl/ke/powerpc/cpu.c | 1 - reactos/ntoskrnl/ntoskrnl.pspec | 2 +- reactos/ntoskrnl/ntoskrnl.spec | 2 +- 7 files changed, 58 insertions(+), 60 deletions(-) diff --git a/reactos/ntoskrnl/include/ntoskrnl.h b/reactos/ntoskrnl/include/ntoskrnl.h index 21e1a0e1be1..08fae623c2b 100644 --- a/reactos/ntoskrnl/include/ntoskrnl.h +++ b/reactos/ntoskrnl/include/ntoskrnl.h @@ -106,6 +106,8 @@ #define KdDebuggerNotPresent _KdDebuggerNotPresent #define NlsOemLeadByteInfo _NlsOemLeadByteInfo extern PUSHORT _NlsOemLeadByteInfo; +#define KeNumberProcessors _KeNumberProcessors +extern UCHAR _KeNumberProcessors; #define FsRtlLegalAnsiCharacterArray _FsRtlLegalAnsiCharacterArray #undef LEGAL_ANSI_CHARACTER_ARRAY #undef NLS_MB_CODE_PAGE_TAG diff --git a/reactos/ntoskrnl/ke/amd64/cpu.c b/reactos/ntoskrnl/ke/amd64/cpu.c index b667e8bd764..cb8299e70b2 100644 --- a/reactos/ntoskrnl/ke/amd64/cpu.c +++ b/reactos/ntoskrnl/ke/amd64/cpu.c @@ -35,7 +35,6 @@ ULONG KeI386MachineType; ULONG KeI386NpxPresent = 1; ULONG KeLargestCacheLine = 0x40; ULONG KiDmaIoCoherency = 0; -CHAR KeNumberProcessors = 0; KAFFINITY KeActiveProcessors = 1; BOOLEAN KiSMTProcessorsPresent; diff --git a/reactos/ntoskrnl/ke/arm/cpu.c b/reactos/ntoskrnl/ke/arm/cpu.c index 5b458517cf1..df475401d6a 100644 --- a/reactos/ntoskrnl/ke/arm/cpu.c +++ b/reactos/ntoskrnl/ke/arm/cpu.c @@ -17,7 +17,6 @@ ULONG KeFixedTbEntries; ULONG KiDmaIoCoherency; ULONG KeIcacheFlushCount = 0; -CCHAR KeNumberProcessors; ULONG KeDcacheFlushCount; ULONG KeActiveProcessors; ULONG KeProcessorArchitecture; diff --git a/reactos/ntoskrnl/ke/i386/cpu.c b/reactos/ntoskrnl/ke/i386/cpu.c index 74c1043fe0a..5404fcdee3a 100644 --- a/reactos/ntoskrnl/ke/i386/cpu.c +++ b/reactos/ntoskrnl/ke/i386/cpu.c @@ -41,7 +41,6 @@ ULONG KeDcacheFlushCount = 0; ULONG KeIcacheFlushCount = 0; ULONG KiDmaIoCoherency = 0; ULONG KePrefetchNTAGranularity = 32; -CHAR KeNumberProcessors = 0; KAFFINITY KeActiveProcessors = 1; BOOLEAN KiI386PentiumLockErrataPresent; BOOLEAN KiSMTProcessorsPresent; @@ -587,7 +586,7 @@ KiGetCacheInformation(VOID) /* Compute associativity */ Associativity = 4; if (RegisterByte >= 0x79) Associativity = 8; - + /* Mask out only the first nibble */ RegisterByte &= 0x07; @@ -605,7 +604,7 @@ KiGetCacheInformation(VOID) { /* Set minimum cache line size */ if (CacheLine < 128) CacheLine = 128; - + /* Hard-code size/associativity */ Associativity = 8; switch (RegisterByte) @@ -614,24 +613,24 @@ KiGetCacheInformation(VOID) Size = 512 * 1024; Associativity = 4; break; - + case 0x23: Size = 1024 * 1024; break; - + case 0x25: Size = 2048 * 1024; break; - + case 0x29: Size = 4096 * 1024; break; - + default: Size = 0; break; } - + /* Check if this cache is bigger than the last */ if ((Size / Associativity) > CurrentSize) { @@ -661,7 +660,7 @@ KiGetCacheInformation(VOID) { /* Set minimum cache line size */ if (CacheLine < 64) CacheLine = 64; - + /* Hard-code size/associativity */ switch (RegisterByte) { @@ -669,37 +668,37 @@ KiGetCacheInformation(VOID) Size = 4 * 1024 * 1024; Associativity = 8; break; - + case 0x4B: Size = 6 * 1024 * 1024; Associativity = 12; break; - + case 0x4C: Size = 8 * 1024 * 1024; Associativity = 16; break; - + case 0x78: Size = 1 * 1024 * 1024; Associativity = 4; break; - + case 0x7D: Size = 2 * 1024 * 1024; Associativity = 8; break; - + case 0x7F: Size = 512 * 1024; Associativity = 2; break; - + case 0x86: Size = 512 * 1024; Associativity = 4; break; - + case 0x87: Size = 1 * 1024 * 1024; Associativity = 8; @@ -709,7 +708,7 @@ KiGetCacheInformation(VOID) Size = 0; break; } - + /* Check if this cache is bigger than the last */ if ((Size / Associativity) > CurrentSize) { @@ -734,17 +733,17 @@ KiGetCacheInformation(VOID) /* Get L1 size first */ CPUID(0x80000005, &Data[0], &Data[1], &Data[2], &Data[3]); KePrefetchNTAGranularity = Data[2] & 0xFF; - + /* Check if we support CPUID 0x80000006 */ CPUID(0x80000000, &Data[0], &Data[1], &Data[2], &Data[3]); if (Data[0] >= 0x80000006) { /* Get 2nd level cache and tlb size */ CPUID(0x80000006, &Data[0], &Data[1], &Data[2], &Data[3]); - + /* Cache line size */ CacheLine = Data[2] & 0xFF; - + /* Hardcode associativity */ RegisterByte = Data[2] >> 12; switch (RegisterByte) @@ -752,28 +751,28 @@ KiGetCacheInformation(VOID) case 2: Associativity = 2; break; - + case 4: Associativity = 4; break; - + case 6: Associativity = 8; break; - + case 8: case 15: Associativity = 16; break; - + default: Associativity = 1; break; } - + /* Compute size */ Size = (Data[2] >> 16) << 10; - + /* Hack for Model 6, Steping 300 */ if ((KeGetCurrentPrcb()->CpuType == 6) && (KeGetCurrentPrcb()->CpuStep == 0x300)) @@ -797,7 +796,7 @@ KiGetCacheInformation(VOID) /* FIXME */ break; } - + /* Set the cache line */ if (CacheLine > KeLargestCacheLine) KeLargestCacheLine = CacheLine; DPRINT1("Prefetch Cache: %d bytes\tL2 Cache: %d bytes\tL2 Cache Line: %d bytes\tL2 Cache Associativity: %d\n", @@ -1221,13 +1220,13 @@ KiIsNpxPresent(VOID) { ULONG Cr0; USHORT Magic; - + /* Set magic */ Magic = 0xFFFF; - + /* Read CR0 and mask out FPU flags */ Cr0 = __readcr0() & ~(CR0_MP | CR0_TS | CR0_EM | CR0_ET); - + /* Store on FPU stack */ #ifdef _MSC_VER __asm fninit; @@ -1235,7 +1234,7 @@ KiIsNpxPresent(VOID) #else asm volatile ("fninit;" "fnstsw %0" : "+m"(Magic)); #endif - + /* Magic should now be cleared */ if (Magic & 0xFF) { @@ -1243,13 +1242,13 @@ KiIsNpxPresent(VOID) __writecr0(Cr0 | CR0_EM | CR0_TS); return FALSE; } - + /* You have an FPU, enable it */ Cr0 |= CR0_ET; - + /* Enable INT 16 on 486 and higher */ if (KeGetCurrentPrcb()->CpuType >= 3) Cr0 |= CR0_NE; - + /* Set FPU state */ __writecr0(Cr0 | CR0_EM | CR0_TS); return TRUE; @@ -1263,28 +1262,28 @@ KiIsNpxErrataPresent(VOID) BOOLEAN ErrataPresent; ULONG Cr0; volatile double Value1, Value2; - + /* Disable interrupts */ _disable(); - + /* Read CR0 and remove FPU flags */ Cr0 = __readcr0(); __writecr0(Cr0 & ~(CR0_MP | CR0_TS | CR0_EM)); - + /* Initialize FPU state */ Ke386FnInit(); - + /* Multiply the magic values and divide, we should get the result back */ Value1 = 4195835.0; Value2 = 3145727.0; ErrataPresent = (Value1 * Value2 / 3145727.0) != 4195835.0; - + /* Restore CR0 */ __writecr0(Cr0); - + /* Enable interrupts */ _enable(); - + /* Return if there's an errata */ return ErrataPresent; } @@ -1296,23 +1295,23 @@ KiFlushNPXState(IN PFLOATING_SAVE_AREA SaveArea) ULONG EFlags, Cr0; PKTHREAD Thread, NpxThread; PFX_SAVE_AREA FxSaveArea; - + /* Save volatiles and disable interrupts */ EFlags = __readeflags(); _disable(); - + /* Save the PCR and get the current thread */ Thread = KeGetCurrentThread(); - + /* Check if we're already loaded */ if (Thread->NpxState != NPX_STATE_LOADED) { /* If there's nothing to load, quit */ if (!SaveArea) return; - + /* Need FXSR support for this */ ASSERT(KeI386FxsrPresent == TRUE); - + /* Check for sane CR0 */ Cr0 = __readcr0(); if (Cr0 & (CR0_MP | CR0_TS | CR0_EM)) @@ -1320,7 +1319,7 @@ KiFlushNPXState(IN PFLOATING_SAVE_AREA SaveArea) /* Mask out FPU flags */ __writecr0(Cr0 & ~(CR0_MP | CR0_TS | CR0_EM)); } - + /* Get the NPX thread and check its FPU state */ NpxThread = KeGetCurrentPrcb()->NpxThread; if ((NpxThread) && (NpxThread->NpxState == NPX_STATE_LOADED)) @@ -1328,11 +1327,11 @@ KiFlushNPXState(IN PFLOATING_SAVE_AREA SaveArea) /* Get the FX frame and store the state there */ FxSaveArea = KiGetThreadNpxArea(NpxThread); Ke386FxSave(FxSaveArea); - + /* NPX thread has lost its state */ NpxThread->NpxState = NPX_STATE_NOT_LOADED; } - + /* Now load NPX state from the NPX area */ FxSaveArea = KiGetThreadNpxArea(Thread); Ke386FxStore(FxSaveArea); @@ -1346,11 +1345,11 @@ KiFlushNPXState(IN PFLOATING_SAVE_AREA SaveArea) /* Mask out FPU flags */ __writecr0(Cr0 & ~(CR0_MP | CR0_TS | CR0_EM)); } - + /* Get FX frame */ FxSaveArea = KiGetThreadNpxArea(Thread); Thread->NpxState = NPX_STATE_NOT_LOADED; - + /* Save state if supported by CPU */ if (KeI386FxsrPresent) Ke386FxSave(FxSaveArea); } @@ -1360,12 +1359,12 @@ KiFlushNPXState(IN PFLOATING_SAVE_AREA SaveArea) /* Clear NPX thread */ KeGetCurrentPrcb()->NpxThread = NULL; - + /* Add the CR0 from the NPX frame */ Cr0 |= NPX_STATE_NOT_LOADED; Cr0 |= FxSaveArea->Cr0NpxState; __writecr0(Cr0); - + /* Restore interrupt state */ __writeeflags(EFlags); } @@ -1380,10 +1379,10 @@ NTAPI KiCoprocessorError(VOID) { PFX_SAVE_AREA NpxArea; - + /* Get the FPU area */ NpxArea = KiGetThreadNpxArea(KeGetCurrentThread()); - + /* Set CR0_TS */ NpxArea->Cr0NpxState = CR0_TS; __writecr0(__readcr0() | CR0_TS); diff --git a/reactos/ntoskrnl/ke/powerpc/cpu.c b/reactos/ntoskrnl/ke/powerpc/cpu.c index 3c555fa8191..8b98a3d8fe6 100644 --- a/reactos/ntoskrnl/ke/powerpc/cpu.c +++ b/reactos/ntoskrnl/ke/powerpc/cpu.c @@ -23,7 +23,6 @@ ULONG KeLargestCacheLine = 0x40; ULONG KeDcacheFlushCount = 0; ULONG KeIcacheFlushCount = 0; ULONG KiDmaIoCoherency = 0; -CHAR KeNumberProcessors; KAFFINITY KeActiveProcessors = 1; BOOLEAN KiSMTProcessorsPresent; diff --git a/reactos/ntoskrnl/ntoskrnl.pspec b/reactos/ntoskrnl/ntoskrnl.pspec index c0fb6011e7e..9a2c0ea1e3d 100644 --- a/reactos/ntoskrnl/ntoskrnl.pspec +++ b/reactos/ntoskrnl/ntoskrnl.pspec @@ -645,7 +645,7 @@ @ stdcall KeLeaveCriticalRegion() _KeLeaveCriticalRegion @ stdcall KeLeaveGuardedRegion() _KeLeaveGuardedRegion @ extern KeLoaderBlock -@ extern KeNumberProcessors +@ extern KeNumberProcessors _KeNumberProcessors @ stdcall KeProfileInterrupt(ptr) @ stdcall KeProfileInterruptWithSource(ptr long) @ stdcall KePulseEvent(ptr long long) diff --git a/reactos/ntoskrnl/ntoskrnl.spec b/reactos/ntoskrnl/ntoskrnl.spec index 9499cb8b61e..762b0efaa23 100644 --- a/reactos/ntoskrnl/ntoskrnl.spec +++ b/reactos/ntoskrnl/ntoskrnl.spec @@ -628,7 +628,7 @@ @ stdcall KeLeaveGuardedRegion() _KeLeaveGuardedRegion @ extern KeLoaderBlock @ cdecl -arch=x86_64 KeLowerIrql(long) -@ extern KeNumberProcessors +@ extern KeNumberProcessors _KeNumberProcessors @ stdcall -arch=i386,arm KeProfileInterrupt(ptr) @ stdcall KeProfileInterruptWithSource(ptr long) @ stdcall KePulseEvent(ptr long long) From 1799be4f5f6d4edf31de703a23ca0385bb0e748c Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Wed, 7 Sep 2011 13:45:06 +0000 Subject: [PATCH 44/55] [NTOSKRNL] Forgot this file, sorry svn path=/trunk/; revision=53619 --- reactos/ntoskrnl/ke/krnlinit.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/reactos/ntoskrnl/ke/krnlinit.c b/reactos/ntoskrnl/ke/krnlinit.c index d22fe7e2fd8..3a1bdb3c66b 100644 --- a/reactos/ntoskrnl/ke/krnlinit.c +++ b/reactos/ntoskrnl/ke/krnlinit.c @@ -24,6 +24,9 @@ PLOADER_PARAMETER_BLOCK KeLoaderBlock; /* PRCB Array */ PKPRCB KiProcessorBlock[MAXIMUM_PROCESSORS]; +/* Number of processors */ +UCHAR KeNumberProcessors = 0; + /* NUMA Node Support */ KNODE KiNode0; PKNODE KeNodeBlock[1]; From 622fc9501cdc40ee981a48be30ad25c4445b1b8e Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Wed, 7 Sep 2011 13:58:34 +0000 Subject: [PATCH 45/55] [NTOSKRNL] Move the internal headers below the redefinition of types, because gcc instantiates inline function where they are defined, using the original types. Fixes build. svn path=/trunk/; revision=53620 --- reactos/ntoskrnl/include/ntoskrnl.h | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/reactos/ntoskrnl/include/ntoskrnl.h b/reactos/ntoskrnl/include/ntoskrnl.h index 08fae623c2b..4af4b96fd39 100644 --- a/reactos/ntoskrnl/include/ntoskrnl.h +++ b/reactos/ntoskrnl/include/ntoskrnl.h @@ -86,14 +86,6 @@ /* PNP GUIDs */ #include -/* Internal Headers */ -#include "internal/ntoskrnl.h" -#include "config.h" - -#include -#include "internal/probe.h" -#include "resource.h" - // // Define the internal versions of external and public global data // @@ -123,3 +115,12 @@ extern UCHAR _KeNumberProcessors; #undef HALDISPATCH #define HALDISPATCH (&HalDispatchTable) #define ExRaiseStatus RtlRaiseStatus + +/* Internal Headers */ +#include "internal/ntoskrnl.h" +#include "config.h" + +#include +#include "internal/probe.h" +#include "resource.h" + From 2f5ccca6990aa7e10d94f5bc1e7da8afebe37c21 Mon Sep 17 00:00:00 2001 From: Giannis Adamopoulos Date: Wed, 7 Sep 2011 14:05:58 +0000 Subject: [PATCH 46/55] [user32_apitest] - Add a test case for SetActiveWindow that shows its behavior related to owner windows. It should point the bug observed in bug 1239 svn path=/trunk/; revision=53621 --- rostests/apitests/user32/CMakeLists.txt | 1 + rostests/apitests/user32/SetActiveWindow.c | 52 +++++++++++++++++++ rostests/apitests/user32/testlist.c | 2 + .../apitests/user32/user32_apitest.rbuild | 1 + 4 files changed, 56 insertions(+) create mode 100644 rostests/apitests/user32/SetActiveWindow.c diff --git a/rostests/apitests/user32/CMakeLists.txt b/rostests/apitests/user32/CMakeLists.txt index d57524afd53..9b3f4acdbfd 100644 --- a/rostests/apitests/user32/CMakeLists.txt +++ b/rostests/apitests/user32/CMakeLists.txt @@ -14,6 +14,7 @@ list(APPEND SOURCE ScrollDC.c ScrollWindowEx.c SetCursorPos.c + SetActiveWindow.c WndProc.c testlist.c user32_apitest.rc) diff --git a/rostests/apitests/user32/SetActiveWindow.c b/rostests/apitests/user32/SetActiveWindow.c new file mode 100644 index 00000000000..1f8aae2740e --- /dev/null +++ b/rostests/apitests/user32/SetActiveWindow.c @@ -0,0 +1,52 @@ +/* + * PROJECT: ReactOS api tests + * LICENSE: GPL - See COPYING in the top level directory + * PURPOSE: Test for SetActiveWindow + * PROGRAMMERS: Giannis Adamopoulos + */ + +#include +#include +#include + +void Test_SetActiveWindow() +{ + MSG msg; + HWND hWnd, hWnd1, hWnd2; + + hWnd = CreateWindowW(L"BUTTON", L"ownertest", WS_OVERLAPPEDWINDOW, + 20, 20, 300, 300, NULL, NULL, 0, NULL); + + hWnd1 = CreateWindowW(L"BUTTON", L"ownertest", WS_OVERLAPPEDWINDOW, + 20, 350, 300, 300, hWnd, NULL, 0, NULL); + + hWnd2 = CreateWindowW(L"BUTTON", L"ownertest", WS_OVERLAPPEDWINDOW, + 200, 200, 300, 300, NULL, NULL, 0, NULL); + + ShowWindow(hWnd, SW_SHOW); + UpdateWindow(hWnd); + ShowWindow(hWnd1, SW_SHOW); + UpdateWindow(hWnd1); + ShowWindow(hWnd2, SW_SHOW); + UpdateWindow(hWnd2); + + while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessageA( &msg ); + + ok(GetWindow(hWnd2,GW_HWNDNEXT) == hWnd1, "Expected %p after %p, not %p\n",hWnd1,hWnd2,GetWindow(hWnd2,GW_HWNDNEXT) ); + ok(GetWindow(hWnd1,GW_HWNDNEXT) == hWnd, "Expected %p after %p, not %p\n",hWnd,hWnd1,GetWindow(hWnd1,GW_HWNDNEXT)); + ok(GetActiveWindow() == hWnd2, "Expected %p to be the active window, not %p\n",hWnd2,GetActiveWindow()); + + SetActiveWindow(hWnd); + + while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessageA( &msg ); + + /* note: the owned is moved on top of the three windows */ + ok(GetActiveWindow() == hWnd, "Expected %p to be the active window, not %p\n",hWnd,GetActiveWindow()); + ok(GetWindow(hWnd1,GW_HWNDNEXT) == hWnd, "Expected %p after %p, not %p\n",hWnd,hWnd1,GetWindow(hWnd1,GW_HWNDNEXT) ); + ok(GetWindow(hWnd,GW_HWNDNEXT) == hWnd2, "Expected %p after %p, not %p\n",hWnd2,hWnd,GetWindow(hWnd,GW_HWNDNEXT) ); +} + +START_TEST(SetActiveWindow) +{ + Test_SetActiveWindow(); +} diff --git a/rostests/apitests/user32/testlist.c b/rostests/apitests/user32/testlist.c index fe27138d10b..51c4fce8244 100644 --- a/rostests/apitests/user32/testlist.c +++ b/rostests/apitests/user32/testlist.c @@ -15,6 +15,7 @@ extern void func_GetPeekMessage(void); extern void func_DeferWindowPos(void); extern void func_GetKeyState(void); extern void func_SetCursorPos(void); +extern void func_SetActiveWindow(void); extern void func_WndProc(void); const struct test winetest_testlist[] = @@ -29,6 +30,7 @@ const struct test winetest_testlist[] = { "DeferWindowPos", func_DeferWindowPos }, { "GetKeyState", func_GetKeyState }, { "SetCursorPos", func_SetCursorPos }, + { "SetActiveWindow", func_SetActiveWindow }, { "WndProc", func_WndProc }, { 0, 0 } }; diff --git a/rostests/apitests/user32/user32_apitest.rbuild b/rostests/apitests/user32/user32_apitest.rbuild index fdd83b50d76..cae3019caa8 100644 --- a/rostests/apitests/user32/user32_apitest.rbuild +++ b/rostests/apitests/user32/user32_apitest.rbuild @@ -19,6 +19,7 @@ GetIconInfo.c GetPeekMessage.c DeferWindowPos.c + SetActiveWindow.c SetCursorPos.c WndProc.c From f85bf4380d46788e608bd731e5a9b7db3e2e5e9e Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Wed, 7 Sep 2011 18:25:43 +0000 Subject: [PATCH 47/55] [HAL] - give apic hal its own halinit_apic - give minihal an own halinit_mini.c containing function stubs - move HalInitializeProcessor to halinit.c and add hal specific function HalpInitProcessor - get rid of all the #ifndef _MINIHAL_ in halinit.c and move the file to lib_hal_generic - improve the hal version/build check - Update spec file for amd64 svn path=/trunk/; revision=53625 --- reactos/hal/hal.spec | 17 ++++-- reactos/hal/halx86/CMakeLists.txt | 8 +-- reactos/hal/halx86/apic/halinit_apic.c | 53 ++++++++++++++++++ reactos/hal/halx86/generic/halinit.c | 75 +++++++++++--------------- reactos/hal/halx86/hal_mini.rbuild | 2 +- reactos/hal/halx86/include/halp.h | 16 ++++++ reactos/hal/halx86/up/halinit_mini.c | 75 ++++++++++++++++++++++++++ reactos/hal/halx86/up/halinit_up.c | 12 ++++- reactos/hal/halx86/up/processor.c | 20 ------- 9 files changed, 204 insertions(+), 74 deletions(-) create mode 100644 reactos/hal/halx86/apic/halinit_apic.c create mode 100644 reactos/hal/halx86/up/halinit_mini.c diff --git a/reactos/hal/hal.spec b/reactos/hal/hal.spec index a00171f61ec..7c8d8c8a458 100644 --- a/reactos/hal/hal.spec +++ b/reactos/hal/hal.spec @@ -27,12 +27,13 @@ @ stdcall HalAllocateCommonBuffer(ptr long ptr long) @ stdcall HalAllocateCrashDumpRegisters(ptr ptr) @ stdcall HalAssignSlotResources(ptr ptr ptr ptr long long long ptr) -@ stdcall HalBeginSystemInterrupt(long long ptr) +@ stdcall -arch=i386,arm HalBeginSystemInterrupt(long long ptr) @ stdcall HalCalibratePerformanceCounter(ptr long long) +;@ stdcall -arch=x86_64 HalCallBios() @ stdcall HalDisableSystemInterrupt(long long) @ stdcall HalDisplayString(str) @ stdcall HalEnableSystemInterrupt(long long long) -@ stdcall HalEndSystemInterrupt(long long) +@ stdcall -arch=i386,arm HalEndSystemInterrupt(long long) @ stdcall HalFlushCommonBuffer(long long long long long) @ stdcall HalFreeCommonBuffer(ptr long long long ptr long) @ stdcall HalGetAdapter(ptr ptr) @@ -41,18 +42,22 @@ @ stdcall HalGetEnvironmentVariable(str long str) @ fastcall -arch=arm HalGetInterruptSource() @ stdcall HalGetInterruptVector(long long long long ptr ptr) -@ stdcall -arch=i386 HalHandleNMI(ptr) +;@ stdcall -arch=x86_64 HalHandleMcheck() +@ stdcall -arch=i386,x86_64 HalHandleNMI(ptr) @ stdcall HalInitSystem(long ptr) @ stdcall HalInitializeProcessor(long ptr) +;@ stdcall -arch=x86_64 HalIsHyperThreadingEnabled() @ stdcall HalMakeBeep(long) @ stdcall HalProcessorIdle() -@ stdcall HalPutDmaAdapter(ptr) +@ stdcall -arch=i386 HalPutDmaAdapter(ptr) @ stdcall HalQueryDisplayParameters(ptr ptr ptr ptr) @ stdcall HalQueryRealTimeClock(ptr) @ stdcall HalReadDmaCounter(ptr) @ stdcall HalReportResourceUsage() @ stdcall HalRequestIpi(long) @ stdcall HalReturnToFirmware(long) +;@ stdcall -arch=x86_64 HalSendNMI() +;@ stdcall -arch=x86_64 HalSendSoftwareInterrupt() @ stdcall HalSetBusData(long long long ptr long) @ stdcall HalSetBusDataByOffset(long long long ptr long long) @ stdcall HalSetDisplayParameters(long long) @@ -65,6 +70,7 @@ @ stdcall HalStopProfileInterrupt(long) @ fastcall -arch=arm HalSweepIcache() @ fastcall -arch=arm HalSweepDcache() +;@ stdcall -arch=x86_64 HalSystemVectorDispatchEntry() @ stdcall HalTranslateBusAddress(long long long long ptr ptr) @ stdcall IoFlushAdapterBuffers(ptr ptr ptr ptr long long) @ stdcall IoFreeAdapterChannel(ptr) @@ -98,3 +104,6 @@ @ stdcall -arch=i386,arm WRITE_PORT_ULONG(ptr long) @ stdcall -arch=i386,arm WRITE_PORT_USHORT(ptr long) @ stdcall -arch=x86_64 HalInitializeBios(long ptr) +;@ stdcall -arch=x86_64 x86BiosExecuteInterrupt() +;@ stdcall -arch=x86_64 x86BiosInitializeBiosEx() +;@ stdcall -arch=x86_64 x86BiosTranslateAddress() diff --git a/reactos/hal/halx86/CMakeLists.txt b/reactos/hal/halx86/CMakeLists.txt index c15d4858b35..0f90d984826 100644 --- a/reactos/hal/halx86/CMakeLists.txt +++ b/reactos/hal/halx86/CMakeLists.txt @@ -13,6 +13,7 @@ list(APPEND HAL_GENERIC_SOURCE generic/display.c generic/dma.c generic/drive.c + generic/halinit.c generic/memory.c generic/misc.c generic/reboot.c @@ -56,8 +57,6 @@ target_link_libraries(lib_hal_acpi lib_hal_generic) list(APPEND HAL_UP_SOURCE generic/spinlock.c - generic/halinit.c - up/halinit_up.c up/processor.c) list(APPEND HAL_PIC_SOURCE @@ -65,12 +64,14 @@ list(APPEND HAL_PIC_SOURCE generic/timer.c generic/systimer.S generic/trap.S + up/halinit_up.c up/pic.c) list(APPEND HAL_APIC_SOURCE apic/apic.c apic/apictimer.c apic/apictrap.S + apic/halinit_apic.c apic/rtctimer.c apic/tsc.c apic/tsccal.S) @@ -98,7 +99,7 @@ if(ARCH MATCHES i386) generic/sysinfo.c generic/timer.c generic/usage.c - up/halinit_up.c + up/halinit_mini.c up/pic.c up/processor.c) @@ -157,7 +158,6 @@ elseif(ARCH MATCHES amd64) ${HAL_ACPI_SOURCE} ${HAL_APIC_SOURCE} generic/spinlock.c - generic/halinit.c amd64/x86bios.c amd64/halinit.c amd64/processor.c diff --git a/reactos/hal/halx86/apic/halinit_apic.c b/reactos/hal/halx86/apic/halinit_apic.c new file mode 100644 index 00000000000..2b37b570572 --- /dev/null +++ b/reactos/hal/halx86/apic/halinit_apic.c @@ -0,0 +1,53 @@ +/* $Id: halinit_up.c 53529 2011-09-02 14:45:19Z tkreuzer $ + * + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS kernel + * FILE: ntoskrnl/hal/x86/halinit.c + * PURPOSE: Initalize the x86 hal + * PROGRAMMER: David Welch (welch@cwcom.net) + * UPDATE HISTORY: + * 11/06/98: Created + */ + +/* INCLUDES *****************************************************************/ + +#include +#define NDEBUG +#include + +VOID +NTAPI +ApicInitializeLocalApic(ULONG Cpu); + +/* FUNCTIONS ***************************************************************/ + +VOID +NTAPI +HalpInitProcessor( + IN ULONG ProcessorNumber, + IN PLOADER_PARAMETER_BLOCK LoaderBlock) +{ + DPRINT1("ApicInitializeProcessor(%ld)\n", ProcessorNumber); + + /* Initialize the local APIC for this cpu */ + ApicInitializeLocalApic(ProcessorNumber); + + /* Initialize the timer */ + //ApicInitializeTimer(ProcessorNumber); + +} + +VOID +HalpInitPhase0(IN PLOADER_PARAMETER_BLOCK LoaderBlock) +{ + +} + +VOID +HalpInitPhase1(VOID) +{ + /* Initialize DMA. NT does this in Phase 0 */ + HalpInitDma(); +} + +/* EOF */ diff --git a/reactos/hal/halx86/generic/halinit.c b/reactos/hal/halx86/generic/halinit.c index 83eaad81bda..850eab1f216 100644 --- a/reactos/hal/halx86/generic/halinit.c +++ b/reactos/hal/halx86/generic/halinit.c @@ -41,6 +41,27 @@ HalpGetParameters(IN PLOADER_PARAMETER_BLOCK LoaderBlock) /* FUNCTIONS *****************************************************************/ +VOID +NTAPI +HalInitializeProcessor( + IN ULONG ProcessorNumber, + IN PLOADER_PARAMETER_BLOCK LoaderBlock) +{ + /* Hal specific initialization for this cpu */ + HalpInitProcessor(ProcessorNumber, LoaderBlock); + + /* Set default stall count */ + KeGetPcr()->StallScaleFactor = INITIAL_STALL_COUNT; + + /* Update the interrupt affinity and processor mask */ + InterlockedBitTestAndSet((PLONG)&HalpActiveProcessors, ProcessorNumber); + InterlockedBitTestAndSet((PLONG)&HalpDefaultInterruptAffinity, + ProcessorNumber); + + /* Register routines for KDCOM */ + HalpRegisterKdSupportFunctions(); +} + /* * @implemented */ @@ -61,48 +82,25 @@ HalInitSystem(IN ULONG BootPhase, /* Get command-line parameters */ HalpGetParameters(LoaderBlock); - /* Checked HAL requires checked kernel */ -#if DBG - if (!(Prcb->BuildType & PRCB_BUILD_DEBUG)) - { - /* No match, bugcheck */ - KeBugCheckEx(MISMATCHED_HAL, 2, Prcb->BuildType, 1, 0); - } -#else - /* Release build requires release HAL */ - if (Prcb->BuildType & PRCB_BUILD_DEBUG) - { - /* No match, bugcheck */ - KeBugCheckEx(MISMATCHED_HAL, 2, Prcb->BuildType, 0, 0); - } -#endif - -#ifdef CONFIG_SMP - /* SMP HAL requires SMP kernel */ - if (Prcb->BuildType & PRCB_BUILD_UNIPROCESSOR) - { - /* No match, bugcheck */ - KeBugCheckEx(MISMATCHED_HAL, 2, Prcb->BuildType, 0, 0); - } -#endif - - /* Validate the PRCB */ + /* Check for PRCB version mismatch */ if (Prcb->MajorVersion != PRCB_MAJOR_VERSION) { - /* Validation failed, bugcheck */ - KeBugCheckEx(MISMATCHED_HAL, 1, Prcb->MajorVersion, 1, 0); + /* No match, bugcheck */ + KeBugCheckEx(MISMATCHED_HAL, 1, Prcb->MajorVersion, PRCB_MAJOR_VERSION, 0); + } + + /* Checked/free HAL requires checked/free kernel */ + if (Prcb->BuildType != HAL_BUILD_TYPE) + { + /* No match, bugcheck */ + KeBugCheckEx(MISMATCHED_HAL, 2, Prcb->BuildType, HAL_BUILD_TYPE, 0); } -#ifndef _MINIHAL_ /* Initialize ACPI */ HalpSetupAcpiPhase0(LoaderBlock); /* Initialize the PICs */ HalpInitializePICs(TRUE); -#endif - - /* Force initial PIC state */ - KfRaiseIrql(KeGetCurrentIrql()); /* Initialize CMOS lock */ KeInitializeSpinLock(&HalpSystemHardwareLock); @@ -114,17 +112,10 @@ HalInitSystem(IN ULONG BootPhase, HalQuerySystemInformation = HaliQuerySystemInformation; HalSetSystemInformation = HaliSetSystemInformation; HalInitPnpDriver = HaliInitPnpDriver; -#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 */ @@ -140,10 +131,8 @@ HalInitSystem(IN ULONG BootPhase, /* Setup busy waiting */ HalpCalibrateStallExecution(); -#ifndef _MINIHAL_ /* Initialize the clock */ HalpInitializeClock(); -#endif /* * We could be rebooting with a pending profile interrupt, diff --git a/reactos/hal/halx86/hal_mini.rbuild b/reactos/hal/halx86/hal_mini.rbuild index 41b76bb47a3..8b69104b369 100644 --- a/reactos/hal/halx86/hal_mini.rbuild +++ b/reactos/hal/halx86/hal_mini.rbuild @@ -36,7 +36,7 @@ bussupp.c - halinit_up.c + halinit_mini.c pic.c processor.c diff --git a/reactos/hal/halx86/include/halp.h b/reactos/hal/halx86/include/halp.h index 9e9e4c4f714..bf4d0e571a4 100644 --- a/reactos/hal/halx86/include/halp.h +++ b/reactos/hal/halx86/include/halp.h @@ -21,6 +21,12 @@ #define REGISTERCALL __attribute__((regparm(3))) #endif +#ifdef CONFIG_SMP +#define HAL_BUILD_TYPE (DBG ? PRCB_BUILD_DEBUG : 0) +#else +#define HAL_BUILD_TYPE ((DBG ? PRCB_BUILD_DEBUG : 0) | PRCB_BUILD_UNIPROCESSOR) +#endif + typedef struct _HAL_BIOS_FRAME { ULONG SegSs; @@ -836,8 +842,18 @@ HalpDebugPciDumpBus( IN PPCI_COMMON_CONFIG PciData ); +VOID +NTAPI +HalpInitProcessor( + IN ULONG ProcessorNumber, + IN PLOADER_PARAMETER_BLOCK LoaderBlock +); + #ifdef _M_AMD64 #define KfLowerIrql KeLowerIrql +#define KiEnterInterruptTrap(TrapFrame) /* We do all neccessary in asm code */ +#define KiEoiHelper() return +#define HalBeginSystemInterrupt(Irql, Vector, OldIrql) TRUE #ifndef CONFIG_SMP /* On UP builds, spinlocks don't exist at IRQL >= DISPATCH */ #define KiAcquireSpinLock(SpinLock) diff --git a/reactos/hal/halx86/up/halinit_mini.c b/reactos/hal/halx86/up/halinit_mini.c new file mode 100644 index 00000000000..06b4e02091a --- /dev/null +++ b/reactos/hal/halx86/up/halinit_mini.c @@ -0,0 +1,75 @@ +/* $Id: halinit_up.c 53529 2011-09-02 14:45:19Z tkreuzer $ + * + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS kernel + * FILE: ntoskrnl/hal/x86/halinit.c + * PURPOSE: Initalize the x86 hal + * PROGRAMMER: David Welch (welch@cwcom.net) + * UPDATE HISTORY: + * 11/06/98: Created + */ + +/* INCLUDES *****************************************************************/ + +#include +#define NDEBUG +#include + +/* FUNCTIONS ***************************************************************/ + +VOID +NTAPI +HalpInitProcessor( + IN ULONG ProcessorNumber, + IN PLOADER_PARAMETER_BLOCK LoaderBlock) +{ +} + +VOID +HalpInitPhase0(IN PLOADER_PARAMETER_BLOCK LoaderBlock) +{ +} + +VOID +HalpInitPhase1(VOID) +{ +} + +NTSTATUS +NTAPI +HalpSetupAcpiPhase0(IN PLOADER_PARAMETER_BLOCK LoaderBlock) +{ + return STATUS_SUCCESS; +} + +VOID +NTAPI +HalpInitializePICs(IN BOOLEAN EnableInterrupts) +{ +} + +PDMA_ADAPTER +NTAPI +HalpGetDmaAdapter( + IN PVOID Context, + IN PDEVICE_DESCRIPTION DeviceDescription, + OUT PULONG NumberOfMapRegisters) +{ + return NULL; +} + +BOOLEAN +NTAPI +HalpBiosDisplayReset(VOID) +{ + return FALSE; +} + +VOID +NTAPI +INIT_FUNCTION +HalpInitializeClock(VOID) +{ +} + +/* EOF */ diff --git a/reactos/hal/halx86/up/halinit_up.c b/reactos/hal/halx86/up/halinit_up.c index 8a5649cc7a7..033ec0c3dfe 100644 --- a/reactos/hal/halx86/up/halinit_up.c +++ b/reactos/hal/halx86/up/halinit_up.c @@ -17,6 +17,16 @@ /* FUNCTIONS ***************************************************************/ +VOID +NTAPI +HalpInitProcessor( + IN ULONG ProcessorNumber, + IN PLOADER_PARAMETER_BLOCK LoaderBlock) +{ + /* Set default IDR */ + KeGetPcr()->IDR = 0xFFFFFFFB; +} + VOID HalpInitPhase0(IN PLOADER_PARAMETER_BLOCK LoaderBlock) { @@ -26,7 +36,6 @@ HalpInitPhase0(IN PLOADER_PARAMETER_BLOCK LoaderBlock) VOID HalpInitPhase1(VOID) { -#ifndef _MINIHAL_ /* Enable IRQ 0 */ HalpEnableInterruptHandler(IDT_DEVICE, 0, @@ -45,7 +54,6 @@ HalpInitPhase1(VOID) /* Initialize DMA. NT does this in Phase 0 */ HalpInitDma(); -#endif } /* EOF */ diff --git a/reactos/hal/halx86/up/processor.c b/reactos/hal/halx86/up/processor.c index 2e92a2c6c86..fbbe707c0d6 100644 --- a/reactos/hal/halx86/up/processor.c +++ b/reactos/hal/halx86/up/processor.c @@ -28,26 +28,6 @@ HaliHaltSystem(VOID) /* FUNCTIONS *****************************************************************/ -/* - * @implemented - */ -VOID -NTAPI -HalInitializeProcessor(IN ULONG ProcessorNumber, - IN PLOADER_PARAMETER_BLOCK LoaderBlock) -{ - /* Set default IDR and stall count */ - KeGetPcr()->IDR = 0xFFFFFFFB; - KeGetPcr()->StallScaleFactor = INITIAL_STALL_COUNT; - - /* Update the interrupt affinity and processor mask */ - InterlockedBitTestAndSet((PLONG)&HalpActiveProcessors, ProcessorNumber); - InterlockedBitTestAndSet((PLONG)&HalpDefaultInterruptAffinity, - ProcessorNumber); - - /* Register routines for KDCOM */ - HalpRegisterKdSupportFunctions(); -} /* * @implemented From d9ab860e67a974bc9550043397e756d7edf406a8 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Wed, 7 Sep 2011 18:30:38 +0000 Subject: [PATCH 48/55] [HAL] Fix buld. I swear it worked here! svn path=/trunk/; revision=53626 --- reactos/hal/halx86/up/halinit_mini.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/reactos/hal/halx86/up/halinit_mini.c b/reactos/hal/halx86/up/halinit_mini.c index 06b4e02091a..7b349e42c6e 100644 --- a/reactos/hal/halx86/up/halinit_mini.c +++ b/reactos/hal/halx86/up/halinit_mini.c @@ -65,11 +65,4 @@ HalpBiosDisplayReset(VOID) return FALSE; } -VOID -NTAPI -INIT_FUNCTION -HalpInitializeClock(VOID) -{ -} - /* EOF */ From d78423aadcfd8f54e67deff6de3171f520fd8ea4 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Wed, 7 Sep 2011 18:39:20 +0000 Subject: [PATCH 49/55] [HAL_XBOX] Fix build svn path=/trunk/; revision=53627 --- reactos/hal/halx86/xbox/halinit_xbox.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/reactos/hal/halx86/xbox/halinit_xbox.c b/reactos/hal/halx86/xbox/halinit_xbox.c index 28e3342c755..80f3cb6c94e 100644 --- a/reactos/hal/halx86/xbox/halinit_xbox.c +++ b/reactos/hal/halx86/xbox/halinit_xbox.c @@ -18,6 +18,16 @@ /* FUNCTIONS ***************************************************************/ +VOID +NTAPI +HalpInitProcessor( + IN ULONG ProcessorNumber, + IN PLOADER_PARAMETER_BLOCK LoaderBlock) +{ + /* Set default IDR */ + KeGetPcr()->IDR = 0xFFFFFFFB; +} + VOID HalpInitPhase0(PLOADER_PARAMETER_BLOCK LoaderBlock) { From 13f41d74b9df7e4a917c12cb278c3772e13ca18d Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Wed, 7 Sep 2011 20:11:19 +0000 Subject: [PATCH 50/55] [RPCTR4] - Take NetworkAddr into account when a named pipe client is opened. - Return RPC_S_SERVER_UNAVAILABLE when an attempt to create a named pipe client fails with an ERROR_BAD_NETPATH error. This fixes the first test failure in the advapi32 service winetest. svn path=/trunk/; revision=53630 --- reactos/dll/win32/rpcrt4/rpc_transport.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/reactos/dll/win32/rpcrt4/rpc_transport.c b/reactos/dll/win32/rpcrt4/rpc_transport.c index dc2ae19cccf..d979b460686 100644 --- a/reactos/dll/win32/rpcrt4/rpc_transport.c +++ b/reactos/dll/win32/rpcrt4/rpc_transport.c @@ -224,6 +224,9 @@ static RPC_STATUS rpcrt4_conn_open_pipe(RpcConnection *Connection, LPCSTR pname, if (err == ERROR_PIPE_BUSY) { TRACE("connection failed, error=%x\n", err); return RPC_S_SERVER_TOO_BUSY; + } else if (err == ERROR_BAD_NETPATH) { + TRACE("connection failed, error=%x\n", err); + return RPC_S_SERVER_UNAVAILABLE; } if (!wait || !WaitNamedPipeA(pname, NMPWAIT_WAIT_FOREVER)) { err = GetLastError(); @@ -305,17 +308,31 @@ static RPC_STATUS rpcrt4_protseq_ncalrpc_open_endpoint(RpcServerProtseq* protseq static RPC_STATUS rpcrt4_ncacn_np_open(RpcConnection* Connection) { RpcConnection_np *npc = (RpcConnection_np *) Connection; - static const char prefix[] = "\\\\."; + static const char prefix[] = "\\\\"; + static const char local[] ="."; RPC_STATUS r; LPSTR pname; + INT size; /* already connected? */ if (npc->pipe) return RPC_S_OK; /* protseq=ncacn_np: named pipes */ - pname = I_RpcAllocate(strlen(prefix) + strlen(Connection->Endpoint) + 1); - strcat(strcpy(pname, prefix), Connection->Endpoint); + size = strlen(prefix); + if (Connection->NetworkAddr == NULL || strlen(Connection->NetworkAddr) == 0) + size += strlen(local); + else + size += strlen(Connection->NetworkAddr); + size += strlen(Connection->Endpoint) + 1; + + pname = I_RpcAllocate(size); + strcpy(pname, prefix); + if (Connection->NetworkAddr == NULL || strlen(Connection->NetworkAddr) == 0) + strcat(pname, local); + else + strcat(pname, Connection->NetworkAddr); + strcat(pname, Connection->Endpoint); r = rpcrt4_conn_open_pipe(Connection, pname, TRUE); I_RpcFree(pname); From f085f50747e6678efbf50047e41265ea7cb80844 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Wed, 7 Sep 2011 21:41:50 +0000 Subject: [PATCH 51/55] [HAL] - Don't use debug prints before the debugger is even initialized - acquire cmos spinlock when accessing the cmos registers - Fix amd64 build svn path=/trunk/; revision=53631 --- reactos/hal/halx86/apic/apic.c | 49 ++++++-------------------- reactos/hal/halx86/apic/apic.h | 5 +-- reactos/hal/halx86/apic/apictrap.S | 11 ++++-- reactos/hal/halx86/apic/halinit_apic.c | 2 -- reactos/hal/halx86/apic/rtctimer.c | 15 +++++++- reactos/hal/halx86/apic/tsc.h | 5 ++- reactos/hal/halx86/apic/tsccal.S | 41 +++++++++++++++++++++ 7 files changed, 81 insertions(+), 47 deletions(-) diff --git a/reactos/hal/halx86/apic/apic.c b/reactos/hal/halx86/apic/apic.c index 7837a35c10d..74fc9f8c82e 100644 --- a/reactos/hal/halx86/apic/apic.c +++ b/reactos/hal/halx86/apic/apic.c @@ -220,8 +220,8 @@ HalpInitializeLegacyPIC(VOID) __outbyte(PIC2_DATA_PORT, 0xFF); } - VOID +NTAPI ApicInitializeLocalApic(ULONG Cpu) { APIC_BASE_ADRESS_REGISTER BaseRegister; @@ -234,9 +234,6 @@ ApicInitializeLocalApic(ULONG Cpu) BaseRegister.BootStrapCPUCore = (Cpu == 0); __writemsr(MSR_APIC_BASE, BaseRegister.Long); - DPRINT1("ApicBase for Cpu %u PhysicalAddress = %p\n", Cpu, BaseRegister.BaseAddress); - DPRINT1("ApicVersion = 0x%lx\n", ApicRead(0x30)); - /* Set spurious vector and SoftwareEnable to 1 */ SpIntRegister.Long = ApicRead(APIC_SIVR); SpIntRegister.Vector = APIC_SPURIOUS_VECTOR; @@ -283,24 +280,10 @@ ApicInitializeLocalApic(ULONG Cpu) LvtEntry.MessageType = APIC_MT_Fixed; ApicWrite(APIC_ERRLVTR, LvtEntry.Long); - DPRINT1("Error code = 0x%lx\n", ApicRead(0x280)); + /* Set the IRQL from the PCR */ + ApicSetCurrentIrql(KeGetPcr()->Irql); } -VOID -NTAPI -ApicInitializeProcessor( - IN ULONG ProcessorNumber, - IN PLOADER_PARAMETER_BLOCK LoaderBlock) -{ - DPRINT1("ApicInitializeProcessor(%ld)\n", ProcessorNumber); - - /* Initialize the local APIC for this cpu */ - ApicInitializeLocalApic(ProcessorNumber); - - /* Initialize the timer */ - ApicInitializeTimer(ProcessorNumber); - -} VOID FORCEINLINE @@ -443,9 +426,6 @@ HalpInitializePICs(IN BOOLEAN EnableInterrupts) EFlags = __readeflags(); _disable(); - /* Initialize the local APIC for this cpu */ - ApicInitializeLocalApic(0); - /* Initialize and mask the PIC */ HalpInitializeLegacyPIC(); @@ -455,21 +435,10 @@ HalpInitializePICs(IN BOOLEAN EnableInterrupts) /* Register interrupt handlers */ KeRegisterInterruptHandler(APIC_CLOCK_VECTOR, HalpClockInterrupt); +#ifndef _M_AMD64 KeRegisterInterruptHandler(APC_VECTOR, HalpApcInterrupt); KeRegisterInterruptHandler(DPC_VECTOR, HalpDispatchInterrupt); - - // HACK, since we messed with the value, should init the local apic in - // HalInitializeProcessor instead - ApicSetCurrentIrql(APC_LEVEL); - ASSERT(ApicGetProcessorIrql() <= APC_LEVEL); - -__debugbreak(); - -HalpInitializeClock(); -//HalpCalibrateStallExecution(); -_enable(); -for (;;); - +#endif /* Restore interrupt state */ if (EnableInterrupts) EFlags |= EFLAGS_INTERRUPT_MASK; @@ -488,6 +457,7 @@ HalpApcInterruptHandler(IN PKTRAP_FRAME TrapFrame) ASSERT(FALSE); } +#ifndef _M_AMD64 VOID DECLSPEC_NORETURN FASTCALL @@ -512,7 +482,7 @@ __debugbreak(); /* Exit the interrupt */ KiEoiHelper(TrapFrame); } - +#endif /* PUBLIC FUNCTIONS ***********************************************************/ @@ -592,6 +562,7 @@ HalDisableSystemInterrupt( IOApicWrite(IOAPIC_REDTBL + 2 * Irql, ReDirReg.Long0); } +#ifndef _M_AMD64 BOOLEAN NTAPI HalBeginSystemInterrupt( @@ -625,7 +596,6 @@ HalEndSystemInterrupt( ApicWrite(APIC_EOI, 0); } -#ifndef _M_AMD64 KIRQL NTAPI @@ -659,7 +629,7 @@ KfRaiseIrql( { KIRQL OldIrql; - /* Read the current TPR and convert it to an IRQL */ + /* Read the current IRQL */ OldIrql = ApicGetCurrentIrql(); #if DBG /* Validate correct raise */ @@ -672,6 +642,7 @@ KfRaiseIrql( /* Convert the new IRQL to a TPR value and write the register */ ApicSetCurrentIrql(NewIrql); + /* Return old IRQL */ return OldIrql; } diff --git a/reactos/hal/halx86/apic/apic.h b/reactos/hal/halx86/apic/apic.h index 3f9f62c515c..7ac5aeda43d 100644 --- a/reactos/hal/halx86/apic/apic.h +++ b/reactos/hal/halx86/apic/apic.h @@ -1,6 +1,7 @@ #ifdef _M_AMD64 -#define APIC_BASE 0xfffffffffee00000ULL; +#define APIC_BASE 0xFFFFFFFFFEE00000ULL +#define IOAPIC_BASE 0xFFFFFFFFFEE01000ULL // checkme #define ZERO_VECTOR 0x00 // IRQL 00 #define APC_VECTOR 0x3D // IRQL 01 #define APIC_SPURIOUS_VECTOR 0x3f @@ -18,7 +19,6 @@ #else #define APIC_BASE 0xFFFE0000 #define IOAPIC_BASE 0xFFFE1000 // checkme -#define IOAPIC_PHYS_BASE 0xFEC00000 #define ZERO_VECTOR 0x00 // IRQL 00 #define APIC_SPURIOUS_VECTOR 0x1f #define APC_VECTOR 0x3D // IRQL 01 @@ -36,6 +36,7 @@ #endif #define MSR_APIC_BASE 0x0000001B +#define IOAPIC_PHYS_BASE 0xFEC00000 #define APIC_CLOCK_INDEX 8 diff --git a/reactos/hal/halx86/apic/apictrap.S b/reactos/hal/halx86/apic/apictrap.S index 63d79e834e2..3a4c1cde641 100644 --- a/reactos/hal/halx86/apic/apictrap.S +++ b/reactos/hal/halx86/apic/apictrap.S @@ -9,25 +9,32 @@ /* INCLUDES ******************************************************************/ #include -#include #ifdef _M_AMD64 #include +#include +#define KI_PUSH_FAKE_ERROR_CODE TF_PUSH_FAKE_ERROR_CODE PUBLIC ApicSpuriousService #else #include +#include PUBLIC _ApicSpuriousService #endif .code +#ifndef _M_AMD64 TRAP_ENTRY HalpTrap0D, 0 -TRAP_ENTRY HalpApcInterrupt, KI_SOFTWARE_TRAP +TRAP_ENTRY HalpApcInterrupt, KI_PUSH_FAKE_ERROR_CODE TRAP_ENTRY HalpDispatchInterrupt, KI_PUSH_FAKE_ERROR_CODE +#endif TRAP_ENTRY HalpClockInterrupt, KI_PUSH_FAKE_ERROR_CODE TRAP_ENTRY HalpProfileInterrupt, KI_PUSH_FAKE_ERROR_CODE FUNC ApicSpuriousService +#ifdef _M_AMD64 + .ENDPROLOG +#endif int 3 iret ENDFUNC ApicSpuriousService diff --git a/reactos/hal/halx86/apic/halinit_apic.c b/reactos/hal/halx86/apic/halinit_apic.c index 2b37b570572..4f8caff8011 100644 --- a/reactos/hal/halx86/apic/halinit_apic.c +++ b/reactos/hal/halx86/apic/halinit_apic.c @@ -27,8 +27,6 @@ HalpInitProcessor( IN ULONG ProcessorNumber, IN PLOADER_PARAMETER_BLOCK LoaderBlock) { - DPRINT1("ApicInitializeProcessor(%ld)\n", ProcessorNumber); - /* Initialize the local APIC for this cpu */ ApicInitializeLocalApic(ProcessorNumber); diff --git a/reactos/hal/halx86/apic/rtctimer.c b/reactos/hal/halx86/apic/rtctimer.c index 3160681aec0..7ae5de26e7f 100644 --- a/reactos/hal/halx86/apic/rtctimer.c +++ b/reactos/hal/halx86/apic/rtctimer.c @@ -42,6 +42,9 @@ RtcSetClockRate(UCHAR ClockRate) EFlags = __readeflags(); _disable(); + /* Acquire CMOS lock */ + HalpAcquireCmosSpinLock(); + // TODO: disable NMI /* Read value of register A */ @@ -54,6 +57,9 @@ RtcSetClockRate(UCHAR ClockRate) /* Write the new value */ HalpWriteCmos(RTC_REGISTER_A, RegisterA); + /* Release CMOS lock */ + HalpReleaseCmosSpinLock(); + /* Restore interrupts if they were previously enabled */ __writeeflags(EFlags); } @@ -67,10 +73,16 @@ HalpInitializeClock(VOID) UCHAR RegisterB; // TODO: disable NMI + /* Acquire CMOS lock */ + HalpAcquireCmosSpinLock(); + /* Enable the periodic interrupt in the CMOS */ RegisterB = HalpReadCmos(RTC_REGISTER_B); HalpWriteCmos(RTC_REGISTER_B, RegisterB | RTC_REG_B_PI); + /* Release CMOS lock */ + HalpReleaseCmosSpinLock(); + // RtcSetClockRate(HalpCurrentRate); } @@ -84,8 +96,9 @@ HalpClockInterruptHandler(IN PKTRAP_FRAME TrapFrame) /* Enter trap */ KiEnterInterruptTrap(TrapFrame); __debugbreak(); + /* Start the interrupt */ - if (HalBeginSystemInterrupt(CLOCK2_LEVEL, PRIMARY_VECTOR_BASE, &Irql)) + if (HalBeginSystemInterrupt(CLOCK_LEVEL, PRIMARY_VECTOR_BASE, &Irql)) { /* Read register C, so that the next interrupt can happen */ HalpReadCmos(RTC_REGISTER_C);; diff --git a/reactos/hal/halx86/apic/tsc.h b/reactos/hal/halx86/apic/tsc.h index 3cda723401a..19b62832afe 100644 --- a/reactos/hal/halx86/apic/tsc.h +++ b/reactos/hal/halx86/apic/tsc.h @@ -9,7 +9,10 @@ void TscCalibrationISR(void); extern LARGE_INTEGER HalpCpuClockFrequency; VOID NTAPI HalpInitializeTsc(); - +#ifdef _M_AMD64 +#define KiGetIdtEntry(Pcr, Vector) &((Pcr)->IdtBase[Vector]) +#else #define KiGetIdtEntry(Pcr, Vector) &((Pcr)->IDT[Vector]) +#endif #endif diff --git a/reactos/hal/halx86/apic/tsccal.S b/reactos/hal/halx86/apic/tsccal.S index a3d7c0f8d72..08cdeb52134 100644 --- a/reactos/hal/halx86/apic/tsccal.S +++ b/reactos/hal/halx86/apic/tsccal.S @@ -4,6 +4,8 @@ .code +#ifdef _M_IX86 + EXTERN _TscCalibrationPhase:BYTE EXTERN _TscCalibrationArray:QWORD @@ -36,4 +38,43 @@ _CalibrationISR_Exit: pop eax iretd +#else + +EXTERN TscCalibrationPhase:BYTE +EXTERN TscCalibrationArray:DWORD + +PUBLIC TscCalibrationISR +FUNC TscCalibrationISR + push rax + push rcx + push rdx + .ENDPROLOG + + /* The first thing we do is read the current TSC value */ + rdtsc + + /* Read the current phase */ + movzx rcx, byte ptr [TscCalibrationPhase] + + /* Check if we're already done */ + cmp cl, NUM_SAMPLES + jnb CalibrationISR_Exit + + /* Store the current value */ + shl rcx, 1 + lea rax, [TscCalibrationArray] + mov dword ptr [rax + rcx], eax + mov dword ptr [rax + rcx + 4], edx + + /* Advance phase */ + inc byte ptr [TscCalibrationPhase] + +CalibrationISR_Exit: + pop rdx + pop rcx + pop rax + iretq +ENDFUNC TscCalibrationISR +#endif + END From 7635cc18b197f4419eff8cda8c3a2cb2b14f0c5c Mon Sep 17 00:00:00 2001 From: Giannis Adamopoulos Date: Wed, 7 Sep 2011 23:08:14 +0000 Subject: [PATCH 52/55] [user32_apitest] - Add some more tests hoping that SetActiveWindow will reveal its secrets svn path=/trunk/; revision=53632 --- rostests/apitests/user32/SetActiveWindow.c | 74 +++++++++++++++++----- 1 file changed, 57 insertions(+), 17 deletions(-) diff --git a/rostests/apitests/user32/SetActiveWindow.c b/rostests/apitests/user32/SetActiveWindow.c index 1f8aae2740e..3a5b6c1405b 100644 --- a/rostests/apitests/user32/SetActiveWindow.c +++ b/rostests/apitests/user32/SetActiveWindow.c @@ -9,41 +9,81 @@ #include #include + +#define EXPECT_NEXT(hWnd1, hWnd2) ok(GetWindow(hWnd1,GW_HWNDNEXT) == hWnd2, "Expected %p after %p, not %p\n",hWnd2,hWnd1,GetWindow(hWnd1,GW_HWNDNEXT) ) +#define EXPECT_ACTIVE(hwnd) ok(GetActiveWindow() == hwnd, "Expected %p to be the active window, not %p\n",hwnd,GetActiveWindow()) + void Test_SetActiveWindow() { MSG msg; - HWND hWnd, hWnd1, hWnd2; - - hWnd = CreateWindowW(L"BUTTON", L"ownertest", WS_OVERLAPPEDWINDOW, - 20, 20, 300, 300, NULL, NULL, 0, NULL); + HWND hWnd1, hWnd2, hWnd3, hWnd4; hWnd1 = CreateWindowW(L"BUTTON", L"ownertest", WS_OVERLAPPEDWINDOW, - 20, 350, 300, 300, hWnd, NULL, 0, NULL); + 20, 20, 300, 300, NULL, NULL, 0, NULL); hWnd2 = CreateWindowW(L"BUTTON", L"ownertest", WS_OVERLAPPEDWINDOW, + 20, 350, 300, 300, hWnd1, NULL, 0, NULL); + + hWnd3 = CreateWindowW(L"BUTTON", L"ownertest", WS_OVERLAPPEDWINDOW, 200, 200, 300, 300, NULL, NULL, 0, NULL); - ShowWindow(hWnd, SW_SHOW); - UpdateWindow(hWnd); + hWnd4 = CreateWindowW(L"BUTTON", L"ownertest", WS_OVERLAPPEDWINDOW, + 250, 250, 200, 200, hWnd1, NULL, 0, NULL); + ShowWindow(hWnd1, SW_SHOW); UpdateWindow(hWnd1); + while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessageA( &msg ); + + EXPECT_NEXT(hWnd4,hWnd2); + EXPECT_NEXT(hWnd1,hWnd3); + ShowWindow(hWnd2, SW_SHOW); UpdateWindow(hWnd2); - while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessageA( &msg ); - ok(GetWindow(hWnd2,GW_HWNDNEXT) == hWnd1, "Expected %p after %p, not %p\n",hWnd1,hWnd2,GetWindow(hWnd2,GW_HWNDNEXT) ); - ok(GetWindow(hWnd1,GW_HWNDNEXT) == hWnd, "Expected %p after %p, not %p\n",hWnd,hWnd1,GetWindow(hWnd1,GW_HWNDNEXT)); - ok(GetActiveWindow() == hWnd2, "Expected %p to be the active window, not %p\n",hWnd2,GetActiveWindow()); - - SetActiveWindow(hWnd); + EXPECT_NEXT(hWnd2,hWnd4); + EXPECT_NEXT(hWnd4,hWnd1); + ShowWindow(hWnd3, SW_SHOW); + UpdateWindow(hWnd3); while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessageA( &msg ); - /* note: the owned is moved on top of the three windows */ - ok(GetActiveWindow() == hWnd, "Expected %p to be the active window, not %p\n",hWnd,GetActiveWindow()); - ok(GetWindow(hWnd1,GW_HWNDNEXT) == hWnd, "Expected %p after %p, not %p\n",hWnd,hWnd1,GetWindow(hWnd1,GW_HWNDNEXT) ); - ok(GetWindow(hWnd,GW_HWNDNEXT) == hWnd2, "Expected %p after %p, not %p\n",hWnd2,hWnd,GetWindow(hWnd,GW_HWNDNEXT) ); + EXPECT_NEXT(hWnd3,hWnd2); + EXPECT_NEXT(hWnd2,hWnd4); + EXPECT_NEXT(hWnd4,hWnd1); + + ShowWindow(hWnd4, SW_SHOW); + UpdateWindow(hWnd4); + while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessageA( &msg ); + + EXPECT_NEXT(hWnd4,hWnd2); + EXPECT_NEXT(hWnd2,hWnd1); + EXPECT_NEXT(hWnd1,hWnd3); + EXPECT_ACTIVE(hWnd4); + + SetActiveWindow(hWnd1); + while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessageA( &msg ); + + EXPECT_NEXT(hWnd4,hWnd2); + EXPECT_NEXT(hWnd2,hWnd1); + EXPECT_NEXT(hWnd1,hWnd3); + EXPECT_ACTIVE(hWnd1); + + SetActiveWindow(hWnd3); + while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessageA( &msg ); + + EXPECT_NEXT(hWnd3,hWnd4); + EXPECT_NEXT(hWnd4,hWnd2); + EXPECT_NEXT(hWnd2,hWnd1); + EXPECT_ACTIVE(hWnd3); + + SetActiveWindow(hWnd2); + while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessageA( &msg ); + + EXPECT_NEXT(hWnd2,hWnd4); + EXPECT_NEXT(hWnd4,hWnd1); + EXPECT_NEXT(hWnd1,hWnd3); + EXPECT_ACTIVE(hWnd2); } START_TEST(SetActiveWindow) From c508185cd9c5064a6d29b6180bb240069c7f84a4 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Thu, 8 Sep 2011 08:15:39 +0000 Subject: [PATCH 53/55] [HAL] - Fix I/O APIC register access - set APIC logical id based on Cpu (currently flat model with up to 8 cpus supported) - In HalpInitializeTsc, setup the RTC clock, since the timer is initialized later - in the TSC calibration ISR, send EOI and read RTC register C to get the next interrupt svn path=/trunk/; revision=53634 --- reactos/hal/halx86/apic/apic.c | 26 ++++++++++++++++++++++---- reactos/hal/halx86/apic/apic.h | 9 ++++++++- reactos/hal/halx86/apic/rtctimer.c | 5 +++-- reactos/hal/halx86/apic/tsc.c | 27 +++++++++++++++++++-------- reactos/hal/halx86/apic/tsccal.S | 17 +++++++++++++++-- 5 files changed, 67 insertions(+), 17 deletions(-) diff --git a/reactos/hal/halx86/apic/apic.c b/reactos/hal/halx86/apic/apic.c index 74fc9f8c82e..d613c5f94d4 100644 --- a/reactos/hal/halx86/apic/apic.c +++ b/reactos/hal/halx86/apic/apic.c @@ -88,7 +88,7 @@ FORCEINLINE IOApicRead(UCHAR Register) { /* Select the register, then do the read */ - *(volatile ULONG *)(IOAPIC_BASE + IOAPIC_IOREGSEL) = Register; + *(volatile UCHAR *)(IOAPIC_BASE + IOAPIC_IOREGSEL) = Register; return *(volatile ULONG *)(IOAPIC_BASE + IOAPIC_IOWIN); } @@ -97,7 +97,7 @@ FORCEINLINE IOApicWrite(UCHAR Register, ULONG Value) { /* Select the register, then do the write */ - *(volatile ULONG *)(IOAPIC_BASE + IOAPIC_IOREGSEL) = Register; + *(volatile UCHAR *)(IOAPIC_BASE + IOAPIC_IOREGSEL) = Register; *(volatile ULONG *)(IOAPIC_BASE + IOAPIC_IOWIN) = Value; } @@ -241,6 +241,12 @@ ApicInitializeLocalApic(ULONG Cpu) SpIntRegister.FocusCPUCoreChecking = 0; ApicWrite(APIC_SIVR, SpIntRegister.Long); + /* Set the mode to flat (max 8 CPUs supported!) */ + ApicWrite(APIC_DFR, APIC_DF_Flat); + + /* Set logical apic ID */ + ApicWrite(APIC_LDR, ApicLogicalId(Cpu) << 24); + /* Set the spurious ISR */ KeRegisterInterruptHandler(APIC_SPURIOUS_VECTOR, ApicSpuriousService); @@ -409,9 +415,11 @@ ApicInitializeIOApic(VOID) /* Enable the timer interrupt */ ReDirReg.Vector = APIC_CLOCK_VECTOR; - ReDirReg.DestinationMode = APIC_DM_Logical; + ReDirReg.DeliveryMode = APIC_MT_Fixed; + ReDirReg.DestinationMode = APIC_DM_Physical; ReDirReg.TriggerMode = APIC_TGM_Edge; ReDirReg.Mask = 0; + ReDirReg.Destination = ApicRead(APIC_ID); IOApicWrite(IOAPIC_REDTBL + 2 * APIC_CLOCK_INDEX, ReDirReg.Long0); } @@ -519,6 +527,7 @@ HalEnableSystemInterrupt( IN KINTERRUPT_MODE InterruptMode) { IOAPIC_REDIRECTION_REGISTER ReDirReg; + PKPRCB Prcb = KeGetCurrentPrcb(); UCHAR Index; ASSERT(Irql <= HIGH_LEVEL); ASSERT((IrqlToTpr(Irql) & 0xF0) == (Vector & 0xF0)); @@ -531,6 +540,7 @@ HalEnableSystemInterrupt( ReDirReg.Vector = Vector; ReDirReg.DeliveryMode = APIC_MT_LowestPriority; ReDirReg.DestinationMode = APIC_DM_Logical; + ReDirReg.Destination |= ApicLogicalId(Prcb->Number); ReDirReg.TriggerMode = 1 - InterruptMode; ReDirReg.Mask = FALSE; @@ -562,6 +572,14 @@ HalDisableSystemInterrupt( IOApicWrite(IOAPIC_REDTBL + 2 * Irql, ReDirReg.Long0); } +VOID +NTAPI +HalpSendEOI(VOID) +{ + /* Write 0 to the EndOfInterruptRegister */ + ApicWrite(APIC_EOI, 0); +} + #ifndef _M_AMD64 BOOLEAN NTAPI @@ -592,7 +610,7 @@ HalEndSystemInterrupt( /* Restore the old IRQL */ ApicSetCurrentIrql(OldIrql); - /* Write 0 to the EndOfInterruptRegister for level triggered ints */ + /* Write 0 to the EndOfInterruptRegister */ ApicWrite(APIC_EOI, 0); } diff --git a/reactos/hal/halx86/apic/apic.h b/reactos/hal/halx86/apic/apic.h index 7ac5aeda43d..c6a43e0c38e 100644 --- a/reactos/hal/halx86/apic/apic.h +++ b/reactos/hal/halx86/apic/apic.h @@ -39,6 +39,7 @@ #define IOAPIC_PHYS_BASE 0xFEC00000 #define APIC_CLOCK_INDEX 8 +#define ApicLogicalId(Cpu) ((UCHAR)(1<< Cpu)) /* APIC Register Address Map */ #define APIC_ID 0x0020 /* Local APIC ID Register (R/W) */ @@ -106,6 +107,12 @@ enum APIC_DSH_AllExclusingSelf }; +enum +{ + APIC_DF_Flat = 0xFFFFFFFF, + APIC_DF_Cluster = 0x0FFFFFFF +}; + enum { TIMER_DV_DivideBy2 = 0, @@ -224,7 +231,7 @@ enum IOAPIC_ID = 0x00, IOAPIC_VER = 0x01, IOAPIC_ARB = 0x02, - IOAPIC_REDTBL = 0x28 + IOAPIC_REDTBL = 0x10 }; typedef union _IOAPIC_REDIRECTION_REGISTER diff --git a/reactos/hal/halx86/apic/rtctimer.c b/reactos/hal/halx86/apic/rtctimer.c index 7ae5de26e7f..dc487bd239a 100644 --- a/reactos/hal/halx86/apic/rtctimer.c +++ b/reactos/hal/halx86/apic/rtctimer.c @@ -83,7 +83,9 @@ HalpInitializeClock(VOID) /* Release CMOS lock */ HalpReleaseCmosSpinLock(); - // RtcSetClockRate(HalpCurrentRate); + RtcSetClockRate(HalpCurrentRate); + + DPRINT1("Clock initialized\n"); } VOID @@ -95,7 +97,6 @@ HalpClockInterruptHandler(IN PKTRAP_FRAME TrapFrame) /* Enter trap */ KiEnterInterruptTrap(TrapFrame); -__debugbreak(); /* Start the interrupt */ if (HalBeginSystemInterrupt(CLOCK_LEVEL, PRIMARY_VECTOR_BASE, &Irql)) diff --git a/reactos/hal/halx86/apic/tsc.c b/reactos/hal/halx86/apic/tsc.c index 14d5c1fba7f..a551b9c3e4a 100644 --- a/reactos/hal/halx86/apic/tsc.c +++ b/reactos/hal/halx86/apic/tsc.c @@ -18,7 +18,7 @@ LARGE_INTEGER HalpCpuClockFrequency = {INITIAL_STALL_COUNT * 1000000}; UCHAR TscCalibrationPhase; LARGE_INTEGER TscCalibrationArray[NUM_SAMPLES]; -extern const UCHAR HalpClockVector; +UCHAR HalpRtcClockVector = 0xD1; /* PRIVATE FUNCTIONS *********************************************************/ @@ -29,6 +29,7 @@ HalpInitializeTsc() ULONG_PTR Flags; KIDTENTRY OldIdtEntry, *IdtPointer; PKPCR Pcr = KeGetPcr(); + UCHAR RegisterA, RegisterB; /* Check if the CPU supports RDTSC */ if (!(KeGetCurrentPrcb()->FeatureBits & KF_RDTSC)) @@ -40,31 +41,41 @@ HalpInitializeTsc() Flags = __readeflags(); _disable(); -__debugbreak(); + /* Enable the periodic interrupt in the CMOS */ + RegisterB = HalpReadCmos(RTC_REGISTER_B); + HalpWriteCmos(RTC_REGISTER_B, RegisterB | RTC_REG_B_PI); - /* Initialze the PIT */ - //HalpInitializePIT(); + /* Modify register A to get 4096 Hz */ + RegisterA = HalpReadCmos(RTC_REGISTER_A); + RegisterA = (RegisterA & 0xF0) | 9; + HalpWriteCmos(RTC_REGISTER_A, RegisterA); /* Save old IDT entry */ - IdtPointer = KiGetIdtEntry(Pcr, HalpClockVector); + IdtPointer = KiGetIdtEntry(Pcr, HalpRtcClockVector); OldIdtEntry = *IdtPointer; /* Set the calibration ISR */ - KeRegisterInterruptHandler(HalpClockVector, TscCalibrationISR); + KeRegisterInterruptHandler(HalpRtcClockVector, TscCalibrationISR); /* Reset TSC value to 0 */ __writemsr(MSR_RDTSC, 0); /* Enable the timer interupt */ - HalEnableSystemInterrupt(HalpClockVector, CLOCK_LEVEL, Latched); + HalEnableSystemInterrupt(HalpRtcClockVector, CLOCK_LEVEL, Latched); + + /* Read register C, so that the next interrupt can happen */ + HalpReadCmos(RTC_REGISTER_C);; /* Wait for completion */ _enable(); while (TscCalibrationPhase < NUM_SAMPLES) _ReadWriteBarrier(); _disable(); + /* Disable the periodic interrupt in the CMOS */ + HalpWriteCmos(RTC_REGISTER_B, RegisterB & ~RTC_REG_B_PI); + /* Disable the timer interupt */ - HalDisableSystemInterrupt(HalpClockVector, CLOCK_LEVEL); + HalDisableSystemInterrupt(HalpRtcClockVector, CLOCK_LEVEL); /* Restore old IDT entry */ *IdtPointer = OldIdtEntry; diff --git a/reactos/hal/halx86/apic/tsccal.S b/reactos/hal/halx86/apic/tsccal.S index 08cdeb52134..8b3f49ba2ad 100644 --- a/reactos/hal/halx86/apic/tsccal.S +++ b/reactos/hal/halx86/apic/tsccal.S @@ -8,6 +8,7 @@ EXTERN _TscCalibrationPhase:BYTE EXTERN _TscCalibrationArray:QWORD +EXTERN _HalpSendEOI@0:PROC PUBLIC _TscCalibrationISR _TscCalibrationISR: @@ -26,13 +27,25 @@ _TscCalibrationISR: jnb _CalibrationISR_Exit /* Store the current value */ - mov dword ptr _TscCalibrationArray[ecx * 2], eax - mov dword ptr _TscCalibrationArray[ecx * 2 + 4], edx + shl ecx, 3 + mov dword ptr _TscCalibrationArray[ecx], eax + mov dword ptr _TscCalibrationArray[ecx + 4], edx /* Advance phase */ inc byte ptr ds:[_TscCalibrationPhase] _CalibrationISR_Exit: + + /* Read CMOS register C */ + mov al, HEX(0C) + out HEX(70), al + jmp $+2 + in al, HEX(71) + jmp $+2 + + /* Send EOI */ + call _HalpSendEOI@0 + pop edx pop ecx pop eax From c7b81786fe1b5158fe2e1a7c76c48a085051ce4a Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Thu, 8 Sep 2011 08:28:41 +0000 Subject: [PATCH 54/55] - Downgrade some DPRINT1s to DPRINTs. svn path=/trunk/; revision=53635 --- reactos/dll/ntdll/ldr/ldrapi.c | 4 ++-- reactos/dll/ntdll/ldr/ldrinit.c | 6 +++--- reactos/ntoskrnl/mm/ARM3/procsup.c | 4 ++-- reactos/subsystems/win32/csrss/csrsrv/api/process.c | 2 +- reactos/subsystems/win32/csrss/csrsrv/api/wapi.c | 6 +++--- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/reactos/dll/ntdll/ldr/ldrapi.c b/reactos/dll/ntdll/ldr/ldrapi.c index a2f11f8a701..848c68bfe00 100644 --- a/reactos/dll/ntdll/ldr/ldrapi.c +++ b/reactos/dll/ntdll/ldr/ldrapi.c @@ -1542,8 +1542,8 @@ BOOLEAN NTAPI LdrUnloadAlternateResourceModule(IN PVOID BaseAddress) { - static BOOLEAN WarnedOnce = FALSE; - if (WarnedOnce == FALSE) { UNIMPLEMENTED; WarnedOnce = TRUE; } + //static BOOLEAN WarnedOnce = FALSE; + //if (WarnedOnce == FALSE) { UNIMPLEMENTED; WarnedOnce = TRUE; } return FALSE; } diff --git a/reactos/dll/ntdll/ldr/ldrinit.c b/reactos/dll/ntdll/ldr/ldrinit.c index dca2b2902db..33b0e86a01d 100644 --- a/reactos/dll/ntdll/ldr/ldrinit.c +++ b/reactos/dll/ntdll/ldr/ldrinit.c @@ -728,7 +728,7 @@ LdrpRunInitializeRoutines(IN PCONTEXT Context OPTIONAL) /* Clear it */ //Kernel32ProcessInitPostImportfunction = NULL; - UNIMPLEMENTED; + //UNIMPLEMENTED; } /* No root entry? return */ @@ -1988,7 +1988,7 @@ LdrpInitializeProcess(IN PCONTEXT Context, if (NtHeader->OptionalHeader.Subsystem == IMAGE_SUBSYSTEM_WINDOWS_GUI) { /* Load kernel32 and call BasePostImportInit... */ - DPRINT1("Unimplemented codepath!\n"); + DPRINT("Unimplemented codepath!\n"); } /* Walk the IAT and load all the DLLs */ @@ -2095,7 +2095,7 @@ LdrpInitializeProcess(IN PCONTEXT Context, { /* Check for Application Compatibility Goo */ //LdrQueryApplicationCompatibilityGoo(hKey); - DPRINT1("Querying app compat hacks is missing!\n"); + DPRINT("Querying app compat hacks is missing!\n"); } /* diff --git a/reactos/ntoskrnl/mm/ARM3/procsup.c b/reactos/ntoskrnl/mm/ARM3/procsup.c index 79612f17b31..074196fae32 100644 --- a/reactos/ntoskrnl/mm/ARM3/procsup.c +++ b/reactos/ntoskrnl/mm/ARM3/procsup.c @@ -590,7 +590,7 @@ MmCreatePeb(IN PEPROCESS Process, ViewShare, MEM_TOP_DOWN, PAGE_READONLY); - DPRINT1("NLS Tables at: %p\n", TableBase); + DPRINT("NLS Tables at: %p\n", TableBase); if (!NT_SUCCESS(Status)) { /* Cleanup and exit */ @@ -602,7 +602,7 @@ MmCreatePeb(IN PEPROCESS Process, // Allocate the PEB // Status = MiCreatePebOrTeb(Process, sizeof(PEB), (PULONG_PTR)&Peb); - DPRINT1("PEB at: %p\n", Peb); + DPRINT("PEB at: %p\n", Peb); if (!NT_SUCCESS(Status)) { /* Cleanup and exit */ diff --git a/reactos/subsystems/win32/csrss/csrsrv/api/process.c b/reactos/subsystems/win32/csrss/csrsrv/api/process.c index c1e7fdb1921..13609eb968c 100644 --- a/reactos/subsystems/win32/csrss/csrsrv/api/process.c +++ b/reactos/subsystems/win32/csrss/csrsrv/api/process.c @@ -105,7 +105,7 @@ PCSRSS_PROCESS_DATA WINAPI CsrCreateProcessData(HANDLE ProcessId) PROCESS_ALL_ACCESS, &ObjectAttributes, &ClientId); - DPRINT1("CSR Process: %p Handle: %p\n", pProcessData, pProcessData->Process); + DPRINT("CSR Process: %p Handle: %p\n", pProcessData, pProcessData->Process); if (!NT_SUCCESS(Status)) { ProcessData[hash] = pProcessData->next; diff --git a/reactos/subsystems/win32/csrss/csrsrv/api/wapi.c b/reactos/subsystems/win32/csrss/csrsrv/api/wapi.c index 678cbde92ca..e856b3050d2 100644 --- a/reactos/subsystems/win32/csrss/csrsrv/api/wapi.c +++ b/reactos/subsystems/win32/csrss/csrsrv/api/wapi.c @@ -278,8 +278,8 @@ CsrSrvAttachSharedSection(IN PCSRSS_PROCESS_DATA CsrProcess OPTIONAL, /* Check if we have a process */ if (CsrProcess) { - /* Map the sectio into this process */ - DPRINT1("CSR Process Handle: %p. CSR Process: %p\n", CsrProcess->Process, CsrProcess); + /* Map the section into this process */ + DPRINT("CSR Process Handle: %p. CSR Process: %p\n", CsrProcess->Process, CsrProcess); Status = NtMapViewOfSection(CsrSrvSharedSection, CsrProcess->Process, &CsrSrvSharedSectionBase, @@ -520,7 +520,7 @@ CsrpHandleConnectionRequest (PPORT_MESSAGE Request, Status = CsrSrvAttachSharedSection(ProcessData, ConnectInfo); if (NT_SUCCESS(Status)) { - DPRINT1("Connection ok\n"); + DPRINT("Connection ok\n"); AllowConnection = TRUE; } else From 8571e00fdcf65a11e495c99466a8557122668db8 Mon Sep 17 00:00:00 2001 From: Rafal Harabien Date: Thu, 8 Sep 2011 09:55:28 +0000 Subject: [PATCH 55/55] [WIN32K] - Fix user32:monitor winetest failures (ClipCursor bugs) - Protect functions in accelerator.c with SEH svn path=/trunk/; revision=53636 --- .../win32/win32k/ntuser/accelerator.c | 115 ++++++++++++------ .../win32/win32k/ntuser/cursoricon.c | 26 +++- 2 files changed, 100 insertions(+), 41 deletions(-) diff --git a/reactos/subsystems/win32/win32k/ntuser/accelerator.c b/reactos/subsystems/win32/win32k/ntuser/accelerator.c index d17b32e610f..90c12314d82 100644 --- a/reactos/subsystems/win32/win32k/ntuser/accelerator.c +++ b/reactos/subsystems/win32/win32k/ntuser/accelerator.c @@ -309,21 +309,32 @@ NtUserCopyAcceleratorTable( Ret = 0; - while (!Done) + _SEH2_TRY { - if (Entries) + ProbeForWrite(Entries, EntriesCount*sizeof(Entries[0]), 4); + + while (!Done) { - Entries[Ret].fVirt = Accel->Table[Ret].fVirt & 0x7f; - Entries[Ret].key = Accel->Table[Ret].key; - Entries[Ret].cmd = Accel->Table[Ret].cmd; + if (Entries) + { + Entries[Ret].fVirt = Accel->Table[Ret].fVirt & 0x7f; + Entries[Ret].key = Accel->Table[Ret].key; + Entries[Ret].cmd = Accel->Table[Ret].cmd; - if(Ret + 1 == EntriesCount) Done = TRUE; + if(Ret + 1 == EntriesCount) Done = TRUE; + } + + if((Accel->Table[Ret].fVirt & 0x80) != 0) Done = TRUE; + + Ret++; } - - if((Accel->Table[Ret].fVirt & 0x80) != 0) Done = TRUE; - - Ret++; } + _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) + { + SetLastNtError(_SEH2_GetExceptionCode()); + Ret = 0; + } + _SEH2_END; RETURN(Ret); @@ -342,6 +353,7 @@ NtUserCreateAcceleratorTable( PACCELERATOR_TABLE Accel; HACCEL hAccel; INT Index; + NTSTATUS Status = STATUS_SUCCESS; DECLARE_RETURN(HACCEL); TRACE("Enter NtUserCreateAcceleratorTable(Entries %p, EntriesCount %d)\n", @@ -374,23 +386,42 @@ NtUserCreateAcceleratorTable( RETURN( (HACCEL) NULL); } - for (Index = 0; Index < EntriesCount; Index++) + _SEH2_TRY { - Accel->Table[Index].fVirt = Entries[Index].fVirt&0x7f; - if(Accel->Table[Index].fVirt & FVIRTKEY) - { - Accel->Table[Index].key = Entries[Index].key; - } - else - { - RtlMultiByteToUnicodeN(&Accel->Table[Index].key, - sizeof(WCHAR), - NULL, - (PCSTR)&Entries[Index].key, - sizeof(CHAR)); - } + ProbeForRead(Entries, EntriesCount * sizeof(ACCEL), 4); - Accel->Table[Index].cmd = Entries[Index].cmd; + for (Index = 0; Index < EntriesCount; Index++) + { + Accel->Table[Index].fVirt = Entries[Index].fVirt&0x7f; + if(Accel->Table[Index].fVirt & FVIRTKEY) + { + Accel->Table[Index].key = Entries[Index].key; + } + else + { + RtlMultiByteToUnicodeN(&Accel->Table[Index].key, + sizeof(WCHAR), + NULL, + (PCSTR)&Entries[Index].key, + sizeof(CHAR)); + } + + Accel->Table[Index].cmd = Entries[Index].cmd; + } + } + _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) + { + Status = _SEH2_GetExceptionCode(); + } + _SEH2_END; + + if (!NT_SUCCESS(Status)) + { + ExFreePoolWithTag(Accel->Table, USERTAG_ACCEL); + UserDereferenceObject(Accel); + UserDeleteObject(hAccel, otAccel); + SetLastNtError(Status); + RETURN( (HACCEL) NULL); } /* Set the end-of-table terminator. */ @@ -450,28 +481,41 @@ APIENTRY NtUserTranslateAccelerator( HWND hWnd, HACCEL hAccel, - LPMSG Message) + LPMSG pUnsafeMessage) { PWND Window = NULL; PACCELERATOR_TABLE Accel = NULL; ULONG i; + MSG Message; USER_REFERENCE_ENTRY AccelRef, WindowRef; DECLARE_RETURN(int); TRACE("NtUserTranslateAccelerator(hWnd %x, Table %x, Message %p)\n", - hWnd, hAccel, Message); + hWnd, hAccel, pUnsafeMessage); UserEnterShared(); - if (Message == NULL) + if (pUnsafeMessage == NULL) { SetLastNtError(STATUS_INVALID_PARAMETER); RETURN( 0); } - if ((Message->message != WM_KEYDOWN) && - (Message->message != WM_SYSKEYDOWN) && - (Message->message != WM_SYSCHAR) && - (Message->message != WM_CHAR)) + _SEH2_TRY + { + ProbeForRead(pUnsafeMessage, sizeof(MSG), 4); + RtlCopyMemory(&Message, pUnsafeMessage, sizeof(MSG)); + } + _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) + { + SetLastNtError(_SEH2_GetExceptionCode()); + _SEH2_YIELD(RETURN( 0)); + } + _SEH2_END; + + if ((Message.message != WM_KEYDOWN) && + (Message.message != WM_SYSKEYDOWN) && + (Message.message != WM_SYSCHAR) && + (Message.message != WM_CHAR)) { RETURN( 0); } @@ -490,17 +534,16 @@ NtUserTranslateAccelerator( UserRefObjectCo(Window, &WindowRef); - /* FIXME: Associate AcceleratorTable with the current thread */ for (i = 0; i < Accel->Count; i++) { - if (co_IntTranslateAccelerator(Window, Message->message, Message->wParam, Message->lParam, + if (co_IntTranslateAccelerator(Window, Message.message, Message.wParam, Message.lParam, Accel->Table[i].fVirt, Accel->Table[i].key, Accel->Table[i].cmd)) { TRACE("NtUserTranslateAccelerator(hWnd %x, Table %x, Message %p) = %i end\n", - hWnd, hAccel, Message, 1); + hWnd, hAccel, pUnsafeMessage, 1); RETURN( 1); } if (((Accel->Table[i].fVirt & 0x80) > 0)) @@ -516,7 +559,7 @@ CLEANUP: if (Accel) UserDerefObjectCo(Accel); TRACE("NtUserTranslateAccelerator(hWnd %x, Table %x, Message %p) = %i end\n", - hWnd, hAccel, Message, 0); + hWnd, hAccel, pUnsafeMessage, 0); UserLeave(); END_CLEANUP; } diff --git a/reactos/subsystems/win32/win32k/ntuser/cursoricon.c b/reactos/subsystems/win32/win32k/ntuser/cursoricon.c index 571988d92f7..e6d56f57d45 100644 --- a/reactos/subsystems/win32/win32k/ntuser/cursoricon.c +++ b/reactos/subsystems/win32/win32k/ntuser/cursoricon.c @@ -564,13 +564,29 @@ UserClipCursor( DesktopWindow = UserGetDesktopWindow(); - if (prcl != NULL && - (prcl->right > prcl->left) && - (prcl->bottom > prcl->top) && - DesktopWindow != NULL) + if (prcl != NULL && DesktopWindow != NULL) { + if (prcl->right < prcl->left || prcl->bottom < prcl->top) + { + EngSetLastError(ERROR_INVALID_PARAMETER); + return FALSE; + } + CurInfo->bClipped = TRUE; - RECTL_bIntersectRect(&CurInfo->rcClip, prcl, &DesktopWindow->rcWindow); + + /* Set nw cliping region. Note: we can't use RECTL_bIntersectRect because + it sets rect to 0 0 0 0 when it's empty. For more info see monitor winetest */ + CurInfo->rcClip.left = max(prcl->left, DesktopWindow->rcWindow.left); + CurInfo->rcClip.right = min(prcl->right, DesktopWindow->rcWindow.right); + if (CurInfo->rcClip.right < CurInfo->rcClip.left) + CurInfo->rcClip.right = CurInfo->rcClip.left; + + CurInfo->rcClip.top = max(prcl->top, DesktopWindow->rcWindow.top); + CurInfo->rcClip.bottom = min(prcl->bottom, DesktopWindow->rcWindow.bottom); + if (CurInfo->rcClip.bottom < CurInfo->rcClip.top) + CurInfo->rcClip.bottom = CurInfo->rcClip.top; + + /* Make sure cursor is in clipping region */ UserSetCursorPos(gpsi->ptCursor.x, gpsi->ptCursor.y, 0, 0, FALSE); } else