ReactOS.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
List overview
Download
Ros-diffs
April 2011
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
ros-diffs@reactos.org
19 participants
296 discussions
Start a n
N
ew thread
[fireball] 51393: Sam Arun Raj Seeniraj: [KERNEL32] - DefineDosDeviceW() is implemented and calls into csrss.exe CsrDefineDosDevice(). - Fixed a minor bug in DefineDosDeviceA(), as calling RtlCreat...
by fireball@svn.reactos.org
Author: fireball Date: Mon Apr 18 21:48:19 2011 New Revision: 51393 URL:
http://svn.reactos.org/svn/reactos?rev=51393&view=rev
Log: Sam Arun Raj Seeniraj: [KERNEL32] - DefineDosDeviceW() is implemented and calls into csrss.exe CsrDefineDosDevice(). - Fixed a minor bug in DefineDosDeviceA(), as calling RtlCreateUnicodeStringFromAsciiz() prevented NULL lpTargetPath to be passed down to DefineDosDeviceW(). - Fixed a minor bug in QueryDosDeviceW() that causes lpTargetPath buffer to be returned with NULL string terminator placed at the wrong point in the buffer. [WIN32CSR.DLL] - Implemented CsrDefineDosDevice() in win32csr.dll, the symbolic links are created in global name space currently. [SUBST.EXE] - Implemented a subst.exe clone. See issue #993 for more details. Added: trunk/reactos/base/system/subst/ trunk/reactos/base/system/subst/subst.c (with props) trunk/reactos/base/system/subst/subst.rbuild (with props) trunk/reactos/base/system/subst/subst.rc (with props) Modified: trunk/reactos/base/system/system.rbuild trunk/reactos/boot/bootdata/packages/reactos.dff trunk/reactos/dll/win32/kernel32/file/dosdev.c trunk/reactos/include/reactos/subsys/csrss/csrss.h trunk/reactos/subsystems/win32/csrss/win32csr/dllmain.c trunk/reactos/subsystems/win32/csrss/win32csr/file.c trunk/reactos/subsystems/win32/csrss/win32csr/file.h Added: trunk/reactos/base/system/subst/subst.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/subst/subst.c?…
============================================================================== --- trunk/reactos/base/system/subst/subst.c (added) +++ trunk/reactos/base/system/subst/subst.c [iso-8859-1] Mon Apr 18 21:48:19 2011 @@ -1,0 +1,257 @@ +/* PROJECT: ReactOS Kernel + * LICENSE: GPL - See COPYING in the top level directory + * FILE: base/system/subst/subst.c + * PURPOSE: Associates a path with a drive letter + * PROGRAMMERS: Sam Arun Raj + */ + +/* INCLUDES *****************************************************************/ + +#define LEAN_AND_MEAN +#include <stdio.h> +#include <stdlib.h> +#include <windows.h> +#include <tchar.h> +#define NDEBUG +#include <debug.h> + +/* FUNCTIONS ****************************************************************/ + +void PrintError(DWORD ErrCode) +{ + TCHAR *buffer = (TCHAR*) calloc(2048, + sizeof(TCHAR)); + TCHAR *msg = NULL; + + if (buffer) + { + FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, + NULL, + ErrCode, + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), + (TCHAR*)&msg, + 0, + NULL); + _sntprintf(buffer, + 2048, + _T("Failed with error code 0x%x: %s\n"), + ErrCode, + msg); + _tprintf(_T("%s"), + buffer); + if (msg) + LocalFree(msg); + free(buffer); + } +} + +void DisplaySubstUsage() +{ + _tprintf(_T("Associates a path with a drive letter.\n\n")); + _tprintf(_T("SUBST [drive1: [drive2:]path]\n")); + _tprintf(_T("SUBST drive1: /D\n\n")); + _tprintf(_T(" drive1: Specifies a virtual drive to which you want to assign a path.\n")); + _tprintf(_T(" [drive2:]path Specifies a physical drive and path you want to assign to\n")); + _tprintf(_T(" a virtual drive.\n")); + _tprintf(_T(" /D Deletes a substituted (virtual) drive.\n\n")); + _tprintf(_T("Type SUBST with no parameters to display a list of current virtual drives.\n")); +} + +BOOLEAN IsSubstedDrive(TCHAR *Drive) +{ + BOOLEAN Result = FALSE; + LPTSTR lpTargetPath = NULL; + DWORD CharCount, dwSize; + + if (_tcslen(Drive) > 2) + return FALSE; + + dwSize = sizeof(TCHAR) * MAX_PATH; + lpTargetPath = (LPTSTR) malloc(sizeof(TCHAR) * MAX_PATH); + if ( lpTargetPath) + { + CharCount = QueryDosDevice(Drive, + lpTargetPath, + dwSize / sizeof(TCHAR)); + while (! CharCount && + GetLastError() == ERROR_INSUFFICIENT_BUFFER) + { + free(lpTargetPath); + dwSize *= 2; + lpTargetPath = (LPTSTR) malloc(dwSize); + if (lpTargetPath) + { + CharCount = QueryDosDevice(Drive, + lpTargetPath, + dwSize / sizeof(TCHAR)); + } + } + + if (CharCount) + { + if ( _tcsncmp(lpTargetPath, _T("\\??\\"), 4) == 0 && + ( (lpTargetPath[4] >= _T('A') && + lpTargetPath[4] <= _T('Z')) || + (lpTargetPath[4] >= _T('a') && + lpTargetPath[4] <= _T('z')) ) ) + { + Result = TRUE; + } + } + free(lpTargetPath); + } + return Result; +} + +void DumpSubstedDrives() +{ + TCHAR Drive[3] = _T("A:"); + LPTSTR lpTargetPath = NULL; + DWORD CharCount, dwSize; + INT i = 0; + + dwSize = sizeof(TCHAR) * MAX_PATH; + lpTargetPath = (LPTSTR) malloc(sizeof(TCHAR) * MAX_PATH); + if (! lpTargetPath) + return; + + while (i < 26) + { + Drive[0] = _T('A') + i; + CharCount = QueryDosDevice(Drive, + lpTargetPath, + dwSize / sizeof(TCHAR)); + while (! CharCount && + GetLastError() == ERROR_INSUFFICIENT_BUFFER) + { + free(lpTargetPath); + dwSize *= 2; + lpTargetPath = (LPTSTR) malloc(dwSize); + if (lpTargetPath) + { + CharCount = QueryDosDevice(Drive, + lpTargetPath, + dwSize / sizeof(TCHAR)); + } + } + + if (! CharCount) + { + i++; + continue; + } + else + { + if ( _tcsncmp(lpTargetPath, _T("\\??\\"), 4) == 0 && + ( (lpTargetPath[4] >= _T('A') && + lpTargetPath[4] <= _T('Z')) || + (lpTargetPath[4] >= _T('a') && + lpTargetPath[4] <= _T('z')) ) ) + { + _tprintf(_T("%s\\: => %s\n"), + Drive, + lpTargetPath + 4); + } + } + i++; + } + free(lpTargetPath); +} + +int DeleteSubst(TCHAR* Drive) +{ + BOOL Result; + + if (_tcslen(Drive) > 2) + { + _tprintf(_T("Invalid parameter - %s\n"), + Drive); + return 1; + } + + if (! IsSubstedDrive(Drive)) + { + _tprintf(_T("Invalid Parameter - %s\n"), + Drive); + return 1; + } + + Result = DefineDosDevice(DDD_REMOVE_DEFINITION, + Drive, + NULL); + if (! Result) + { + PrintError(GetLastError()); + return 1; + } + return 0; +} + +int AddSubst(TCHAR* Drive, TCHAR *Path) +{ + BOOL Result; + + if (_tcslen(Drive) > 2) + { + _tprintf(_T("Invalid parameter - %s\n"), + Drive); + return 1; + } + + if (IsSubstedDrive(Drive)) + { + _tprintf(_T("Drive already SUBSTed\n")); + return 1; + } + + Result = DefineDosDevice(0, + Drive, + Path); + if (! Result) + { + PrintError(GetLastError()); + return 1; + } + return 0; +} + +int _tmain(int argc, TCHAR* argv[]) +{ + INT i; + + for (i = 0; i < argc; i++) + { + if (!_tcsicmp(argv[i], _T("/?"))) + { + DisplaySubstUsage(); + return 0; + } + } + + if (argc < 3) + { + if (argc >= 2) + { + _tprintf(_T("Invalid parameter - %s\n"), + argv[1]); + return 1; + } + DumpSubstedDrives(); + return 0; + } + + if (argc > 3) + { + _tprintf(_T("Incorrect number of parameters - %s\n"), + argv[3]); + return 1; + } + + if (! _tcsicmp(argv[1], _T("/D"))) + return DeleteSubst(argv[2]); + if (! _tcsicmp(argv[2], _T("/D"))) + return DeleteSubst(argv[1]); + return AddSubst(argv[1], argv[2]); +} + +/* EOF */ Propchange: trunk/reactos/base/system/subst/subst.c ------------------------------------------------------------------------------ svn:eol-style = native Added: trunk/reactos/base/system/subst/subst.rbuild URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/subst/subst.rb…
============================================================================== --- trunk/reactos/base/system/subst/subst.rbuild (added) +++ trunk/reactos/base/system/subst/subst.rbuild [iso-8859-1] Mon Apr 18 21:48:19 2011 @@ -1,0 +1,9 @@ +<?xml version="1.0"?> +<!DOCTYPE module SYSTEM "../../../tools/rbuild/project.dtd"> +<module name="subst" type="win32cui" installbase="system32" installname="subst.exe" > + <include base="ReactOS">include/reactos/wine</include> + <include base="subst">.</include> + <library>kernel32</library> + <file>subst.c</file> + <file>subst.rc</file> +</module> Propchange: trunk/reactos/base/system/subst/subst.rbuild ------------------------------------------------------------------------------ svn:eol-style = native Added: trunk/reactos/base/system/subst/subst.rc URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/subst/subst.rc…
============================================================================== --- trunk/reactos/base/system/subst/subst.rc (added) +++ trunk/reactos/base/system/subst/subst.rc [iso-8859-1] Mon Apr 18 21:48:19 2011 @@ -1,0 +1,5 @@ +#include <windows.h> +#define REACTOS_STR_FILE_DESCRIPTION "ReactOS Virtual Drive Utility Version 1.0 \0" +#define REACTOS_STR_INTERNAL_NAME "subst\0" +#define REACTOS_STR_ORIGINAL_FILENAME "subst.exe\0" +#include <reactos/version.rc> Propchange: trunk/reactos/base/system/subst/subst.rc ------------------------------------------------------------------------------ svn:eol-style = native Modified: trunk/reactos/base/system/system.rbuild URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/system.rbuild?…
============================================================================== --- trunk/reactos/base/system/system.rbuild [iso-8859-1] (original) +++ trunk/reactos/base/system/system.rbuild [iso-8859-1] Mon Apr 18 21:48:19 2011 @@ -9,6 +9,9 @@ </directory> <directory name="expand"> <xi:include href="expand/expand.rbuild" /> + </directory> + <directory name="subst"> + <xi:include href="subst/subst.rbuild" /> </directory> <directory name="format"> <xi:include href="format/format.rbuild" /> Modified: trunk/reactos/boot/bootdata/packages/reactos.dff URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/bootdata/packages/rea…
============================================================================== --- trunk/reactos/boot/bootdata/packages/reactos.dff [iso-8859-1] (original) +++ trunk/reactos/boot/bootdata/packages/reactos.dff [iso-8859-1] Mon Apr 18 21:48:19 2011 @@ -115,6 +115,7 @@ base\system\autochk\autochk.exe 1 base\system\bootok\bootok.exe 1 base\system\expand\expand.exe 1 +base\system\subst\subst.exe 1 base\system\format\format.exe 1 base\system\lsass\lsass.exe 1 base\system\msiexec\msiexec.exe 1 Modified: trunk/reactos/dll/win32/kernel32/file/dosdev.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/file/do…
============================================================================== --- trunk/reactos/dll/win32/kernel32/file/dosdev.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/kernel32/file/dosdev.c [iso-8859-1] Mon Apr 18 21:48:19 2011 @@ -14,6 +14,7 @@ #include <k32.h> #define NDEBUG #include <debug.h> +#include <Dbt.h> DEBUG_CHANNEL(kernel32file); /* FUNCTIONS *****************************************************************/ @@ -29,44 +30,55 @@ LPCSTR lpTargetPath ) { - UNICODE_STRING DeviceNameU; - UNICODE_STRING TargetPathU; - BOOL Result; - - if (!RtlCreateUnicodeStringFromAsciiz (&DeviceNameU, - (LPSTR)lpDeviceName)) - { - SetLastError (ERROR_NOT_ENOUGH_MEMORY); - return 0; - } - - if (!RtlCreateUnicodeStringFromAsciiz (&TargetPathU, - (LPSTR)lpTargetPath)) - { - RtlFreeHeap (RtlGetProcessHeap (), - 0, - DeviceNameU.Buffer); - SetLastError (ERROR_NOT_ENOUGH_MEMORY); - return 0; - } - - Result = DefineDosDeviceW (dwFlags, - DeviceNameU.Buffer, - TargetPathU.Buffer); - - RtlFreeHeap (RtlGetProcessHeap (), - 0, - TargetPathU.Buffer); - RtlFreeHeap (RtlGetProcessHeap (), - 0, - DeviceNameU.Buffer); - - return Result; + UNICODE_STRING DeviceNameU = {0}; + UNICODE_STRING TargetPathU = {0}; + BOOL Result; + + if (lpDeviceName && + ! RtlCreateUnicodeStringFromAsciiz(&DeviceNameU, + (LPSTR)lpDeviceName)) + { + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + return 0; + } + + if (lpTargetPath && + ! RtlCreateUnicodeStringFromAsciiz(&TargetPathU, + (LPSTR)lpTargetPath)) + { + if (DeviceNameU.Buffer) + { + RtlFreeHeap(RtlGetProcessHeap (), + 0, + DeviceNameU.Buffer); + } + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + return 0; + } + + Result = DefineDosDeviceW(dwFlags, + DeviceNameU.Buffer, + TargetPathU.Buffer); + + if (TargetPathU.Buffer) + { + RtlFreeHeap(RtlGetProcessHeap (), + 0, + TargetPathU.Buffer); + } + + if (DeviceNameU.Buffer) + { + RtlFreeHeap(RtlGetProcessHeap (), + 0, + DeviceNameU.Buffer); + } + return Result; } /* - * @unimplemented + * @implemented */ BOOL WINAPI @@ -76,8 +88,154 @@ LPCWSTR lpTargetPath ) { - UNIMPLEMENTED; - return FALSE; + ULONG ArgumentCount; + ULONG BufferSize; + PCSR_CAPTURE_BUFFER CaptureBuffer; + CSR_API_MESSAGE Request; + NTSTATUS Status; + UNICODE_STRING NtTargetPathU; + UNICODE_STRING DeviceNameU; + UNICODE_STRING DeviceUpcaseNameU; + HANDLE hUser32; + DEV_BROADCAST_VOLUME dbcv; + BOOL Result = TRUE; + DWORD dwRecipients; + typedef long (WINAPI *BSM_type)(DWORD,LPDWORD,UINT,WPARAM,LPARAM); + BSM_type BSM_ptr; + + if ( (dwFlags & 0xFFFFFFF0) || + ((dwFlags & DDD_EXACT_MATCH_ON_REMOVE) && + ! (dwFlags & DDD_REMOVE_DEFINITION)) ) + { + SetLastError(ERROR_INVALID_PARAMETER); + return FALSE; + } + + ArgumentCount = 1; + BufferSize = 0; + if (! lpTargetPath) + { + RtlInitUnicodeString(&NtTargetPathU, + NULL); + } + else + { + if (dwFlags & DDD_RAW_TARGET_PATH) + { + RtlInitUnicodeString(&NtTargetPathU, + lpTargetPath); + } + else + { + if (! RtlDosPathNameToNtPathName_U(lpTargetPath, + &NtTargetPathU, + 0, + 0)) + { + WARN("RtlDosPathNameToNtPathName_U() failed\n"); + BaseSetLastNTError(STATUS_OBJECT_NAME_INVALID); + return FALSE; + } + } + ArgumentCount = 2; + BufferSize += NtTargetPathU.Length; + } + + RtlInitUnicodeString(&DeviceNameU, + lpDeviceName); + RtlUpcaseUnicodeString(&DeviceUpcaseNameU, + &DeviceNameU, + TRUE); + BufferSize += DeviceUpcaseNameU.Length; + + CaptureBuffer = CsrAllocateCaptureBuffer(ArgumentCount, + BufferSize); + if (! CaptureBuffer) + { + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + Result = FALSE; + } + else + { + Request.Data.DefineDosDeviceRequest.dwFlags = dwFlags; + + CsrCaptureMessageBuffer(CaptureBuffer, + (PVOID)DeviceUpcaseNameU.Buffer, + DeviceUpcaseNameU.Length, + (PVOID*)&Request.Data.DefineDosDeviceRequest.DeviceName.Buffer); + + Request.Data.DefineDosDeviceRequest.DeviceName.Length = + DeviceUpcaseNameU.Length; + Request.Data.DefineDosDeviceRequest.DeviceName.MaximumLength = + DeviceUpcaseNameU.Length; + + if (NtTargetPathU.Buffer) + { + CsrCaptureMessageBuffer(CaptureBuffer, + (PVOID)NtTargetPathU.Buffer, + NtTargetPathU.Length, + (PVOID*)&Request.Data.DefineDosDeviceRequest.TargetName.Buffer); + } + Request.Data.DefineDosDeviceRequest.TargetName.Length = + NtTargetPathU.Length; + Request.Data.DefineDosDeviceRequest.TargetName.MaximumLength = + NtTargetPathU.Length; + + Status = CsrClientCallServer(&Request, + CaptureBuffer, + MAKE_CSR_API(DEFINE_DOS_DEVICE, CSR_CONSOLE), + sizeof(CSR_API_MESSAGE)); + CsrFreeCaptureBuffer(CaptureBuffer); + + if (! NT_SUCCESS(Status) || + ! NT_SUCCESS(Status = Request.Status)) + { + WARN("CsrClientCallServer() failed (Status %lx)\n", + Status); + SetLastErrorByStatus(Status); + Result = FALSE; + } + else + { + if (! (dwFlags & DDD_NO_BROADCAST_SYSTEM) && + DeviceUpcaseNameU.Length == 2 * sizeof(WCHAR) && + DeviceUpcaseNameU.Buffer[1] == L':' && + ( (DeviceUpcaseNameU.Buffer[0] - L'A') < 26 )) + { + hUser32 = LoadLibraryA("user32.dll"); + if (hUser32) + { + BSM_ptr = (BSM_type) + GetProcAddress(hUser32, "BroadcastSystemMessageW"); + if (BSM_ptr) + { + dwRecipients = BSM_APPLICATIONS; + dbcv.dbcv_size = sizeof(DEV_BROADCAST_VOLUME); + dbcv.dbcv_devicetype = DBT_DEVTYP_VOLUME; + dbcv.dbcv_reserved = 0; + dbcv.dbcv_unitmask |= + (1 << (DeviceUpcaseNameU.Buffer[0] - L'A')); + dbcv.dbcv_flags = DBTF_NET; + (void) BSM_ptr(BSF_SENDNOTIFYMESSAGE | BSF_FLUSHDISK, + &dwRecipients, + WM_DEVICECHANGE, + (WPARAM)DBT_DEVICEARRIVAL, + (LPARAM)&dbcv); + } + FreeLibrary(hUser32); + } + } + } + } + + if (NtTargetPathU.Buffer) + { + RtlFreeHeap(RtlGetProcessHeap(), + 0, + NtTargetPathU.Buffer); + } + RtlFreeUnicodeString(&DeviceUpcaseNameU); + return Result; } @@ -250,7 +408,7 @@ TRACE ("TargetLength: %hu\n", UnicodeString.Length); TRACE ("Target: '%wZ'\n", &UnicodeString); - Length = ReturnLength / sizeof(WCHAR); + Length = UnicodeString.Length / sizeof(WCHAR); if (Length < ucchMax) { /* Append null-charcter */ Modified: trunk/reactos/include/reactos/subsys/csrss/csrss.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/subsys/csr…
============================================================================== --- trunk/reactos/include/reactos/subsys/csrss/csrss.h [iso-8859-1] (original) +++ trunk/reactos/include/reactos/subsys/csrss/csrss.h [iso-8859-1] Mon Apr 18 21:48:19 2011 @@ -517,6 +517,13 @@ { UINT UniqueID; } CSRSS_GET_TEMP_FILE, *PCSRSS_GET_TEMP_FILE; + +typedef struct +{ + UNICODE_STRING DeviceName; + UNICODE_STRING TargetName; + DWORD dwFlags; +} CSRSS_DEFINE_DOS_DEVICE, *PCSRSS_DEFINE_DOS_DEVICE; #define CSR_API_MESSAGE_HEADER_SIZE(Type) (FIELD_OFFSET(CSR_API_MESSAGE, Data) + sizeof(Type)) #define CSRSS_MAX_WRITE_CONSOLE (LPC_MAX_DATA_LENGTH - CSR_API_MESSAGE_HEADER_SIZE(CSRSS_WRITE_CONSOLE)) @@ -598,6 +605,7 @@ #define GET_HISTORY_INFO (0x46) #define SET_HISTORY_INFO (0x47) #define GET_TEMP_FILE (0x48) +#define DEFINE_DOS_DEVICE (0X49) /* Keep in sync with definition below. */ #define CSRSS_HEADER_SIZE (sizeof(PORT_MESSAGE) + sizeof(ULONG) + sizeof(NTSTATUS)) @@ -680,6 +688,7 @@ CSRSS_GET_HISTORY_INFO GetHistoryInfo; CSRSS_SET_HISTORY_INFO SetHistoryInfo; CSRSS_GET_TEMP_FILE GetTempFile; + CSRSS_DEFINE_DOS_DEVICE DefineDosDeviceRequest; } Data; } CSR_API_MESSAGE, *PCSR_API_MESSAGE; Modified: trunk/reactos/subsystems/win32/csrss/win32csr/dllmain.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/win…
============================================================================== --- trunk/reactos/subsystems/win32/csrss/win32csr/dllmain.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/csrss/win32csr/dllmain.c [iso-8859-1] Mon Apr 18 21:48:19 2011 @@ -9,11 +9,14 @@ /* INCLUDES ******************************************************************/ #define NDEBUG #include "w32csr.h" +#include "file.h" #include <debug.h> /* Not defined in any header file */ extern VOID WINAPI PrivateCsrssManualGuiCheck(LONG Check); extern VOID WINAPI InitializeAppSwitchHook(); +extern LIST_ENTRY DosDeviceHistory; +extern RTL_CRITICAL_SECTION Win32CsrDefineDosDeviceCritSec; /* GLOBALS *******************************************************************/ @@ -88,6 +91,7 @@ CSRSS_DEFINE_API(GET_HISTORY_INFO, CsrGetHistoryInfo), CSRSS_DEFINE_API(SET_HISTORY_INFO, CsrSetHistoryInfo), CSRSS_DEFINE_API(GET_TEMP_FILE, CsrGetTempFile), + CSRSS_DEFINE_API(DEFINE_DOS_DEVICE, CsrDefineDosDevice), { 0, 0, NULL } }; @@ -104,6 +108,10 @@ InitializeAppSwitchHook(); } + if (DLL_PROCESS_DETACH == dwReason) + { + CsrCleanupDefineDosDevice(); + } return TRUE; } @@ -174,6 +182,8 @@ ServerProcs->ProcessInheritProc = Win32CsrDuplicateHandleTable; ServerProcs->ProcessDeletedProc = Win32CsrReleaseConsole; + Status = RtlInitializeCriticalSection(&Win32CsrDefineDosDeviceCritSec); + InitializeListHead(&DosDeviceHistory); return TRUE; } Modified: trunk/reactos/subsystems/win32/csrss/win32csr/file.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/win…
============================================================================== --- trunk/reactos/subsystems/win32/csrss/win32csr/file.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/csrss/win32csr/file.c [iso-8859-1] Mon Apr 18 21:48:19 2011 @@ -10,13 +10,15 @@ /* INCLUDES ******************************************************************/ #include <w32csr.h> - #define NDEBUG #include <debug.h> +#include "file.h" /* GLOBALS *******************************************************************/ UINT CsrGetTempFileUnique; +LIST_ENTRY DosDeviceHistory; +RTL_CRITICAL_SECTION Win32CsrDefineDosDeviceCritSec; /* FUNCTIONS *****************************************************************/ @@ -31,3 +33,508 @@ return STATUS_SUCCESS; } + +CSR_API(CsrDefineDosDevice) +{ + OBJECT_ATTRIBUTES ObjectAttributes; + HANDLE LinkHandle = NULL; + NTSTATUS Status; + UNICODE_STRING DeviceName = {0}; + UNICODE_STRING RequestDeviceName = {0}; + UNICODE_STRING LinkTarget = {0}; + PUNICODE_STRING RequestLinkTarget; + ULONG Length; + SID_IDENTIFIER_AUTHORITY WorldAuthority = {SECURITY_WORLD_SID_AUTHORITY}; + SID_IDENTIFIER_AUTHORITY SystemAuthority = {SECURITY_NT_AUTHORITY}; + PSECURITY_DESCRIPTOR SecurityDescriptor; + PACL Dacl; + PSID AdminSid; + PSID SystemSid; + PSID WorldSid; + ULONG SidLength; + PCSRSS_DOS_DEVICE_HISTORY_ENTRY HistoryEntry; + PLIST_ENTRY Entry; + PLIST_ENTRY ListHead; + BOOLEAN Matched, AddHistory; + DWORD dwFlags; + PWSTR lpBuffer; + + DPRINT("CsrDefineDosDevice entered, Flags:%d, DeviceName:%wZ, TargetName:%wZ\n", + Request->Data.DefineDosDeviceRequest.dwFlags, + &Request->Data.DefineDosDeviceRequest.DeviceName, + &Request->Data.DefineDosDeviceRequest.TargetName); + + Matched = AddHistory = FALSE; + HistoryEntry = NULL; + AdminSid = SystemSid = WorldSid = NULL; + SecurityDescriptor = NULL; + ListHead = &DosDeviceHistory; + dwFlags = Request->Data.DefineDosDeviceRequest.dwFlags; + + /* Validate the flags */ + if ( (dwFlags & 0xFFFFFFF0) || + ((dwFlags & DDD_EXACT_MATCH_ON_REMOVE) && + ! (dwFlags & DDD_REMOVE_DEFINITION)) ) + { + return STATUS_INVALID_PARAMETER; + } + + Status = RtlEnterCriticalSection(&Win32CsrDefineDosDeviceCritSec); + if (! NT_SUCCESS(Status)) + { + DPRINT1("RtlEnterCriticalSection() failed (Status %lx)", + Status); + return Status; + } + + _SEH2_TRY + { + Status = + RtlUpcaseUnicodeString(&RequestDeviceName, + &Request->Data.DefineDosDeviceRequest.DeviceName, + TRUE); + if (! NT_SUCCESS(Status)) + _SEH2_LEAVE; + + RequestLinkTarget = + &Request->Data.DefineDosDeviceRequest.TargetName; + lpBuffer = (PWSTR) RtlAllocateHeap(Win32CsrApiHeap, + HEAP_ZERO_MEMORY, + RequestDeviceName.MaximumLength + 5 * sizeof(WCHAR)); + if (! lpBuffer) + { + DPRINT1("Failed to allocate memory\n"); + Status = STATUS_NO_MEMORY; + _SEH2_LEAVE; + } + + swprintf(lpBuffer, + L"\\??\\%wZ", + &RequestDeviceName); + RtlInitUnicodeString(&DeviceName, + lpBuffer); + InitializeObjectAttributes(&ObjectAttributes, + &DeviceName, + OBJ_CASE_INSENSITIVE, + NULL, + NULL); + Status = NtOpenSymbolicLinkObject(&LinkHandle, + DELETE | 0x1, + &ObjectAttributes); + if (NT_SUCCESS(Status)) + { + Status = NtQuerySymbolicLinkObject(LinkHandle, + &LinkTarget, + &Length); + if (! NT_SUCCESS(Status) && + Status == STATUS_BUFFER_TOO_SMALL) + { + LinkTarget.Length = 0; + LinkTarget.MaximumLength = Length; + LinkTarget.Buffer = (PWSTR) + RtlAllocateHeap(Win32CsrApiHeap, + HEAP_ZERO_MEMORY, + Length); + if (! LinkTarget.Buffer) + { + DPRINT1("Failed to allocate memory\n"); + Status = STATUS_NO_MEMORY; + _SEH2_LEAVE; + } + + Status = NtQuerySymbolicLinkObject(LinkHandle, + &LinkTarget, + &Length); + } + + if (! NT_SUCCESS(Status)) + { + DPRINT1("NtQuerySymbolicLinkObject(%wZ) failed (Status %lx)", + &DeviceName, Status); + _SEH2_LEAVE; + } + + if ((dwFlags & DDD_REMOVE_DEFINITION)) + { + /* If no target name specified we remove the current symlink target */ + if (RequestLinkTarget->Length == 0) + Matched = TRUE; + else + { + if (dwFlags & DDD_EXACT_MATCH_ON_REMOVE) + Matched = ! RtlCompareUnicodeString(RequestLinkTarget, + &LinkTarget, + TRUE); + else + Matched = RtlPrefixUnicodeString(RequestLinkTarget, + &LinkTarget, + TRUE); + } + + if (Matched && IsListEmpty(ListHead)) + { + /* Current symlink target macthed and there is nothing to revert to */ + RequestLinkTarget = NULL; + } + else if (Matched && ! IsListEmpty(ListHead)) + { + /* Fetch the first history entry we come across for the device name */ + /* This will become the current symlink target for the device name */ + Matched = FALSE; + Entry = ListHead->Flink; + while (Entry != ListHead) + { + HistoryEntry = (PCSRSS_DOS_DEVICE_HISTORY_ENTRY) + CONTAINING_RECORD(Entry, + CSRSS_DOS_DEVICE_HISTORY_ENTRY, + Entry); + Matched = + ! RtlCompareUnicodeString(&RequestDeviceName, + &HistoryEntry->Device, + FALSE); + if (Matched) + { + RemoveEntryList(&HistoryEntry->Entry); + RequestLinkTarget = &HistoryEntry->Target; + break; + } + Entry = Entry->Flink; + HistoryEntry = NULL; + } + + /* Nothing to revert to so delete the symlink */ + if (! Matched) + RequestLinkTarget = NULL; + } + else if (! Matched) + { + /* Locate a previous symlink target as we did not get a hit earlier */ + /* If we find one we need to remove it */ + Entry = ListHead->Flink; + while (Entry != ListHead) + { + HistoryEntry = (PCSRSS_DOS_DEVICE_HISTORY_ENTRY) + CONTAINING_RECORD(Entry, + CSRSS_DOS_DEVICE_HISTORY_ENTRY, + Entry); + Matched = + ! RtlCompareUnicodeString(&RequestDeviceName, + &HistoryEntry->Device, + FALSE); + if (! Matched) + { + HistoryEntry = NULL; + Entry = Entry->Flink; + continue; + } + + Matched = FALSE; + if (dwFlags & DDD_EXACT_MATCH_ON_REMOVE) + { + if (! RtlCompareUnicodeString(RequestLinkTarget, + &HistoryEntry->Target, + TRUE)) + { + Matched = TRUE; + } + } + else if (RtlPrefixUnicodeString(RequestLinkTarget, + &HistoryEntry->Target, + TRUE)) + { + Matched = TRUE; + } + + if (Matched) + { + RemoveEntryList(&HistoryEntry->Entry); + break; + } + Entry = Entry->Flink; + HistoryEntry = NULL; + } + + /* Leave existing symlink as is */ + if (! Matched) + Status = STATUS_OBJECT_NAME_NOT_FOUND; + else + Status = STATUS_SUCCESS; + _SEH2_LEAVE; + } + } + else + { + AddHistory = TRUE; + } + + Status = NtMakeTemporaryObject(LinkHandle); + if (! NT_SUCCESS(Status)) + { + DPRINT1("NtMakeTemporaryObject(%wZ) failed (Status %lx)", + &DeviceName, Status); + _SEH2_LEAVE; + } + + Status = NtClose(LinkHandle); + LinkHandle = NULL; + if (! NT_SUCCESS(Status)) + { + DPRINT1("NtClose(%wZ) failed (Status %lx)", + &DeviceName, Status); + _SEH2_LEAVE; + } + } + + /* Don't create symlink if we don't have a target */ + if (! RequestLinkTarget || RequestLinkTarget->Length == 0) + _SEH2_LEAVE; + + if (AddHistory) + { + HistoryEntry = (PCSRSS_DOS_DEVICE_HISTORY_ENTRY) + RtlAllocateHeap(Win32CsrApiHeap, + HEAP_ZERO_MEMORY, + sizeof(CSRSS_DOS_DEVICE_HISTORY_ENTRY)); + if (! HistoryEntry) + { + DPRINT1("Failed to allocate memory\n"); + Status = STATUS_NO_MEMORY; + _SEH2_LEAVE; + } + + HistoryEntry->Target.Buffer = + RtlAllocateHeap(Win32CsrApiHeap, + HEAP_ZERO_MEMORY, + LinkTarget.Length); + if (! HistoryEntry->Target.Buffer) + { + DPRINT1("Failed to allocate memory\n"); + Status = STATUS_NO_MEMORY; + _SEH2_LEAVE; + } + HistoryEntry->Target.Length = + HistoryEntry->Target.MaximumLength = + LinkTarget.Length; + RtlCopyUnicodeString(&HistoryEntry->Target, + &LinkTarget); + + HistoryEntry->Device.Buffer = + RtlAllocateHeap(Win32CsrApiHeap, + HEAP_ZERO_MEMORY, + RequestDeviceName.Length); + if (! HistoryEntry->Device.Buffer) + { + DPRINT1("Failed to allocate memory\n"); + Status = STATUS_NO_MEMORY; + _SEH2_LEAVE; + } + HistoryEntry->Device.Length = + HistoryEntry->Device.MaximumLength = + RequestDeviceName.Length; + RtlCopyUnicodeString(&HistoryEntry->Device, + &RequestDeviceName); + + /* Remember previous symlink target for this device */ + InsertHeadList(ListHead, + &HistoryEntry->Entry); + HistoryEntry = NULL; + } + + RtlAllocateAndInitializeSid(&WorldAuthority, + 1, + SECURITY_WORLD_RID, + SECURITY_NULL_RID, + SECURITY_NULL_RID, + SECURITY_NULL_RID, + SECURITY_NULL_RID, + SECURITY_NULL_RID, + SECURITY_NULL_RID, + SECURITY_NULL_RID, + &WorldSid); + + RtlAllocateAndInitializeSid(&SystemAuthority, + 1, + SECURITY_LOCAL_SYSTEM_RID, + SECURITY_NULL_RID, + SECURITY_NULL_RID, + SECURITY_NULL_RID, + SECURITY_NULL_RID, + SECURITY_NULL_RID, + SECURITY_NULL_RID, + SECURITY_NULL_RID, + &SystemSid); + + RtlAllocateAndInitializeSid(&SystemAuthority, + 2, + SECURITY_BUILTIN_DOMAIN_RID, + DOMAIN_ALIAS_RID_ADMINS, + SECURITY_NULL_RID, + SECURITY_NULL_RID, + SECURITY_NULL_RID, + SECURITY_NULL_RID, + SECURITY_NULL_RID, + SECURITY_NULL_RID, + &AdminSid); + + SidLength = RtlLengthSid(SystemSid) + + RtlLengthSid(AdminSid) + + RtlLengthSid(WorldSid); + Length = sizeof(ACL) + SidLength + 3 * sizeof(ACCESS_ALLOWED_ACE); + + SecurityDescriptor = RtlAllocateHeap(Win32CsrApiHeap, + 0, + SECURITY_DESCRIPTOR_MIN_LENGTH + Length); + if (! SecurityDescriptor) + { + DPRINT1("Failed to allocate memory\n"); + Status = STATUS_NO_MEMORY; + _SEH2_LEAVE; + } + + Dacl = (PACL)((ULONG_PTR)SecurityDescriptor + SECURITY_DESCRIPTOR_MIN_LENGTH); + Status = RtlCreateSecurityDescriptor(SecurityDescriptor, + SECURITY_DESCRIPTOR_REVISION); + if (! NT_SUCCESS(Status)) + { + DPRINT1("RtlCreateSecurityDescriptor() failed (Status %lx)", + Status); + _SEH2_LEAVE; + } + + Status = RtlCreateAcl(Dacl, + Length, + ACL_REVISION); + if (! NT_SUCCESS(Status)) + { + DPRINT1("RtlCreateAcl() failed (Status %lx)", + Status); + _SEH2_LEAVE; + } + + (void) RtlAddAccessAllowedAce(Dacl, + ACL_REVISION, + GENERIC_ALL, + SystemSid); + (void) RtlAddAccessAllowedAce(Dacl, + ACL_REVISION, + GENERIC_ALL, + AdminSid); + (void) RtlAddAccessAllowedAce(Dacl, + ACL_REVISION, + STANDARD_RIGHTS_READ, + WorldSid); + + Status = RtlSetDaclSecurityDescriptor(SecurityDescriptor, + TRUE, + Dacl, + FALSE); + if (! NT_SUCCESS(Status)) + { + DPRINT1("RtlSetDaclSecurityDescriptor() failed (Status %lx)", + Status); + _SEH2_LEAVE; + } + + InitializeObjectAttributes(&ObjectAttributes, + &DeviceName, + OBJ_CASE_INSENSITIVE, + NULL, + SecurityDescriptor); + Status = NtCreateSymbolicLinkObject(&LinkHandle, + SYMBOLIC_LINK_ALL_ACCESS, + &ObjectAttributes, + RequestLinkTarget); + if (NT_SUCCESS(Status)) + { + Status = NtMakePermanentObject(LinkHandle); + if (! NT_SUCCESS(Status)) + { + DPRINT1("NtMakePermanentObject(%wZ) failed (Status %lx)", + &DeviceName, Status); + } + } + else + { + DPRINT1("NtCreateSymbolicLinkObject(%wZ) failed (Status %lx)", + &DeviceName, Status); + } + } + _SEH2_FINALLY + { + (void) RtlLeaveCriticalSection(&Win32CsrDefineDosDeviceCritSec); + if (DeviceName.Buffer) + (void) RtlFreeHeap(Win32CsrApiHeap, + 0, + DeviceName.Buffer); + if (LinkTarget.Buffer) + (void) RtlFreeHeap(Win32CsrApiHeap, + 0, + LinkTarget.Buffer); + if (SecurityDescriptor) + (void) RtlFreeHeap(Win32CsrApiHeap, + 0, + SecurityDescriptor); + if (LinkHandle) + (void) NtClose(LinkHandle); + if (SystemSid) + (void) RtlFreeSid(SystemSid); + if (AdminSid) + (void) RtlFreeSid(AdminSid); + if (WorldSid) + (void) RtlFreeSid(WorldSid); + RtlFreeUnicodeString(&RequestDeviceName); + if (HistoryEntry) + { + if (HistoryEntry->Target.Buffer) + (void) RtlFreeHeap(Win32CsrApiHeap, + 0, + HistoryEntry->Target.Buffer); + if (HistoryEntry->Device.Buffer) + (void) RtlFreeHeap(Win32CsrApiHeap, + 0, + HistoryEntry->Device.Buffer); + (void) RtlFreeHeap(Win32CsrApiHeap, + 0, + HistoryEntry); + } + } + _SEH2_END + + DPRINT("CsrDefineDosDevice Exit, Statux: 0x%x\n", Status); + return Status; +} + +void CsrCleanupDefineDosDevice() +{ + PLIST_ENTRY Entry, ListHead; + PCSRSS_DOS_DEVICE_HISTORY_ENTRY HistoryEntry; + + (void) RtlDeleteCriticalSection(&Win32CsrDefineDosDeviceCritSec); + + ListHead = &DosDeviceHistory; + Entry = ListHead->Flink; + while (Entry != ListHead) + { + HistoryEntry = (PCSRSS_DOS_DEVICE_HISTORY_ENTRY) + CONTAINING_RECORD(Entry, + CSRSS_DOS_DEVICE_HISTORY_ENTRY, + Entry); + Entry = Entry->Flink; + + if (HistoryEntry) + { + if (HistoryEntry->Target.Buffer) + (void) RtlFreeHeap(Win32CsrApiHeap, + 0, + HistoryEntry->Target.Buffer); + if (HistoryEntry->Device.Buffer) + (void) RtlFreeHeap(Win32CsrApiHeap, + 0, + HistoryEntry->Device.Buffer); + (void) RtlFreeHeap(Win32CsrApiHeap, + 0, + HistoryEntry); + } + } +} +/* EOF */ Modified: trunk/reactos/subsystems/win32/csrss/win32csr/file.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/win…
============================================================================== --- trunk/reactos/subsystems/win32/csrss/win32csr/file.h [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/csrss/win32csr/file.h [iso-8859-1] Mon Apr 18 21:48:19 2011 @@ -11,7 +11,18 @@ #include "api.h" +typedef struct tagCSRSS_DOS_DEVICE_HISTORY_ENTRY +{ + UNICODE_STRING Device; + UNICODE_STRING Target; + LIST_ENTRY Entry; +} CSRSS_DOS_DEVICE_HISTORY_ENTRY, *PCSRSS_DOS_DEVICE_HISTORY_ENTRY; + /* Api functions */ CSR_API(CsrGetTempFile); +CSR_API(CsrDefineDosDevice); + +/* functions */ +void CsrCleanupDefineDosDevice(); /* EOF */
13 years, 8 months
1
0
0
0
[tkreuzer] 51392: [WIN32K] - Use shared locks for surfaces and palettes
by tkreuzer@svn.reactos.org
Author: tkreuzer Date: Mon Apr 18 19:09:05 2011 New Revision: 51392 URL:
http://svn.reactos.org/svn/reactos?rev=51392&view=rev
Log: [WIN32K] - Use shared locks for surfaces and palettes Modified: trunk/reactos/subsystems/win32/win32k/eng/bitblt.c trunk/reactos/subsystems/win32/win32k/eng/stretchblt.c trunk/reactos/subsystems/win32/win32k/ntuser/clipboard.c trunk/reactos/subsystems/win32/win32k/ntuser/cursoricon.c trunk/reactos/subsystems/win32/win32k/ntuser/sysparams.c trunk/reactos/subsystems/win32/win32k/objects/bitmaps.c trunk/reactos/subsystems/win32/win32k/objects/dibobj.c trunk/reactos/subsystems/win32/win32k/objects/icm.c Modified: trunk/reactos/subsystems/win32/win32k/eng/bitblt.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/en…
============================================================================== --- trunk/reactos/subsystems/win32/win32k/eng/bitblt.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/eng/bitblt.c [iso-8859-1] Mon Apr 18 19:09:05 2011 @@ -66,7 +66,7 @@ pebo = CONTAINING_RECORD(pbo, EBRUSHOBJ, BrushObject); hbmPattern = EBRUSHOBJ_pvGetEngBrush(pebo); - psurfPattern = SURFACE_LockSurface(hbmPattern); + psurfPattern = SURFACE_ShareLockSurface(hbmPattern); if (psurfPattern != NULL) { psoPattern = &psurfPattern->SurfObj; @@ -168,7 +168,7 @@ } if (psurfPattern) - SURFACE_UnlockSurface(psurfPattern); + SURFACE_ShareUnlockSurface(psurfPattern); return TRUE; } @@ -230,7 +230,7 @@ { GdiBrush = CONTAINING_RECORD(pbo, EBRUSHOBJ, BrushObject); hbmPattern = EBRUSHOBJ_pvGetEngBrush(GdiBrush); - psurfPattern = SURFACE_LockSurface(hbmPattern); + psurfPattern = SURFACE_ShareLockSurface(hbmPattern); if (psurfPattern) { BltInfo.PatternSurface = &psurfPattern->SurfObj; @@ -250,7 +250,7 @@ /* Pattern brush */ if (psurfPattern) { - SURFACE_UnlockSurface(psurfPattern); + SURFACE_ShareUnlockSurface(psurfPattern); } return Result; Modified: trunk/reactos/subsystems/win32/win32k/eng/stretchblt.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/en…
============================================================================== --- trunk/reactos/subsystems/win32/win32k/eng/stretchblt.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/eng/stretchblt.c [iso-8859-1] Mon Apr 18 19:09:05 2011 @@ -55,7 +55,7 @@ { GdiBrush = CONTAINING_RECORD(pbo, EBRUSHOBJ, BrushObject); hbmPattern = EBRUSHOBJ_pvGetEngBrush(GdiBrush); - psurfPattern = SURFACE_LockSurface(hbmPattern); + psurfPattern = SURFACE_ShareLockSurface(hbmPattern); if (psurfPattern) { PatternSurface = &psurfPattern->SurfObj; @@ -78,7 +78,7 @@ /* Pattern brush */ if (psurfPattern) { - SURFACE_UnlockSurface(psurfPattern); + SURFACE_ShareUnlockSurface(psurfPattern); } return bResult; Modified: trunk/reactos/subsystems/win32/win32k/ntuser/clipboard.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/nt…
============================================================================== --- trunk/reactos/subsystems/win32/win32k/ntuser/clipboard.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/ntuser/clipboard.c [iso-8859-1] Mon Apr 18 19:09:05 2011 @@ -984,11 +984,11 @@ hdc = UserGetDCEx(NULL, NULL, DCX_USESTYLE); - psurf = SURFACE_LockSurface(hMem); + psurf = SURFACE_ShareLockSurface(hMem); BITMAP_GetObject(psurf, sizeof(BITMAP), (PVOID)&bm); if(psurf) { - SURFACE_UnlockSurface(psurf); + SURFACE_ShareUnlockSurface(psurf); } bi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); Modified: trunk/reactos/subsystems/win32/win32k/ntuser/cursoricon.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/nt…
============================================================================== --- trunk/reactos/subsystems/win32/win32k/ntuser/cursoricon.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/ntuser/cursoricon.c [iso-8859-1] Mon Apr 18 19:09:05 2011 @@ -508,11 +508,11 @@ { PSURFACE psurfBmp; - psurfBmp = SURFACE_LockSurface(CurIcon->IconInfo.hbmColor); + psurfBmp = SURFACE_ShareLockSurface(CurIcon->IconInfo.hbmColor); if (psurfBmp) { colorBpp = BitsPerFormat(psurfBmp->SurfObj.iBitmapFormat); - SURFACE_UnlockSurface(psurfBmp); + SURFACE_ShareUnlockSurface(psurfBmp); } } @@ -1197,7 +1197,7 @@ /* In order to correctly display 32 bit icons Windows first scans the image, because information about transparency is not stored in any image's headers */ - psurfOff = SURFACE_LockSurface(hbmColor); + psurfOff = SURFACE_ShareLockSurface(hbmColor); if (psurfOff) { fnSource_GetPixel = DibFunctionsForBitmapFormat[psurfOff->SurfObj.iBitmapFormat].DIB_GetPixel; @@ -1215,7 +1215,7 @@ break; } } - SURFACE_UnlockSurface(psurfOff); + SURFACE_ShareUnlockSurface(psurfOff); } } @@ -1272,7 +1272,7 @@ goto CleanupAlpha; } - psurf = SURFACE_LockSurface(hMemBmp); + psurf = SURFACE_ShareLockSurface(hMemBmp); if(!psurf) { DPRINT1("SURFACE_LockSurface failed!\n"); @@ -1294,7 +1294,7 @@ } } - SURFACE_UnlockSurface(psurf); + SURFACE_ShareUnlockSurface(psurf); hTmpBmp = NtGdiSelectBitmap(hMemDC, hMemBmp); Modified: trunk/reactos/subsystems/win32/win32k/ntuser/sysparams.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/nt…
============================================================================== --- trunk/reactos/subsystems/win32/win32k/ntuser/sysparams.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/ntuser/sysparams.c [iso-8859-1] Mon Apr 18 19:09:05 2011 @@ -634,7 +634,7 @@ } /* Try to get the size of the wallpaper */ - if(!(psurfBmp = SURFACE_LockSurface(hbmp))) + if(!(psurfBmp = SURFACE_ShareLockSurface(hbmp))) { GreDeleteObject(hbmp); return 0; @@ -644,7 +644,7 @@ gpwinstaCurrent->cyWallpaper = psurfBmp->SurfObj.sizlBitmap.cy; gpwinstaCurrent->WallpaperMode = wmCenter; - SURFACE_UnlockSurface(psurfBmp); + SURFACE_ShareUnlockSurface(psurfBmp); /* Change the bitmap's ownership */ GDIOBJ_SetOwnership(hbmp, NULL); @@ -907,7 +907,7 @@ case SPI_SETWORKAREA: { - /*FIXME: we should set the work area of the monitor + /*FIXME: we should set the work area of the monitor that contains the specified rectangle*/ PMONITOR pmonitor = IntGetPrimaryMonitor(); RECT rcWorkArea; Modified: trunk/reactos/subsystems/win32/win32k/objects/bitmaps.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ob…
============================================================================== --- trunk/reactos/subsystems/win32/win32k/objects/bitmaps.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/objects/bitmaps.c [iso-8859-1] Mon Apr 18 19:09:05 2011 @@ -270,7 +270,7 @@ 1, dibs.dsBm.bmBitsPixel, NULL); - psurfBmp = SURFACE_LockSurface(Bmp); + psurfBmp = SURFACE_ShareLockSurface(Bmp); ASSERT(psurfBmp); /* Assign palette */ psurfBmp->ppal = psurf->ppal; @@ -278,7 +278,7 @@ /* Set flags */ psurfBmp->flags = API_BITMAP; psurfBmp->hdc = NULL; // Fixme - SURFACE_UnlockSurface(psurfBmp); + SURFACE_ShareUnlockSurface(psurfBmp); } else if (Count == sizeof(DIBSECTION)) { @@ -316,7 +316,7 @@ return 0; } - PalGDI = PALETTE_LockPalette(psurf->ppal->BaseObject.hHmgr); + PalGDI = PALETTE_ShareLockPalette(psurf->ppal->BaseObject.hHmgr); for (Index = 0; Index < 256 && Index < PalGDI->NumColors; @@ -327,7 +327,7 @@ bi->bmiColors[Index].rgbBlue = PalGDI->IndexedColors[Index].peBlue; bi->bmiColors[Index].rgbReserved = 0; } - PALETTE_UnlockPalette(PalGDI); + PALETTE_ShareUnlockPalette(PalGDI); } Bmp = DIB_CreateDIBSection(Dc, @@ -390,7 +390,7 @@ if (hBitmap == NULL) return FALSE; - psurfBmp = SURFACE_LockSurface(hBitmap); + psurfBmp = SURFACE_ShareLockSurface(hBitmap); if (psurfBmp == NULL) { EngSetLastError(ERROR_INVALID_HANDLE); @@ -408,7 +408,7 @@ } _SEH2_END - SURFACE_UnlockSurface(psurfBmp); + SURFACE_ShareUnlockSurface(psurfBmp); return Ret; } @@ -496,12 +496,12 @@ NtGdiSelectBitmap(hDCTmp, hBmpOld); // our bitmap is no longer selected, so we can access it's stuff... - psurf = SURFACE_LockSurface(hBmpTmp); + psurf = SURFACE_ShareLockSurface(hBmpTmp); if (psurf) { // Dont you need to convert something here? Result = *(COLORREF*)psurf->SurfObj.pvScan0; - SURFACE_UnlockSurface(psurf); + SURFACE_ShareUnlockSurface(psurf); } } GreDeleteObject(hBmpTmp); @@ -598,7 +598,7 @@ return 0; } - psurf = SURFACE_LockSurface(hBitmap); + psurf = SURFACE_ShareLockSurface(hBitmap); if (!psurf) { EngSetLastError(ERROR_INVALID_HANDLE); @@ -612,7 +612,7 @@ /* If the bits vector is null, the function should return the read size */ if (pUnsafeBits == NULL) { - SURFACE_UnlockSurface(psurf); + SURFACE_ShareUnlockSurface(psurf); return bmSize; } @@ -632,7 +632,7 @@ } _SEH2_END - SURFACE_UnlockSurface(psurf); + SURFACE_ShareUnlockSurface(psurf); return ret; } @@ -652,7 +652,7 @@ return 0; } - psurf = SURFACE_LockSurface(hBitmap); + psurf = SURFACE_ShareLockSurface(hBitmap); if (psurf == NULL) { EngSetLastError(ERROR_INVALID_HANDLE); @@ -671,7 +671,7 @@ } _SEH2_END - SURFACE_UnlockSurface(psurf); + SURFACE_ShareUnlockSurface(psurf); return ret; } @@ -689,7 +689,7 @@ if (hBitmap == NULL) return FALSE; - psurf = SURFACE_LockSurface(hBitmap); + psurf = SURFACE_ShareLockSurface(hBitmap); if (psurf == NULL) { EngSetLastError(ERROR_INVALID_HANDLE); @@ -714,7 +714,7 @@ psurf->sizlDim.cx = Width; psurf->sizlDim.cy = Height; - SURFACE_UnlockSurface(psurf); + SURFACE_ShareUnlockSurface(psurf); return Ret; } @@ -998,11 +998,11 @@ IN HBITMAP hsurf) { HDC hdc = NULL; - PSURFACE psurf = SURFACE_LockSurface(hsurf); + PSURFACE psurf = SURFACE_ShareLockSurface(hsurf); if (psurf) { hdc = psurf->hdc; - SURFACE_UnlockSurface(psurf); + SURFACE_ShareUnlockSurface(psurf); } return hdc; } Modified: trunk/reactos/subsystems/win32/win32k/objects/dibobj.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ob…
============================================================================== --- trunk/reactos/subsystems/win32/win32k/objects/dibobj.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/objects/dibobj.c [iso-8859-1] Mon Apr 18 19:09:05 2011 @@ -164,7 +164,7 @@ return 0; } - PalGDI = PALETTE_LockPalette(psurf->ppal->BaseObject.hHmgr); + PalGDI = PALETTE_ShareLockPalette(psurf->ppal->BaseObject.hHmgr); for (Index = StartIndex; Index < StartIndex + Entries && Index < PalGDI->NumColors; @@ -174,7 +174,7 @@ PalGDI->IndexedColors[Index].peGreen = Colors[Index - StartIndex].rgbGreen; PalGDI->IndexedColors[Index].peBlue = Colors[Index - StartIndex].rgbBlue; } - PALETTE_UnlockPalette(PalGDI); + PALETTE_ShareUnlockPalette(PalGDI); } else Entries = 0; @@ -277,8 +277,8 @@ bmi->bmiHeader.biHeight, bmi->bmiHeader.biBitCount)); - psurfDst = SURFACE_LockSurface(hBitmap); - psurfSrc = SURFACE_LockSurface(SourceBitmap); + psurfDst = SURFACE_ShareLockSurface(hBitmap); + psurfSrc = SURFACE_ShareLockSurface(SourceBitmap); if(!(psurfSrc && psurfDst)) { @@ -311,11 +311,11 @@ cleanup: if(psurfSrc) { - SURFACE_UnlockSurface(psurfSrc); + SURFACE_ShareUnlockSurface(psurfSrc); } if(psurfDst) { - SURFACE_UnlockSurface(psurfDst); + SURFACE_ShareUnlockSurface(psurfDst); } GreDeleteObject(SourceBitmap); @@ -766,7 +766,7 @@ /* For color DDBs in native depth (mono DDBs always have a black/white palette): Generate the color map from the selected palette */ - PPALETTE pDcPal = PALETTE_LockPalette(pDC->dclevel.hpal); + PPALETTE pDcPal = PALETTE_ShareLockPalette(pDC->dclevel.hpal); if(!pDcPal) { ScanLines = 0 ; @@ -786,7 +786,7 @@ rgbQuads[i].rgbBlue = pDcPal->IndexedColors[i].peBlue; rgbQuads[i].rgbReserved = 0; } - PALETTE_UnlockPalette(pDcPal); + PALETTE_ShareUnlockPalette(pDcPal); } else { @@ -1548,10 +1548,10 @@ { if(dc) { - PPALETTE pdcPal ; - pdcPal = PALETTE_LockPalette(dc->dclevel.hpal); - hpal = DIB_MapPaletteColors(pdcPal, bmi); - PALETTE_UnlockPalette(pdcPal); + PPALETTE ppalDc; + ppalDc = PALETTE_ShareLockPalette(dc->dclevel.hpal); + hpal = DIB_MapPaletteColors(ppalDc, bmi); + PALETTE_ShareUnlockPalette(ppalDc); } else { Modified: trunk/reactos/subsystems/win32/win32k/objects/icm.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ob…
============================================================================== --- trunk/reactos/subsystems/win32/win32k/objects/icm.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/objects/icm.c [iso-8859-1] Mon Apr 18 19:09:05 2011 @@ -251,7 +251,7 @@ if (!(pGDev->flFlags & PDEV_GAMMARAMP_TABLE)) return FALSE; - palGDI = PALETTE_LockPalette(pGDev->devinfo.hpalDefault); + palGDI = PALETTE_ShareLockPalette(pGDev->devinfo.hpalDefault); if(!palGDI) return FALSE; palPtr = (PALOBJ*) palGDI; @@ -272,7 +272,7 @@ 0, palGDI->NumColors); } - PALETTE_UnlockPalette(palGDI); + PALETTE_ShareUnlockPalette(palGDI); return Ret; } else
13 years, 8 months
1
0
0
0
[tkreuzer] 51391: [WIN32K] Set ulShareCount of static palettes to 1, so they won't get dereferenced to 0
by tkreuzer@svn.reactos.org
Author: tkreuzer Date: Mon Apr 18 14:15:18 2011 New Revision: 51391 URL:
http://svn.reactos.org/svn/reactos?rev=51391&view=rev
Log: [WIN32K] Set ulShareCount of static palettes to 1, so they won't get dereferenced to 0 Modified: trunk/reactos/subsystems/win32/win32k/objects/palette.c Modified: trunk/reactos/subsystems/win32/win32k/objects/palette.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ob…
============================================================================== --- trunk/reactos/subsystems/win32/win32k/objects/palette.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/objects/palette.c [iso-8859-1] Mon Apr 18 14:15:18 2011 @@ -92,33 +92,33 @@ gpalRGB.RedMask = RGB(0xFF, 0x00, 0x00); gpalRGB.GreenMask = RGB(0x00, 0xFF, 0x00); gpalRGB.BlueMask = RGB(0x00, 0x00, 0xFF); - gpalRGB.BaseObject.ulShareCount = 0; + gpalRGB.BaseObject.ulShareCount = 1; gpalRGB.BaseObject.BaseFlags = 0 ; gpalBGR.flFlags = PAL_BGR; gpalBGR.RedMask = RGB(0x00, 0x00, 0xFF); gpalBGR.GreenMask = RGB(0x00, 0xFF, 0x00); gpalBGR.BlueMask = RGB(0xFF, 0x00, 0x00); - gpalBGR.BaseObject.ulShareCount = 0; + gpalBGR.BaseObject.ulShareCount = 1; gpalBGR.BaseObject.BaseFlags = 0 ; gpalRGB555.flFlags = PAL_RGB16_555 | PAL_BITFIELDS; gpalRGB555.RedMask = 0x7C00; gpalRGB555.GreenMask = 0x3E0; gpalRGB555.BlueMask = 0x1F; - gpalRGB555.BaseObject.ulShareCount = 0; + gpalRGB555.BaseObject.ulShareCount = 1; gpalRGB555.BaseObject.BaseFlags = 0 ; gpalRGB565.flFlags = PAL_RGB16_565 | PAL_BITFIELDS; gpalRGB565.RedMask = 0xF800; gpalRGB565.GreenMask = 0x7E0; gpalRGB565.BlueMask = 0x1F; - gpalRGB565.BaseObject.ulShareCount = 0; + gpalRGB565.BaseObject.ulShareCount = 1; gpalRGB565.BaseObject.BaseFlags = 0 ; memset(&gpalMono, 0, sizeof(PALETTE)); gpalMono.flFlags = PAL_MONOCHROME; - gpalMono.BaseObject.ulShareCount = 0; + gpalMono.BaseObject.ulShareCount = 1; gpalMono.BaseObject.BaseFlags = 0 ; /* Initialize default surface palettes */
13 years, 8 months
1
0
0
0
[mjmartin] 51390: [USBEHCI_NEW] - Use PQUEUE_HEAD as the Head of pending list and Async (Active) list vice using PLIST_ENTRY. - Implement linking/unlinking a QueueHead to these Head QueueHeads. - I...
by mjmartin@svn.reactos.org
Author: mjmartin Date: Mon Apr 18 11:34:02 2011 New Revision: 51390 URL:
http://svn.reactos.org/svn/reactos?rev=51390&view=rev
Log: [USBEHCI_NEW] - Use PQUEUE_HEAD as the Head of pending list and Async (Active) list vice using PLIST_ENTRY. - Implement linking/unlinking a QueueHead to these Head QueueHeads. - Implement chain linking/unlinking of QueueHeads. Thr plan being to used these functions during DMA operations to pull a number of QueueHeads from the pending list to place into the Async list for execution. - Will look for optimization in these functions later. Modified: branches/usb-bringup/drivers/usb/usbehci_new/usb_queue.cpp Modified: branches/usb-bringup/drivers/usb/usbehci_new/usb_queue.cpp URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/usb/usbehci…
============================================================================== --- branches/usb-bringup/drivers/usb/usbehci_new/usb_queue.cpp [iso-8859-1] (original) +++ branches/usb-bringup/drivers/usb/usbehci_new/usb_queue.cpp [iso-8859-1] Mon Apr 18 11:34:02 2011 @@ -50,12 +50,16 @@ PDMA_ADAPTER m_Adapter; PVOID VirtualBase; PHYSICAL_ADDRESS PhysicalAddress; - PLIST_ENTRY ExecutingList; - PLIST_ENTRY PendingList; + PQUEUE_HEAD AsyncQueueHead; + PQUEUE_HEAD PendingQueueHead; IDMAMemoryManager *m_MemoryManager; PQUEUE_HEAD CreateQueueHead(); PQUEUE_TRANSFER_DESCRIPTOR CreateDescriptor(UCHAR PIDCode, ULONG TotalBytesToTransfer); + VOID LinkQueueHead(PQUEUE_HEAD HeadQueueHead, PQUEUE_HEAD NewQueueHead); + VOID UnlinkQueueHead(PQUEUE_HEAD QueueHead); + VOID LinkQueueHeadChain(PQUEUE_HEAD HeadQueueHead, PQUEUE_HEAD NewQueueHead); + PQUEUE_HEAD UnlinkQueueHeadChain(PQUEUE_HEAD HeadQueueHead, ULONG Count); }; //================================================================================================= @@ -84,7 +88,6 @@ IN OPTIONAL PKSPIN_LOCK Lock) { NTSTATUS Status; - PQUEUE_HEAD HeadQueueHead; DPRINT1("CUSBQueue::Initialize()\n"); @@ -130,33 +133,28 @@ } // - // Create a dead QueueHead for use in Async Register - // - HeadQueueHead = CreateQueueHead(); - HeadQueueHead->HorizontalLinkPointer = HeadQueueHead->PhysicalAddr | QH_TYPE_QH; - HeadQueueHead->EndPointCharacteristics.QEDTDataToggleControl = FALSE; - HeadQueueHead->Token.Bits.InterruptOnComplete = FALSE; - HeadQueueHead->EndPointCharacteristics.HeadOfReclamation = TRUE; - HeadQueueHead->Token.Bits.Halted = TRUE; + // Create a QueueHead for use in Async Register + // + AsyncQueueHead = CreateQueueHead(); + AsyncQueueHead->HorizontalLinkPointer = AsyncQueueHead->PhysicalAddr | QH_TYPE_QH; + AsyncQueueHead->EndPointCharacteristics.QEDTDataToggleControl = FALSE; + AsyncQueueHead->Token.Bits.InterruptOnComplete = FALSE; + AsyncQueueHead->EndPointCharacteristics.HeadOfReclamation = TRUE; + AsyncQueueHead->Token.Bits.Halted = TRUE; - Hardware->SetAsyncListRegister(HeadQueueHead->PhysicalAddr); - - // - // Set ExecutingList and create PendingList - // - ExecutingList = &HeadQueueHead->LinkedQueueHeads; - PendingList = (PLIST_ENTRY) ExAllocatePool(NonPagedPool, sizeof(LIST_ENTRY)); - if (!PendingList) - { - DPRINT1("Pool allocation failed\n"); - return STATUS_INSUFFICIENT_RESOURCES; - } - - // - // Initialize ListHeads - // - InitializeListHead(ExecutingList); - InitializeListHead(PendingList); + Hardware->SetAsyncListRegister(AsyncQueueHead->PhysicalAddr); + + // + // Create a Unused QueueHead to hold pending QueueHeads + // + PendingQueueHead = CreateQueueHead(); + PendingQueueHead->Token.Bits.Halted = TRUE; + + // + // Initialize ListHead in QueueHeads + // + InitializeListHead(&AsyncQueueHead->LinkedQueueHeads); + InitializeListHead(&PendingQueueHead->LinkedQueueHeads); return STATUS_SUCCESS; } @@ -262,6 +260,9 @@ if (!NT_SUCCESS(Status)) return NULL; + // + // Set default values + // Descriptor->NextPointer = TERMINATE_POINTER; Descriptor->AlternateNextPointer = TERMINATE_POINTER; Descriptor->Token.Bits.DataToggle = TRUE; @@ -270,7 +271,144 @@ Descriptor->Token.Bits.PIDCode = PIDCode; Descriptor->Token.Bits.TotalBytesToTransfer = TotalBytesToTransfer; Descriptor->PhysicalAddr = PhysicalAddress.LowPart; + return Descriptor; +} + +// +// LinkQueueHead - Links one QueueHead to the end of HeadQueueHead list, updating HorizontalLinkPointer. +// +VOID +CUSBQueue::LinkQueueHead( + PQUEUE_HEAD HeadQueueHead, + PQUEUE_HEAD NewQueueHead) +{ + PQUEUE_HEAD LastQueueHead, NextQueueHead; + PLIST_ENTRY Entry; + ASSERT(HeadQueueHead); + ASSERT(NewQueueHead); + + // + // Link the LIST_ENTRYs + // + InsertTailList(&HeadQueueHead->LinkedQueueHeads, &NewQueueHead->LinkedQueueHeads); + + // + // Update HLP for Previous QueueHead, which should be the last in list. + // + Entry = NewQueueHead->LinkedQueueHeads.Blink; + LastQueueHead = CONTAINING_RECORD(Entry, QUEUE_HEAD, LinkedQueueHeads); + LastQueueHead->HorizontalLinkPointer = (NewQueueHead->PhysicalAddr | QH_TYPE_QH); + + // + // Update HLP for NewQueueHead to point to next, which should be the HeadQueueHead + // + Entry = NewQueueHead->LinkedQueueHeads.Flink; + NextQueueHead = CONTAINING_RECORD(Entry, QUEUE_HEAD, LinkedQueueHeads); + ASSERT(NextQueueHead == HeadQueueHead); + NewQueueHead->HorizontalLinkPointer = NextQueueHead->PhysicalAddr; +} + +// +// UnlinkQueueHead - Unlinks one QueueHead, updating HorizontalLinkPointer. +// +VOID +CUSBQueue::UnlinkQueueHead( + PQUEUE_HEAD QueueHead) +{ + PQUEUE_HEAD PreviousQH, NextQH; + PLIST_ENTRY Entry; + + Entry = QueueHead->LinkedQueueHeads.Blink; + PreviousQH = CONTAINING_RECORD(Entry, QUEUE_HEAD, LinkedQueueHeads); + Entry = QueueHead->LinkedQueueHeads.Flink; + NextQH = CONTAINING_RECORD(Entry, QUEUE_HEAD, LinkedQueueHeads); + ASSERT(QueueHead->HorizontalLinkPointer == (NextQH->PhysicalAddr | QH_TYPE_QH)); + PreviousQH->HorizontalLinkPointer = NextQH->PhysicalAddr | QH_TYPE_QH; + + RemoveEntryList(&QueueHead->LinkedQueueHeads); +} + +// +// LinkQueueHeadChain - Links a list of QueueHeads to the HeadQueueHead list, updating HorizontalLinkPointer. +// +VOID +CUSBQueue::LinkQueueHeadChain( + PQUEUE_HEAD HeadQueueHead, + PQUEUE_HEAD NewQueueHead) +{ + PQUEUE_HEAD LastQueueHead; + PLIST_ENTRY Entry; + ASSERT(HeadQueueHead); + ASSERT(NewQueueHead); + + // + // Find the last QueueHead in NewQueueHead + // + Entry = NewQueueHead->LinkedQueueHeads.Blink; + ASSERT(Entry != NewQueueHead->LinkedQueueHeads.Flink); + LastQueueHead = CONTAINING_RECORD(Entry, QUEUE_HEAD, LinkedQueueHeads); + + // + // Set the LinkPointer and Flink + // + LastQueueHead->HorizontalLinkPointer = HeadQueueHead->PhysicalAddr | QH_TYPE_QH; + LastQueueHead->LinkedQueueHeads.Flink = &HeadQueueHead->LinkedQueueHeads; + + // + // Fine the last QueueHead in HeadQueueHead + // + Entry = HeadQueueHead->LinkedQueueHeads.Blink; + HeadQueueHead->LinkedQueueHeads.Blink = &LastQueueHead->LinkedQueueHeads; + LastQueueHead = CONTAINING_RECORD(Entry, QUEUE_HEAD, LinkedQueueHeads); + LastQueueHead->LinkedQueueHeads.Flink = &NewQueueHead->LinkedQueueHeads; + LastQueueHead->HorizontalLinkPointer = NewQueueHead->PhysicalAddr | QH_TYPE_QH; +} + +// +// UnlinkQueueHeadChain - Unlinks a list number of QueueHeads from HeadQueueHead list, updating HorizontalLinkPointer. +// returns the chain of QueueHeads removed from HeadQueueHead. +// +PQUEUE_HEAD +CUSBQueue::UnlinkQueueHeadChain( + PQUEUE_HEAD HeadQueueHead, + ULONG Count) +{ + PQUEUE_HEAD LastQueueHead, FirstQueueHead; + PLIST_ENTRY Entry; + ULONG Index; + + // + // Find the last QueueHead in NewQueueHead + // + Entry = &HeadQueueHead->LinkedQueueHeads; + FirstQueueHead = CONTAINING_RECORD(Entry->Flink, QUEUE_HEAD, LinkedQueueHeads); + + for (Index = 0; Index < Count; Index++) + { + Entry = Entry->Flink; + + if (Entry == &HeadQueueHead->LinkedQueueHeads) + { + DPRINT1("Warnnig; Only %d QueueHeads in HeadQueueHead\n", Index); + Count = Index + 1; + break; + } + } + + LastQueueHead = CONTAINING_RECORD(Entry, QUEUE_HEAD, LinkedQueueHeads); + HeadQueueHead->LinkedQueueHeads.Flink = LastQueueHead->LinkedQueueHeads.Flink; + if (Count + 1 == Index) + { + HeadQueueHead->LinkedQueueHeads.Blink = &HeadQueueHead->LinkedQueueHeads; + } + else + HeadQueueHead->LinkedQueueHeads.Blink = LastQueueHead->LinkedQueueHeads.Flink; + + FirstQueueHead->LinkedQueueHeads.Blink = &LastQueueHead->LinkedQueueHeads; + LastQueueHead->LinkedQueueHeads.Flink = &FirstQueueHead->LinkedQueueHeads; + LastQueueHead->HorizontalLinkPointer = TERMINATE_POINTER; + return FirstQueueHead; } NTSTATUS
13 years, 8 months
1
0
0
0
[gadamopoulos] 51389: [win32k] - GetKeyboardState and SetKeyboardState should use the thread key state and not the global key state
by gadamopoulos@svn.reactos.org
Author: gadamopoulos Date: Mon Apr 18 09:13:31 2011 New Revision: 51389 URL:
http://svn.reactos.org/svn/reactos?rev=51389&view=rev
Log: [win32k] - GetKeyboardState and SetKeyboardState should use the thread key state and not the global key state Modified: trunk/reactos/subsystems/win32/win32k/ntuser/keyboard.c trunk/reactos/subsystems/win32/win32k/ntuser/msgqueue.c Modified: trunk/reactos/subsystems/win32/win32k/ntuser/keyboard.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/nt…
============================================================================== --- trunk/reactos/subsystems/win32/win32k/ntuser/keyboard.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/ntuser/keyboard.c [iso-8859-1] Mon Apr 18 09:13:31 2011 @@ -486,55 +486,6 @@ return Result; } -DWORD -APIENTRY -NtUserGetKeyboardState( - LPBYTE lpKeyState) -{ - BOOL Result = TRUE; - DECLARE_RETURN(DWORD); - - DPRINT("Enter NtUserGetKeyboardState\n"); - UserEnterShared(); - - if (lpKeyState) - { - if(!NT_SUCCESS(MmCopyToCaller(lpKeyState, gQueueKeyStateTable, 256))) - Result = FALSE; - } - - RETURN(Result); - -CLEANUP: - DPRINT("Leave NtUserGetKeyboardState, ret=%i\n",_ret_); - UserLeave(); - END_CLEANUP; -} - -BOOL -APIENTRY -NtUserSetKeyboardState(LPBYTE lpKeyState) -{ - BOOL Result = TRUE; - DECLARE_RETURN(DWORD); - - DPRINT("Enter NtUserSetKeyboardState\n"); - UserEnterExclusive(); - - if (lpKeyState) - { - if(! NT_SUCCESS(MmCopyFromCaller(gQueueKeyStateTable, lpKeyState, 256))) - Result = FALSE; - } - - RETURN(Result); - -CLEANUP: - DPRINT("Leave NtUserSetKeyboardState, ret=%i\n",_ret_); - UserLeave(); - END_CLEANUP; -} - static UINT VkToScan( UINT Code, BOOL ExtCode, PKBDTABLES pkKT ) { int i; Modified: trunk/reactos/subsystems/win32/win32k/ntuser/msgqueue.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/nt…
============================================================================== --- trunk/reactos/subsystems/win32/win32k/ntuser/msgqueue.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/ntuser/msgqueue.c [iso-8859-1] Mon Apr 18 09:13:31 2011 @@ -1896,4 +1896,66 @@ return Ret; } + +DWORD +APIENTRY +NtUserGetKeyboardState(LPBYTE lpKeyState) +{ + DWORD ret = TRUE; + PTHREADINFO pti; + PUSER_MESSAGE_QUEUE MessageQueue; + + UserEnterShared(); + + pti = PsGetCurrentThreadWin32Thread(); + MessageQueue = pti->MessageQueue; + + _SEH2_TRY + { + ProbeForWrite(lpKeyState,sizeof(MessageQueue->KeyState) ,1); + RtlCopyMemory(lpKeyState,MessageQueue->KeyState,sizeof(MessageQueue->KeyState)); + } + _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) + { + SetLastNtError(_SEH2_GetExceptionCode()); + ret = FALSE; + } + _SEH2_END; + + UserLeave(); + + return ret; +} + +BOOL +APIENTRY +NtUserSetKeyboardState(LPBYTE lpKeyState) +{ + DWORD ret = TRUE; + PTHREADINFO pti; + PUSER_MESSAGE_QUEUE MessageQueue; + + UserEnterExclusive(); + + pti = PsGetCurrentThreadWin32Thread(); + MessageQueue = pti->MessageQueue; + + _SEH2_TRY + { + ProbeForRead(lpKeyState,sizeof(MessageQueue->KeyState) ,1); + RtlCopyMemory(MessageQueue->KeyState,lpKeyState,sizeof(MessageQueue->KeyState)); + } + _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) + { + SetLastNtError(_SEH2_GetExceptionCode()); + ret = FALSE; + } + _SEH2_END; + + UserLeave(); + + return ret; +} + + /* EOF */
13 years, 8 months
1
0
0
0
[mjmartin] 51388: [USBEHCI_NEW] - Use LIST_ENTRY in QueueHeads and Descriptors vice Next and Previous Pointers. - Add functions to interface for setting AsyncListRegister and PeriodicListRegister. ...
by mjmartin@svn.reactos.org
Author: mjmartin Date: Mon Apr 18 00:06:37 2011 New Revision: 51388 URL:
http://svn.reactos.org/svn/reactos?rev=51388&view=rev
Log: [USBEHCI_NEW] - Use LIST_ENTRY in QueueHeads and Descriptors vice Next and Previous Pointers. - Add functions to interface for setting AsyncListRegister and PeriodicListRegister. - USBHardwareDevice: Initialize USBQueue when handling PNPStart. - USBQueue: Allocate Common Buffer and use it to Create and Initialize DmaMemoryManager object. - USBQueue: Implement CreateQueueHead and CreateDescriptor. Modified: branches/usb-bringup/drivers/usb/usbehci_new/hardware.cpp branches/usb-bringup/drivers/usb/usbehci_new/hardware.h branches/usb-bringup/drivers/usb/usbehci_new/interfaces.h branches/usb-bringup/drivers/usb/usbehci_new/usb_queue.cpp Modified: branches/usb-bringup/drivers/usb/usbehci_new/hardware.cpp URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/usb/usbehci…
============================================================================== --- branches/usb-bringup/drivers/usb/usbehci_new/hardware.cpp [iso-8859-1] (original) +++ branches/usb-bringup/drivers/usb/usbehci_new/hardware.cpp [iso-8859-1] Mon Apr 18 00:06:37 2011 @@ -60,7 +60,7 @@ NTSTATUS ResetController(); NTSTATUS ResetPort(ULONG PortIndex); - VOID SetAsyncListAddressRegister(ULONG PhysicalAddress); + VOID SetAsyncListRegister(ULONG PhysicalAddress); VOID SetPeriodicListRegister(ULONG PhysicalAddress); KIRQL AcquireDeviceLock(void); @@ -132,12 +132,16 @@ DPRINT1("CUSBHardwareDevice::Initialize\n"); + // + // Create the UsbQueue class that will handle the Asynchronous and Periodic Schedules + // Status = CreateUSBQueue(&m_UsbQueue); if (!NT_SUCCESS(Status)) { DPRINT1("Failed to create UsbQueue!\n"); return Status; } + // // store device objects // @@ -333,8 +337,26 @@ } // + // Stop the controller before modifying schedules + // + Status = StopController(); + if (!NT_SUCCESS(Status)) + return Status; + + // + // Initialize the UsbQueue now that we have an AdapterObject. + // + Status = m_UsbQueue->Initialize(PUSBHARDWAREDEVICE(this), m_Adapter, NULL); + if (!NT_SUCCESS(Status)) + { + DPRINT1("Failed to Initialize the UsbQueue\n"); + return Status; + } + + // // Start the controller // + DPRINT1("Starting Controller\n"); return StartController(); } @@ -369,7 +391,7 @@ *NumberOfPorts = m_Capabilities.HCSParams.PortCount; //FIXME: What to returned here? if (Speed) - *Speed = 0; + *Speed = 0x200; return STATUS_SUCCESS; } @@ -477,6 +499,7 @@ // Set port routing to EHCI controller // EHCI_WRITE_REGISTER_ULONG(EHCI_CONFIGFLAG, 1); + DPRINT1("EHCI Started!\n"); return STATUS_SUCCESS; } @@ -489,6 +512,7 @@ // // Disable Interrupts and stop execution + // EHCI_WRITE_REGISTER_ULONG (EHCI_USBINTR, 0); GetCommandRegister(&UsbCmd); @@ -565,25 +589,11 @@ return STATUS_SUCCESS; } -//----------------------------------------------------------------------------------------- -// -// SetAsyncListAddressRegister -// -// Description: this functions sets the register to a address that is the physical address of a QueueHead. -// This is the location at which the controller will start executing the Asynchronous Schedule. -// -VOID CUSBHardwareDevice::SetAsyncListAddressRegister(ULONG PhysicalAddress) +VOID CUSBHardwareDevice::SetAsyncListRegister(ULONG PhysicalAddress) { EHCI_WRITE_REGISTER_ULONG(EHCI_ASYNCLISTBASE, PhysicalAddress); } -//----------------------------------------------------------------------------------------- -// -// SetPeriodicListRegister -// -// Description: this functions sets the register to a address that is the physical address of a ???. -// This is the location at which the controller will start executing the Periodic Schedule. -// VOID CUSBHardwareDevice::SetPeriodicListRegister(ULONG PhysicalAddress) { EHCI_WRITE_REGISTER_ULONG(EHCI_PERIODICLISTBASE, PhysicalAddress); Modified: branches/usb-bringup/drivers/usb/usbehci_new/hardware.h URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/usb/usbehci…
============================================================================== --- branches/usb-bringup/drivers/usb/usbehci_new/hardware.h [iso-8859-1] (original) +++ branches/usb-bringup/drivers/usb/usbehci_new/hardware.h [iso-8859-1] Mon Apr 18 00:06:37 2011 @@ -125,8 +125,7 @@ //Software ULONG PhysicalAddr; - struct _QUEUE_TRANSFER_DESCRIPTOR *PreviousDescriptor; - struct _QUEUE_TRANSFER_DESCRIPTOR *NextDescriptor; + LIST_ENTRY LinkedDescriptors; } QUEUE_TRANSFER_DESCRIPTOR, *PQUEUE_TRANSFER_DESCRIPTOR; // @@ -190,8 +189,7 @@ //Software ULONG PhysicalAddr; - struct _QUEUE_HEAD *PreviousQueueHead; - struct _QUEUE_HEAD *NextQueueHead; + LIST_ENTRY LinkedQueueHeads; PQUEUE_TRANSFER_DESCRIPTOR TransferDescriptor; PIRP IrpToComplete; PMDL MdlToFree; Modified: branches/usb-bringup/drivers/usb/usbehci_new/interfaces.h URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/usb/usbehci…
============================================================================== --- branches/usb-bringup/drivers/usb/usbehci_new/interfaces.h [iso-8859-1] (original) +++ branches/usb-bringup/drivers/usb/usbehci_new/interfaces.h [iso-8859-1] Mon Apr 18 00:06:37 2011 @@ -209,6 +209,25 @@ // virtual NTSTATUS ResetPort(ULONG PortNumber) = 0; + +//----------------------------------------------------------------------------------------- +// +// SetAsyncListRegister +// +// Description: this functions sets the register to a address that is the physical address of a QueueHead. +// This is the location at which the controller will start executing the Asynchronous Schedule. +// +// FIXME: This is only available for USB 2.0 + virtual VOID SetAsyncListRegister(ULONG PhysicalAddress) = 0; + +//----------------------------------------------------------------------------------------- +// +// SetPeriodicListRegister +// +// Description: this functions sets the register to a address that is the physical address of a ???. +// This is the location at which the controller will start executing the Periodic Schedule. +// + virtual VOID SetPeriodicListRegister(ULONG PhysicalAddress) = 0; //----------------------------------------------------------------------------------------- // @@ -374,7 +393,7 @@ // Description: initializes the object virtual NTSTATUS Initialize(IN PUSBHARDWAREDEVICE Hardware, - PADAPTER_OBJECT AdapterObject, + PDMA_ADAPTER AdapterObject, IN OPTIONAL PKSPIN_LOCK Lock) = 0; //----------------------------------------------------------------------------------------- Modified: branches/usb-bringup/drivers/usb/usbehci_new/usb_queue.cpp URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/usb/usbehci…
============================================================================== --- branches/usb-bringup/drivers/usb/usbehci_new/usb_queue.cpp [iso-8859-1] (original) +++ branches/usb-bringup/drivers/usb/usbehci_new/usb_queue.cpp [iso-8859-1] Mon Apr 18 00:06:37 2011 @@ -33,7 +33,7 @@ return m_Ref; } - NTSTATUS Initialize(IN PUSBHARDWAREDEVICE Hardware, PADAPTER_OBJECT AdapterObject, IN OPTIONAL PKSPIN_LOCK Lock); + NTSTATUS Initialize(IN PUSBHARDWAREDEVICE Hardware, PDMA_ADAPTER AdapterObject, IN OPTIONAL PKSPIN_LOCK Lock); ULONG GetPendingRequestCount(); NTSTATUS AddUSBRequest(PURB Urb); NTSTATUS AddUSBRequest(IUSBRequest * Request); @@ -46,10 +46,16 @@ protected: LONG m_Ref; + KSPIN_LOCK m_Lock; PDMA_ADAPTER m_Adapter; - PQUEUE_HEAD ExecutingList; - PQUEUE_HEAD PendingList; + PVOID VirtualBase; + PHYSICAL_ADDRESS PhysicalAddress; + PLIST_ENTRY ExecutingList; + PLIST_ENTRY PendingList; IDMAMemoryManager *m_MemoryManager; + + PQUEUE_HEAD CreateQueueHead(); + PQUEUE_TRANSFER_DESCRIPTOR CreateDescriptor(UCHAR PIDCode, ULONG TotalBytesToTransfer); }; //================================================================================================= @@ -74,14 +80,33 @@ NTSTATUS CUSBQueue::Initialize( IN PUSBHARDWAREDEVICE Hardware, - PADAPTER_OBJECT AdapterObject, + PDMA_ADAPTER AdapterObject, IN OPTIONAL PKSPIN_LOCK Lock) { NTSTATUS Status; + PQUEUE_HEAD HeadQueueHead; + + DPRINT1("CUSBQueue::Initialize()\n"); ASSERT(Hardware); ASSERT(AdapterObject); + // + // Create Common Buffer + // + VirtualBase = AdapterObject->DmaOperations->AllocateCommonBuffer(AdapterObject, + PAGE_SIZE * 4, + &PhysicalAddress, + FALSE); + if (!VirtualBase) + { + DPRINT1("Failed to allocate a common buffer\n"); + return STATUS_INSUFFICIENT_RESOURCES; + } + + // + // Create DMAMemoryManager for use with QueueHeads and Transfer Descriptors. + // Status = CreateDMAMemoryManager(&m_MemoryManager); if (!NT_SUCCESS(Status)) { @@ -89,6 +114,50 @@ return Status; } + // + // initialize device lock + // + KeInitializeSpinLock(&m_Lock); + + // + // Initialize the DMAMemoryManager + // + Status = m_MemoryManager->Initialize(Hardware, &m_Lock, PAGE_SIZE * 4, VirtualBase, PhysicalAddress, 32); + if (!NT_SUCCESS(Status)) + { + DPRINT1("Failed to initialize the DMAMemoryManager\n"); + return Status; + } + + // + // Create a dead QueueHead for use in Async Register + // + HeadQueueHead = CreateQueueHead(); + HeadQueueHead->HorizontalLinkPointer = HeadQueueHead->PhysicalAddr | QH_TYPE_QH; + HeadQueueHead->EndPointCharacteristics.QEDTDataToggleControl = FALSE; + HeadQueueHead->Token.Bits.InterruptOnComplete = FALSE; + HeadQueueHead->EndPointCharacteristics.HeadOfReclamation = TRUE; + HeadQueueHead->Token.Bits.Halted = TRUE; + + Hardware->SetAsyncListRegister(HeadQueueHead->PhysicalAddr); + + // + // Set ExecutingList and create PendingList + // + ExecutingList = &HeadQueueHead->LinkedQueueHeads; + PendingList = (PLIST_ENTRY) ExAllocatePool(NonPagedPool, sizeof(LIST_ENTRY)); + if (!PendingList) + { + DPRINT1("Pool allocation failed\n"); + return STATUS_INSUFFICIENT_RESOURCES; + } + + // + // Initialize ListHeads + // + InitializeListHead(ExecutingList); + InitializeListHead(PendingList); + return STATUS_SUCCESS; } @@ -128,6 +197,80 @@ { UNIMPLEMENTED return STATUS_NOT_IMPLEMENTED; +} + +PQUEUE_HEAD +CUSBQueue::CreateQueueHead() +{ + PQUEUE_HEAD QueueHead; + PHYSICAL_ADDRESS PhysicalAddress; + NTSTATUS Status; + // + // Create the QueueHead from Common Buffer + // + Status = m_MemoryManager->Allocate(sizeof(QUEUE_HEAD), + (PVOID*)&QueueHead, + &PhysicalAddress); + if (!NT_SUCCESS(Status)) + return NULL; + + // + // Initialize default values + // + + QueueHead->PhysicalAddr = PhysicalAddress.LowPart; + QueueHead->HorizontalLinkPointer = TERMINATE_POINTER; + QueueHead->AlternateNextPointer = TERMINATE_POINTER; + QueueHead->NextPointer = TERMINATE_POINTER; + + // 1 for non high speed, 0 for high speed device + QueueHead->EndPointCharacteristics.ControlEndPointFlag = 0; + QueueHead->EndPointCharacteristics.HeadOfReclamation = FALSE; + QueueHead->EndPointCharacteristics.MaximumPacketLength = 64; + + // Set NakCountReload to max value possible + QueueHead->EndPointCharacteristics.NakCountReload = 0xF; + + // Get the Initial Data Toggle from the Queue Element Desriptor + QueueHead->EndPointCharacteristics.QEDTDataToggleControl = FALSE; + + QueueHead->EndPointCharacteristics.EndPointSpeed = QH_ENDPOINT_HIGHSPEED; + + QueueHead->EndPointCapabilities.NumberOfTransactionPerFrame = 0x03; + + // Interrupt when QueueHead is processed + QueueHead->Token.Bits.InterruptOnComplete = FALSE; + + return QueueHead; +} + +PQUEUE_TRANSFER_DESCRIPTOR +CUSBQueue::CreateDescriptor( + UCHAR PIDCode, + ULONG TotalBytesToTransfer) +{ + PQUEUE_TRANSFER_DESCRIPTOR Descriptor; + PHYSICAL_ADDRESS PhysicalAddress; + NTSTATUS Status; + + // + // Create the Descriptor from Common Buffer + // + Status = m_MemoryManager->Allocate(sizeof(QUEUE_TRANSFER_DESCRIPTOR), + (PVOID*)&Descriptor, + &PhysicalAddress); + if (!NT_SUCCESS(Status)) + return NULL; + + Descriptor->NextPointer = TERMINATE_POINTER; + Descriptor->AlternateNextPointer = TERMINATE_POINTER; + Descriptor->Token.Bits.DataToggle = TRUE; + Descriptor->Token.Bits.ErrorCounter = 0x03; + Descriptor->Token.Bits.Active = TRUE; + Descriptor->Token.Bits.PIDCode = PIDCode; + Descriptor->Token.Bits.TotalBytesToTransfer = TotalBytesToTransfer; + Descriptor->PhysicalAddr = PhysicalAddress.LowPart; + return Descriptor; } NTSTATUS
13 years, 8 months
1
0
0
0
[janderwald] 51387: [USBEHCI_NEW] - Add interface function GetHubControllerSymbolicLink - Implement IOCTL_USB_GET_ROOT_HUB_NAME for usbview
by janderwald@svn.reactos.org
Author: janderwald Date: Sun Apr 17 22:38:32 2011 New Revision: 51387 URL:
http://svn.reactos.org/svn/reactos?rev=51387&view=rev
Log: [USBEHCI_NEW] - Add interface function GetHubControllerSymbolicLink - Implement IOCTL_USB_GET_ROOT_HUB_NAME for usbview Modified: branches/usb-bringup/drivers/usb/usbehci_new/hcd_controller.cpp branches/usb-bringup/drivers/usb/usbehci_new/hub_controller.cpp branches/usb-bringup/drivers/usb/usbehci_new/interfaces.h Modified: branches/usb-bringup/drivers/usb/usbehci_new/hcd_controller.cpp URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/usb/usbehci…
============================================================================== --- branches/usb-bringup/drivers/usb/usbehci_new/hcd_controller.cpp [iso-8859-1] (original) +++ branches/usb-bringup/drivers/usb/usbehci_new/hcd_controller.cpp [iso-8859-1] Sun Apr 17 22:38:32 2011 @@ -230,87 +230,123 @@ // DeviceExtension = (PCOMMON_DEVICE_EXTENSION)DeviceObject->DeviceExtension; - - DPRINT1("HandleDeviceControl>Type: FDO %u IoCtl %x InputBufferLength %lu OutputBufferLength %lu\n", - DeviceExtension->IsFDO, + // + // sanity check + // + PC_ASSERT(DeviceExtension->IsFDO); + + DPRINT1("HandleDeviceControl>Type: IoCtl %x InputBufferLength %lu OutputBufferLength %lu\n", IoStack->Parameters.DeviceIoControl.IoControlCode, IoStack->Parameters.DeviceIoControl.InputBufferLength, IoStack->Parameters.DeviceIoControl.OutputBufferLength); // - // get device type - // - if (DeviceExtension->IsFDO) - { - // - // perform ioctl for FDO - // - if (IoStack->Parameters.DeviceIoControl.IoControlCode == IOCTL_GET_HCD_DRIVERKEY_NAME) - { - // - // check if sizee is at least >= USB_HCD_DRIVERKEY_NAME - // - if(IoStack->Parameters.DeviceIoControl.OutputBufferLength >= sizeof(USB_HCD_DRIVERKEY_NAME)) - { - // - // get device property size - // - Status = IoGetDeviceProperty(m_PhysicalDeviceObject, DevicePropertyDriverKeyName, 0, NULL, &ResultLength); - - DriverKey = (PUSB_HCD_DRIVERKEY_NAME)Irp->AssociatedIrp.SystemBuffer; - - // - // check result - // - if (Status == STATUS_BUFFER_TOO_SMALL) + // perform ioctl for FDO + // + if (IoStack->Parameters.DeviceIoControl.IoControlCode == IOCTL_GET_HCD_DRIVERKEY_NAME) + { + // + // check if sizee is at least >= USB_HCD_DRIVERKEY_NAME + // + if(IoStack->Parameters.DeviceIoControl.OutputBufferLength >= sizeof(USB_HCD_DRIVERKEY_NAME)) + { + // + // get device property size + // + Status = IoGetDeviceProperty(m_PhysicalDeviceObject, DevicePropertyDriverKeyName, 0, NULL, &ResultLength); + + // + // get input buffer + // + DriverKey = (PUSB_HCD_DRIVERKEY_NAME)Irp->AssociatedIrp.SystemBuffer; + + // + // check result + // + if (Status == STATUS_BUFFER_TOO_SMALL) + { + // + // does the caller provide enough buffer space + // + if (IoStack->Parameters.DeviceIoControl.OutputBufferLength >= ResultLength) { // - // does the caller provide enough buffer space - // - if (IoStack->Parameters.DeviceIoControl.OutputBufferLength >= ResultLength) + // it does + // + Status = IoGetDeviceProperty(m_PhysicalDeviceObject, DevicePropertyDriverKeyName, IoStack->Parameters.DeviceIoControl.OutputBufferLength - sizeof(ULONG), DriverKey->DriverKeyName, &ResultLength); + + if (NT_SUCCESS(Status)) { // - // it does + // informal debug print // - Status = IoGetDeviceProperty(m_PhysicalDeviceObject, DevicePropertyDriverKeyName, IoStack->Parameters.DeviceIoControl.OutputBufferLength - sizeof(ULONG), DriverKey->DriverKeyName, &ResultLength); - - if (NT_SUCCESS(Status)) - { - // - // informal debug print - // - DPRINT1("Result %S\n", DriverKey->DriverKeyName); - } + DPRINT1("Result %S\n", DriverKey->DriverKeyName); } - - // - // store result - // - DriverKey->ActualLength = ResultLength + FIELD_OFFSET(USB_HCD_DRIVERKEY_NAME, DriverKeyName) + sizeof(WCHAR); - Irp->IoStatus.Information = IoStack->Parameters.DeviceIoControl.OutputBufferLength; - Status = STATUS_SUCCESS; } - } - else - { - // - // buffer is certainly too small - // - Status = STATUS_BUFFER_OVERFLOW; - Irp->IoStatus.Information = sizeof(USB_HCD_DRIVERKEY_NAME); - } - } - else if (IoStack->Parameters.DeviceIoControl.IoControlCode == IOCTL_USB_GET_ROOT_HUB_NAME) - { - DPRINT1("IOCTL_USB_GET_ROOT_HUB_NAME is not implemented yet\n"); - } - } - else - { - // - // the PDO does not support any device IOCTLs - // - Status = STATUS_SUCCESS; + + // + // store result + // + DriverKey->ActualLength = ResultLength + FIELD_OFFSET(USB_HCD_DRIVERKEY_NAME, DriverKeyName) + sizeof(WCHAR); + Irp->IoStatus.Information = IoStack->Parameters.DeviceIoControl.OutputBufferLength; + Status = STATUS_SUCCESS; + } + } + else + { + // + // buffer is certainly too small + // + Status = STATUS_BUFFER_OVERFLOW; + Irp->IoStatus.Information = sizeof(USB_HCD_DRIVERKEY_NAME); + } + } + else if (IoStack->Parameters.DeviceIoControl.IoControlCode == IOCTL_USB_GET_ROOT_HUB_NAME) + { + // + // check if sizee is at least >= USB_HCD_DRIVERKEY_NAME + // + if(IoStack->Parameters.DeviceIoControl.OutputBufferLength >= sizeof(USB_HCD_DRIVERKEY_NAME)) + { + // + // sanity check + // + PC_ASSERT(m_HubController); + + // + // get input buffer + // + DriverKey = (PUSB_HCD_DRIVERKEY_NAME)Irp->AssociatedIrp.SystemBuffer; + + // + // get symbolic link + // + Status = m_HubController->GetHubControllerSymbolicLink(IoStack->Parameters.DeviceIoControl.OutputBufferLength - sizeof(ULONG), DriverKey->DriverKeyName, &ResultLength); + + + if (NT_SUCCESS(Status)) + { + // + // informal debug print + // + DPRINT1("Result %S\n", DriverKey->DriverKeyName); + } + + // + // store result + // + DriverKey->ActualLength = ResultLength + FIELD_OFFSET(USB_HCD_DRIVERKEY_NAME, DriverKeyName) + sizeof(WCHAR); + Irp->IoStatus.Information = IoStack->Parameters.DeviceIoControl.OutputBufferLength; + Status = STATUS_SUCCESS; + } + else + { + // + // buffer is certainly too small + // + Status = STATUS_BUFFER_OVERFLOW; + Irp->IoStatus.Information = sizeof(USB_HCD_DRIVERKEY_NAME); + } } // Modified: branches/usb-bringup/drivers/usb/usbehci_new/hub_controller.cpp URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/usb/usbehci…
============================================================================== --- branches/usb-bringup/drivers/usb/usbehci_new/hub_controller.cpp [iso-8859-1] (original) +++ branches/usb-bringup/drivers/usb/usbehci_new/hub_controller.cpp [iso-8859-1] Sun Apr 17 22:38:32 2011 @@ -36,6 +36,8 @@ // IHubController interface functions virtual NTSTATUS Initialize(IN PDRIVER_OBJECT DriverObject, IN PHCDCONTROLLER Controller, IN PUSBHARDWAREDEVICE Device, IN BOOLEAN IsRootHubDevice, IN ULONG DeviceAddress); + virtual NTSTATUS GetHubControllerDeviceObject(PDEVICE_OBJECT * HubDeviceObject); + virtual NTSTATUS GetHubControllerSymbolicLink(ULONG BufferLength, PVOID Buffer, PULONG RequiredLength); // IDispatchIrp interface functions virtual NTSTATUS HandlePnp(IN PDEVICE_OBJECT DeviceObject, IN OUT PIRP Irp); @@ -46,7 +48,6 @@ NTSTATUS HandleQueryInterface(PIO_STACK_LOCATION IoStack); NTSTATUS SetDeviceInterface(BOOLEAN bEnable); NTSTATUS CreatePDO(PDRIVER_OBJECT DriverObject, PDEVICE_OBJECT * OutDeviceObject); - NTSTATUS GetHubControllerDeviceObject(PDEVICE_OBJECT * HubDeviceObject); PUSBHARDWAREDEVICE GetUsbHardware(); ULONG AcquireDeviceAddress(); VOID ReleaseDeviceAddress(ULONG DeviceAddress); @@ -71,8 +72,10 @@ PUSBHARDWAREDEVICE m_Hardware; BOOLEAN m_IsRootHubDevice; ULONG m_DeviceAddress; + BOOLEAN m_InterfaceEnabled; UNICODE_STRING m_HubDeviceInterfaceString; + PDEVICE_OBJECT m_HubControllerDeviceObject; PDRIVER_OBJECT m_DriverObject; @@ -267,6 +270,51 @@ return STATUS_SUCCESS; } +//----------------------------------------------------------------------------------------- +NTSTATUS +CHubController::GetHubControllerSymbolicLink( + ULONG BufferLength, + PVOID Buffer, + PULONG RequiredLength) +{ + if (!m_InterfaceEnabled) + { + // + // device interface not yet enabled + // + return STATUS_UNSUCCESSFUL; + } + + if (BufferLength < m_HubDeviceInterfaceString.Length - 8) + { + // + // buffer too small + // length is without '\??\' + // + *RequiredLength = m_HubDeviceInterfaceString.Length- 8; + + // + // done + // + return STATUS_BUFFER_OVERFLOW; + } + + // + // copy symbolic link + // + RtlCopyMemory(Buffer, &m_HubDeviceInterfaceString.Buffer[4], m_HubDeviceInterfaceString.Length - 8); + + // + // store length, length is without '\??\' + // + *RequiredLength = m_HubDeviceInterfaceString.Length - 8; + + // + // done + // + return STATUS_SUCCESS; +} + //----------------------------------------------------------------------------------------- NTSTATUS CHubController::HandlePnp( Modified: branches/usb-bringup/drivers/usb/usbehci_new/interfaces.h URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/usb/usbehci…
============================================================================== --- branches/usb-bringup/drivers/usb/usbehci_new/interfaces.h [iso-8859-1] (original) +++ branches/usb-bringup/drivers/usb/usbehci_new/interfaces.h [iso-8859-1] Sun Apr 17 22:38:32 2011 @@ -444,6 +444,15 @@ virtual NTSTATUS GetHubControllerDeviceObject(PDEVICE_OBJECT * HubDeviceObject) = 0; +//---------------------------------------------------------------------------------------- +// +// GetHubControllerSymbolicLink +// +// Description: Returns the symbolic link of the root hub + + virtual NTSTATUS GetHubControllerSymbolicLink(ULONG BufferLength, PVOID Buffer, PULONG RequiredLength) = 0; + + }; typedef IHubController *PHUBCONTROLLER;
13 years, 8 months
1
0
0
0
[mjmartin] 51386: [USBEHCI_NEW] - Update interfaces with new methods needed for UsbHardWare class. - Remove GetDmaMemoryManager as the DmaMemory will only be needed by UsbQueue class. - GetDeviceDe...
by mjmartin@svn.reactos.org
Author: mjmartin Date: Sun Apr 17 22:06:20 2011 New Revision: 51386 URL:
http://svn.reactos.org/svn/reactos?rev=51386&view=rev
Log: [USBEHCI_NEW] - Update interfaces with new methods needed for UsbHardWare class. - Remove GetDmaMemoryManager as the DmaMemory will only be needed by UsbQueue class. - GetDeviceDetails: Only fill in a parameter if its not null. - Start implementing UsbQueue class. Added: branches/usb-bringup/drivers/usb/usbehci_new/usb_queue.cpp (with props) Modified: branches/usb-bringup/drivers/usb/usbehci_new/CMakeLists.txt branches/usb-bringup/drivers/usb/usbehci_new/hardware.cpp branches/usb-bringup/drivers/usb/usbehci_new/interfaces.h branches/usb-bringup/drivers/usb/usbehci_new/usbehci.h Modified: branches/usb-bringup/drivers/usb/usbehci_new/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/usb/usbehci…
============================================================================== --- branches/usb-bringup/drivers/usb/usbehci_new/CMakeLists.txt [iso-8859-1] (original) +++ branches/usb-bringup/drivers/usb/usbehci_new/CMakeLists.txt [iso-8859-1] Sun Apr 17 22:06:20 2011 @@ -7,6 +7,7 @@ add_library(usbehci SHARED usbehci.cpp usb_device.cpp + usb_queue.cpp hcd_controller.cpp hardware.cpp misc.cpp Modified: branches/usb-bringup/drivers/usb/usbehci_new/hardware.cpp URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/usb/usbehci…
============================================================================== --- branches/usb-bringup/drivers/usb/usbehci_new/hardware.cpp [iso-8859-1] (original) +++ branches/usb-bringup/drivers/usb/usbehci_new/hardware.cpp [iso-8859-1] Sun Apr 17 22:06:20 2011 @@ -52,12 +52,17 @@ NTSTATUS PnpStop(void); NTSTATUS HandlePower(PIRP Irp); NTSTATUS GetDeviceDetails(PUSHORT VendorId, PUSHORT DeviceId, PULONG NumberOfPorts, PULONG Speed); - NTSTATUS GetDmaMemoryManager(OUT struct IDMAMemoryManager **OutMemoryManager); + NTSTATUS GetDmaAdapter(OUT PDMA_ADAPTER AdapterObject); NTSTATUS GetUSBQueue(OUT struct IUSBQueue **OutUsbQueue); + NTSTATUS StartController(); NTSTATUS StopController(); NTSTATUS ResetController(); NTSTATUS ResetPort(ULONG PortIndex); + + VOID SetAsyncListAddressRegister(ULONG PhysicalAddress); + VOID SetPeriodicListRegister(ULONG PhysicalAddress); + KIRQL AcquireDeviceLock(void); VOID ReleaseDeviceLock(KIRQL OldLevel); // local @@ -83,10 +88,10 @@ PULONG m_Base; PDMA_ADAPTER m_Adapter; ULONG m_MapRegisters; - PQUEUE_HEAD m_AsyncListQueueHead; EHCI_CAPS m_Capabilities; USHORT m_VendorID; USHORT m_DeviceID; + PUSBQUEUE m_UsbQueue; VOID SetCommandRegister(PEHCI_USBCMD_CONTENT UsbCmd); VOID GetCommandRegister(PEHCI_USBCMD_CONTENT UsbCmd); @@ -127,6 +132,12 @@ DPRINT1("CUSBHardwareDevice::Initialize\n"); + Status = CreateUSBQueue(&m_UsbQueue); + if (!NT_SUCCESS(Status)) + { + DPRINT1("Failed to create UsbQueue!\n"); + return Status; + } // // store device objects // @@ -322,11 +333,6 @@ } // - // FIXME: Create a QueueHead that will always be the address of the AsyncList - // - m_AsyncListQueueHead = NULL; - - // // Start the controller // DPRINT1("Starting Controller\n"); @@ -355,20 +361,16 @@ OUT OPTIONAL PULONG NumberOfPorts, OUT OPTIONAL PULONG Speed) { - *VendorId = m_VendorID; - *DeviceId = m_DeviceID; - *NumberOfPorts = m_Capabilities.HCSParams.PortCount; + if (VendorId) + *VendorId = m_VendorID; + if (DeviceId) + *DeviceId = m_DeviceID; + if (NumberOfPorts) + *NumberOfPorts = m_Capabilities.HCSParams.PortCount; //FIXME: What to returned here? - *Speed = 0; + if (Speed) + *Speed = 0; return STATUS_SUCCESS; -} - -NTSTATUS -CUSBHardwareDevice::GetDmaMemoryManager( - OUT struct IDMAMemoryManager **OutMemoryManager) -{ - UNIMPLEMENTED - return STATUS_NOT_IMPLEMENTED; } NTSTATUS @@ -563,6 +565,30 @@ return STATUS_SUCCESS; } +//----------------------------------------------------------------------------------------- +// +// SetAsyncListAddressRegister +// +// Description: this functions sets the register to a address that is the physical address of a QueueHead. +// This is the location at which the controller will start executing the Asynchronous Schedule. +// +VOID CUSBHardwareDevice::SetAsyncListAddressRegister(ULONG PhysicalAddress) +{ + EHCI_WRITE_REGISTER_ULONG(EHCI_ASYNCLISTBASE, PhysicalAddress); +} + +//----------------------------------------------------------------------------------------- +// +// SetPeriodicListRegister +// +// Description: this functions sets the register to a address that is the physical address of a ???. +// This is the location at which the controller will start executing the Periodic Schedule. +// +VOID CUSBHardwareDevice::SetPeriodicListRegister(ULONG PhysicalAddress) +{ + EHCI_WRITE_REGISTER_ULONG(EHCI_PERIODICLISTBASE, PhysicalAddress); +} + KIRQL CUSBHardwareDevice::AcquireDeviceLock(void) { @@ -642,14 +668,15 @@ IN PVOID SystemArgument2) { CUSBHardwareDevice *This; - ULONG CStatus, PortStatus, i; + ULONG CStatus, PortStatus, PortCount, i; This = (CUSBHardwareDevice*) SystemArgument1; CStatus = (ULONG) SystemArgument2; + This->GetDeviceDetails(NULL, NULL, &PortCount, NULL); if (CStatus & EHCI_STS_PCD) { - for (i = 0; i < This->m_Capabilities.HCSParams.PortCount; i++) + for (i = 0; i < PortCount; i++) { PortStatus = This->EHCI_READ_REGISTER_ULONG(EHCI_PORTSC + (4 * i)); Modified: branches/usb-bringup/drivers/usb/usbehci_new/interfaces.h URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/usb/usbehci…
============================================================================== --- branches/usb-bringup/drivers/usb/usbehci_new/interfaces.h [iso-8859-1] (original) +++ branches/usb-bringup/drivers/usb/usbehci_new/interfaces.h [iso-8859-1] Sun Apr 17 22:06:20 2011 @@ -164,16 +164,6 @@ //----------------------------------------------------------------------------------------- // -// GetDmaMemoryManager -// -// Description: returns interface to DMAMemoryManager -// Interface is reference counted, you need to call Release method when you are done with it -// Do not call Initialize on IDMAMemoryManager, the object is already initialized - - virtual NTSTATUS GetDmaMemoryManager(OUT struct IDMAMemoryManager **OutMemoryManager) = 0; - -//----------------------------------------------------------------------------------------- -// // GetUSBQueue // // Description: returns interface to internal IUSBQueue @@ -190,6 +180,26 @@ // Returns STATUS_SUCCESS when the controller was successfully reset virtual NTSTATUS ResetController() = 0; + +//----------------------------------------------------------------------------------------- +// +// StartController +// +// Description: this functions starts controller allowing interrupts for device connects/removal, and execution of +// Periodic and Asynchronous Schedules. +// + + virtual NTSTATUS StartController() = 0; + +//----------------------------------------------------------------------------------------- +// +// StopController +// +// Description: this functions stops controller disabling interrupts for device connects/removal, and execution of +// Periodic and Asynchronous Schedules. +// + + virtual NTSTATUS StopController() = 0; //----------------------------------------------------------------------------------------- // @@ -364,8 +374,8 @@ // Description: initializes the object virtual NTSTATUS Initialize(IN PUSBHARDWAREDEVICE Hardware, - IN OPTIONAL PKSPIN_LOCK Lock, - IN PDMAMEMORYMANAGER MemoryManager) = 0; + PADAPTER_OBJECT AdapterObject, + IN OPTIONAL PKSPIN_LOCK Lock) = 0; //----------------------------------------------------------------------------------------- // @@ -383,7 +393,7 @@ // Returns status success when successful virtual NTSTATUS AddUSBRequest(IUSBRequest * Request) = 0; - + virtual NTSTATUS AddUSBRequest(PURB Urb) = 0; //----------------------------------------------------------------------------------------- // // CancelRequests() Added: branches/usb-bringup/drivers/usb/usbehci_new/usb_queue.cpp URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/usb/usbehci…
============================================================================== --- branches/usb-bringup/drivers/usb/usbehci_new/usb_queue.cpp (added) +++ branches/usb-bringup/drivers/usb/usbehci_new/usb_queue.cpp [iso-8859-1] Sun Apr 17 22:06:20 2011 @@ -1,0 +1,165 @@ +/* + * PROJECT: ReactOS Universal Serial Bus Bulk Enhanced Host Controller Interface + * LICENSE: GPL - See COPYING in the top level directory + * FILE: drivers/usb/usbehci/usb_queue.cpp + * PURPOSE: USB EHCI device driver. + * PROGRAMMERS: + * Michael Martin (michael.martin(a)reactos.org) + * Johannes Anderwald (johannes.anderwald(a)reactos.org) + */ + +#include "usbehci.h" +#include "hardware.h" + +class CUSBQueue : public IUSBQueue +{ +public: + STDMETHODIMP QueryInterface( REFIID InterfaceId, PVOID* Interface); + + STDMETHODIMP_(ULONG) AddRef() + { + InterlockedIncrement(&m_Ref); + return m_Ref; + } + STDMETHODIMP_(ULONG) Release() + { + InterlockedDecrement(&m_Ref); + + if (!m_Ref) + { + delete this; + return 0; + } + return m_Ref; + } + + NTSTATUS Initialize(IN PUSBHARDWAREDEVICE Hardware, PADAPTER_OBJECT AdapterObject, IN OPTIONAL PKSPIN_LOCK Lock); + ULONG GetPendingRequestCount(); + NTSTATUS AddUSBRequest(PURB Urb); + NTSTATUS AddUSBRequest(IUSBRequest * Request); + NTSTATUS CancelRequests(); + NTSTATUS CreateUSBRequest(IUSBRequest **OutRequest); + + // constructor / destructor + CUSBQueue(IUnknown *OuterUnknown){} + virtual ~CUSBQueue(){} + +protected: + LONG m_Ref; + PDMA_ADAPTER m_Adapter; + PQUEUE_HEAD ExecutingList; + PQUEUE_HEAD PendingList; + IDMAMemoryManager *m_MemoryManager; +}; + +//================================================================================================= +// COM +// +NTSTATUS +STDMETHODCALLTYPE +CUSBQueue::QueryInterface( + IN REFIID refiid, + OUT PVOID* Output) +{ + if (IsEqualGUIDAligned(refiid, IID_IUnknown)) + { + *Output = PVOID(PUNKNOWN(this)); + PUNKNOWN(*Output)->AddRef(); + return STATUS_SUCCESS; + } + + return STATUS_UNSUCCESSFUL; +} + +NTSTATUS +CUSBQueue::Initialize( + IN PUSBHARDWAREDEVICE Hardware, + PADAPTER_OBJECT AdapterObject, + IN OPTIONAL PKSPIN_LOCK Lock) +{ + NTSTATUS Status; + + ASSERT(Hardware); + ASSERT(AdapterObject); + + Status = CreateDMAMemoryManager(&m_MemoryManager); + if (!NT_SUCCESS(Status)) + { + DPRINT1("Failed to create DMAMemoryManager Object\n"); + return Status; + } + + return STATUS_SUCCESS; +} + +ULONG +CUSBQueue::GetPendingRequestCount() +{ + UNIMPLEMENTED + return 0; +} + +NTSTATUS +CUSBQueue::AddUSBRequest( + IUSBRequest * Request) +{ + UNIMPLEMENTED + return STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS +CUSBQueue::AddUSBRequest( + PURB Urb) +{ + UNIMPLEMENTED + return STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS +CUSBQueue::CancelRequests() +{ + UNIMPLEMENTED + return STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS +CUSBQueue::CreateUSBRequest( + IUSBRequest **OutRequest) +{ + UNIMPLEMENTED + return STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS +CreateUSBQueue( + PUSBQUEUE *OutUsbQueue) +{ + PUSBQUEUE This; + + // + // allocate controller + // + This = new(NonPagedPool, TAG_USBEHCI) CUSBQueue(0); + if (!This) + { + // + // failed to allocate + // + return STATUS_INSUFFICIENT_RESOURCES; + } + + // + // add reference count + // + This->AddRef(); + + // + // return result + // + *OutUsbQueue = (PUSBQUEUE)This; + + // + // done + // + return STATUS_SUCCESS; +} Propchange: branches/usb-bringup/drivers/usb/usbehci_new/usb_queue.cpp ------------------------------------------------------------------------------ svn:eol-style = native Modified: branches/usb-bringup/drivers/usb/usbehci_new/usbehci.h URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/usb/usbehci…
============================================================================== --- branches/usb-bringup/drivers/usb/usbehci_new/usbehci.h [iso-8859-1] (original) +++ branches/usb-bringup/drivers/usb/usbehci_new/usbehci.h [iso-8859-1] Sun Apr 17 22:06:20 2011 @@ -72,4 +72,9 @@ // NTSTATUS CreateUSBDevice(PUSBDEVICE *OutDevice); +// +// usb_queue.cpp +// +NTSTATUS CreateUSBQueue(PUSBQUEUE *OutUsbQueue); + #endif
13 years, 8 months
1
0
0
0
[janderwald] 51385: [USBEHCI_NEW] - Implement IRP_MN_QUERY_DEVICE_RELATIONS for hub controller object - Implement stub handler for URB_FUNCTION_CLASS_OTHER, URB_FUNCTION_SELECT_CONFIGURATION - Part...
by janderwald@svn.reactos.org
Author: janderwald Date: Sun Apr 17 21:35:25 2011 New Revision: 51385 URL:
http://svn.reactos.org/svn/reactos?rev=51385&view=rev
Log: [USBEHCI_NEW] - Implement IRP_MN_QUERY_DEVICE_RELATIONS for hub controller object - Implement stub handler for URB_FUNCTION_CLASS_OTHER, URB_FUNCTION_SELECT_CONFIGURATION - Partly implement URB_FUNCTION_GET_STATUS_FROM_DEVICE - Return success from unimplemented USBHI_Initialize20Hub routine - based on mjmartin usbehci driver - Tested in Windows XP SP2 Modified: branches/usb-bringup/drivers/usb/usbehci_new/hub_controller.cpp Modified: branches/usb-bringup/drivers/usb/usbehci_new/hub_controller.cpp URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/usb/usbehci…
============================================================================== --- branches/usb-bringup/drivers/usb/usbehci_new/hub_controller.cpp [iso-8859-1] (original) +++ branches/usb-bringup/drivers/usb/usbehci_new/hub_controller.cpp [iso-8859-1] Sun Apr 17 21:35:25 2011 @@ -54,8 +54,12 @@ NTSTATUS AddUsbDevice(PUSBDEVICE UsbDevice); NTSTATUS RemoveUsbDevice(PUSBDEVICE UsbDevice); VOID SetNotification(PVOID CallbackContext, PRH_INIT_CALLBACK CallbackRoutine); + // internal ioctl routines NTSTATUS HandleGetDescriptor(IN OUT PIRP Irp, PURB Urb); NTSTATUS HandleClassDevice(IN OUT PIRP Irp, PURB Urb); + NTSTATUS HandleGetStatusFromDevice(IN OUT PIRP Irp, PURB Urb); + NTSTATUS HandleSelectConfiguration(IN OUT PIRP Irp, PURB Urb); + NTSTATUS HandleClassOther(IN OUT PIRP Irp, PURB Urb); // constructor / destructor CHubController(IUnknown *OuterUnknown){} @@ -273,6 +277,7 @@ PCOMMON_DEVICE_EXTENSION DeviceExtension; PDEVICE_CAPABILITIES DeviceCapabilities; PPNP_BUS_INFORMATION BusInformation; + PDEVICE_RELATIONS DeviceRelations; NTSTATUS Status; ULONG Index = 0, Length; USHORT VendorID, DeviceID; @@ -515,6 +520,47 @@ // return STATUS_SUCCESS; } + case IRP_MN_QUERY_DEVICE_RELATIONS: + { + DPRINT1("CHubController::HandlePnp IRP_MN_QUERY_DEVICE_RELATIONS Type %x\n", IoStack->Parameters.QueryDeviceRelations.Type); + + if (IoStack->Parameters.QueryDeviceRelations.Type == TargetDeviceRelation) + { + // + // allocate device relations + // + DeviceRelations = (PDEVICE_RELATIONS)ExAllocatePoolWithTag(PagedPool, sizeof(DEVICE_RELATIONS), TAG_USBEHCI); + if (!DeviceRelations) + { + // + // no memory + // + Status = STATUS_INSUFFICIENT_RESOURCES; + break; + } + + // + // initialize device relations + // + DeviceRelations->Count = 1; + DeviceRelations->Objects[0] = DeviceObject; + ObReferenceObject(DeviceObject); + + // + // done + // + Status = STATUS_SUCCESS; + Irp->IoStatus.Information = (ULONG_PTR)DeviceRelations; + } + else + { + // + // not handled + // + Status = Irp->IoStatus.Status; + } + break; + } case IRP_MN_QUERY_BUS_INFORMATION: { DPRINT1("CHubController::HandlePnp IRP_MN_QUERY_BUS_INFORMATION\n"); @@ -591,6 +637,84 @@ //----------------------------------------------------------------------------------------- NTSTATUS +CHubController::HandleClassOther( + IN OUT PIRP Irp, + PURB Urb) +{ + DPRINT1("CHubController::HandleClassOther> Request %x Value %x not implemented\n", Urb->UrbControlVendorClassRequest.Request, Urb->UrbControlVendorClassRequest.Value); + + // + // FIXME implement me + // + + return STATUS_SUCCESS; +} + +//----------------------------------------------------------------------------------------- +NTSTATUS +CHubController::HandleSelectConfiguration( + IN OUT PIRP Irp, + PURB Urb) +{ + // + // sanity checks + // + + // + // FIXME: support devices + // + PC_ASSERT(Urb->UrbHeader.UsbdDeviceHandle == NULL); + + // + // FIXME: support setting device to unconfigured state + // + PC_ASSERT(Urb->UrbSelectConfiguration.ConfigurationDescriptor); + + // + // set device handle + // + Urb->UrbSelectConfiguration.ConfigurationHandle = (PVOID)ROOTHUB2_CONFIGURATION_DESCRIPTOR; + + // + // TODO: copy interface info + // + return STATUS_SUCCESS; +} + +//----------------------------------------------------------------------------------------- +NTSTATUS +CHubController::HandleGetStatusFromDevice( + IN OUT PIRP Irp, + PURB Urb) +{ + PUSHORT Status; + + // + // sanity checks + // + PC_ASSERT(Urb->UrbControlGetStatusRequest.Index == 0); + PC_ASSERT(Urb->UrbControlGetStatusRequest.TransferBufferLength >= sizeof(USHORT)); + PC_ASSERT(Urb->UrbControlGetStatusRequest.TransferBuffer); + PC_ASSERT(Urb->UrbHeader.UsbdDeviceHandle == NULL); + + // + // get status buffer + // + Status = (PUSHORT)Urb->UrbControlGetStatusRequest.TransferBuffer; + + // + // FIXME need more flags ? + // + *Status = USB_PORT_STATUS_CONNECT; + + // + // done + // + return STATUS_SUCCESS; +} + +//----------------------------------------------------------------------------------------- +NTSTATUS CHubController::HandleClassDevice( IN OUT PIRP Irp, IN OUT PURB Urb) @@ -605,53 +729,63 @@ // switch(Urb->UrbControlVendorClassRequest.Request) { - case USB_DEVICE_CLASS_HUB: - { - // - // sanity checks - // - PC_ASSERT(Urb->UrbControlVendorClassRequest.TransferBuffer); - PC_ASSERT(Urb->UrbControlVendorClassRequest.TransferBufferLength >= sizeof(USB_HUB_DESCRIPTOR)); - - // - // get hub descriptor - // - UsbHubDescriptor = (PUSB_HUB_DESCRIPTOR)Urb->UrbControlVendorClassRequest.TransferBuffer; - - // - // one hub is handled - // - UsbHubDescriptor->bDescriptorLength = sizeof(USB_HUB_DESCRIPTOR); - Urb->UrbControlVendorClassRequest.TransferBufferLength = sizeof(USB_HUB_DESCRIPTOR); - - // - // type should 0x29 according to msdn - // - UsbHubDescriptor->bDescriptorType = 0x29; - - // - // get port count - // - Status = m_Hardware->GetDeviceDetails(&Dummy1, &Dummy1, &PortCount, &Dummy2); - PC_ASSERT(Status == STATUS_SUCCESS); - - // - // FIXME: retrieve values - // - UsbHubDescriptor->bNumberOfPorts = PortCount; - UsbHubDescriptor->wHubCharacteristics = 0x0012; - UsbHubDescriptor->bPowerOnToPowerGood = 0x01; - UsbHubDescriptor->bHubControlCurrent = 0x00; - - // - // done - // - Status = STATUS_SUCCESS; + case USB_REQUEST_GET_DESCRIPTOR: + { + switch (Urb->UrbControlVendorClassRequest.Value >> 8) + { + case USB_DEVICE_CLASS_RESERVED: // FALL THROUGH + case USB_DEVICE_CLASS_HUB: + { + // + // sanity checks + // + PC_ASSERT(Urb->UrbControlVendorClassRequest.TransferBuffer); + PC_ASSERT(Urb->UrbControlVendorClassRequest.TransferBufferLength >= sizeof(USB_HUB_DESCRIPTOR)); + + // + // get hub descriptor + // + UsbHubDescriptor = (PUSB_HUB_DESCRIPTOR)Urb->UrbControlVendorClassRequest.TransferBuffer; + + // + // one hub is handled + // + UsbHubDescriptor->bDescriptorLength = sizeof(USB_HUB_DESCRIPTOR); + Urb->UrbControlVendorClassRequest.TransferBufferLength = sizeof(USB_HUB_DESCRIPTOR); + + // + // type should 0x29 according to msdn + // + UsbHubDescriptor->bDescriptorType = 0x29; + + // + // get port count + // + Status = m_Hardware->GetDeviceDetails(&Dummy1, &Dummy1, &PortCount, &Dummy2); + PC_ASSERT(Status == STATUS_SUCCESS); + + // + // FIXME: retrieve values + // + UsbHubDescriptor->bNumberOfPorts = PortCount; + UsbHubDescriptor->wHubCharacteristics = 0x0012; + UsbHubDescriptor->bPowerOnToPowerGood = 0x01; + UsbHubDescriptor->bHubControlCurrent = 0x00; + + // + // done + // + Status = STATUS_SUCCESS; + break; + } + default: + DPRINT1("CHubController::HandleClassDevice Class %x not implemented\n", Urb->UrbControlVendorClassRequest.Value >> 8); + break; + } break; } default: - DPRINT1("CHubController::HandleClassDevice Class %x not implemented\n", Urb->UrbControlVendorClassRequest.Request); - break; + DPRINT1("CHubController::HandleClassDevice Type %x not implemented\n", Urb->UrbControlVendorClassRequest.Request); } return Status; @@ -807,6 +941,16 @@ break; case URB_FUNCTION_CLASS_DEVICE: Status = HandleClassDevice(Irp, Urb); + break; + case URB_FUNCTION_GET_STATUS_FROM_DEVICE: + Status = HandleGetStatusFromDevice(Irp, Urb); + break; + case URB_FUNCTION_SELECT_CONFIGURATION: + Status = HandleSelectConfiguration(Irp, Urb); + break; + case URB_FUNCTION_CLASS_OTHER: + Status = HandleClassOther(Irp, Urb); + break; } // // request completed @@ -1865,7 +2009,7 @@ ULONG TtCount) { UNIMPLEMENTED - return STATUS_NOT_IMPLEMENTED; + return STATUS_SUCCESS; } NTSTATUS @@ -1889,6 +2033,11 @@ // set notification routine // Controller->SetNotification(CallbackContext, CallbackRoutine); + + // + // FIXME: determine when to perform callback + // + CallbackRoutine(CallbackContext); // // done
13 years, 8 months
1
0
0
0
[janderwald] 51384: [USBEHCI_NEW] - Setup a default device descriptor for the root hub and initialize it with vendor & product id - Partly implement URB_FUNCTION_GET_DESCRIPTOR_FROM_DEVICE, URB_FUN...
by janderwald@svn.reactos.org
Author: janderwald Date: Sun Apr 17 19:23:13 2011 New Revision: 51384 URL:
http://svn.reactos.org/svn/reactos?rev=51384&view=rev
Log: [USBEHCI_NEW] - Setup a default device descriptor for the root hub and initialize it with vendor & product id - Partly implement URB_FUNCTION_GET_DESCRIPTOR_FROM_DEVICE, URB_FUNCTION_CLASS_DEVICE - based on mjmartin usbehci Modified: branches/usb-bringup/drivers/usb/usbehci_new/hub_controller.cpp branches/usb-bringup/drivers/usb/usbehci_new/interfaces.h branches/usb-bringup/drivers/usb/usbehci_new/usb_device.cpp Modified: branches/usb-bringup/drivers/usb/usbehci_new/hub_controller.cpp URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/usb/usbehci…
============================================================================== --- branches/usb-bringup/drivers/usb/usbehci_new/hub_controller.cpp [iso-8859-1] (original) +++ branches/usb-bringup/drivers/usb/usbehci_new/hub_controller.cpp [iso-8859-1] Sun Apr 17 19:23:13 2011 @@ -54,6 +54,8 @@ NTSTATUS AddUsbDevice(PUSBDEVICE UsbDevice); NTSTATUS RemoveUsbDevice(PUSBDEVICE UsbDevice); VOID SetNotification(PVOID CallbackContext, PRH_INIT_CALLBACK CallbackRoutine); + NTSTATUS HandleGetDescriptor(IN OUT PIRP Irp, PURB Urb); + NTSTATUS HandleClassDevice(IN OUT PIRP Irp, PURB Urb); // constructor / destructor CHubController(IUnknown *OuterUnknown){} @@ -65,7 +67,6 @@ PUSBHARDWAREDEVICE m_Hardware; BOOLEAN m_IsRootHubDevice; ULONG m_DeviceAddress; - ULONG m_PDODeviceNumber; BOOLEAN m_InterfaceEnabled; UNICODE_STRING m_HubDeviceInterfaceString; PDEVICE_OBJECT m_HubControllerDeviceObject; @@ -74,6 +75,7 @@ PVOID m_HubCallbackContext; PRH_INIT_CALLBACK m_HubCallbackRoutine; + USB_DEVICE_DESCRIPTOR m_DeviceDescriptor; KSPIN_LOCK m_Lock; RTL_BITMAP m_DeviceAddressBitmap; @@ -87,6 +89,64 @@ PUSBDEVICE Device; }USBDEVICE_ENTRY, *PUSBDEVICE_ENTRY; +/* Lifted from Linux with slight changes */ +const UCHAR ROOTHUB2_DEVICE_DESCRIPTOR [] = +{ + 0x12, /* bLength; */ + USB_DEVICE_DESCRIPTOR_TYPE, /* bDescriptorType; Device */ + 0x00, 0x20, /* bcdUSB; v1.1 */ + USB_DEVICE_CLASS_HUB, /* bDeviceClass; HUB_CLASSCODE */ + 0x01, /* bDeviceSubClass; */ + 0x00, /* bDeviceProtocol; [ low/full speeds only ] */ + 0x08, /* bMaxPacketSize0; 8 Bytes */ + /* Fill Vendor and Product in when init root hub */ + 0x00, 0x00, /* idVendor; */ + 0x00, 0x00, /* idProduct; */ + 0x00, 0x00, /* bcdDevice */ + 0x00, /* iManufacturer; */ + 0x00, /* iProduct; */ + 0x00, /* iSerialNumber; */ + 0x01 /* bNumConfigurations; */ + +}; + +const UCHAR ROOTHUB2_CONFIGURATION_DESCRIPTOR [] = +{ + /* one configuration */ + 0x09, /* bLength; */ + 0x02, /* bDescriptorType; Configuration */ + 0x19, 0x00, /* wTotalLength; */ + 0x01, /* bNumInterfaces; (1) */ + 0x23, /* bConfigurationValue; */ + 0x00, /* iConfiguration; */ + 0x40, /* bmAttributes; */ + 0x00 /* MaxPower; */ +}; + +const UCHAR ROOTHUB2_INTERFACE_DESCRIPTOR [] = +{ + /* one interface */ + 0x09, /* bLength: Interface; */ + 0x04, /* bDescriptorType; Interface */ + 0x00, /* bInterfaceNumber; */ + 0x00, /* bAlternateSetting; */ + 0x01, /* bNumEndpoints; */ + 0x09, /* bInterfaceClass; HUB_CLASSCODE */ + 0x01, /* bInterfaceSubClass; */ + 0x00, /* bInterfaceProtocol: */ + 0x00 /* iInterface; */ +}; + +const UCHAR ROOTHUB2_ENDPOINT_DESCRIPTOR [] = +{ + /* one endpoint (status change endpoint) */ + 0x07, /* bLength; */ + 0x05, /* bDescriptorType; Endpoint */ + 0x81, /* bEndpointAddress; IN Endpoint 1 */ + 0x03, /* bmAttributes; Interrupt */ + 0x08, 0x00, /* wMaxPacketSize; 1 + (MAX_ROOT_PORTS / 8) */ + 0xFF /* bInterval; (255ms -- usb 2.0 spec) */ +}; //---------------------------------------------------------------------------------------- NTSTATUS @@ -108,6 +168,8 @@ { NTSTATUS Status; PCOMMON_DEVICE_EXTENSION DeviceExtension; + USHORT VendorID, DeviceID; + ULONG Dummy1; DPRINT1("CHubController::Initialize\n"); @@ -120,6 +182,7 @@ m_DeviceAddress = DeviceAddress; m_DriverObject = DriverObject; KeInitializeSpinLock(&m_Lock); + InitializeListHead(&m_UsbDeviceList); // // allocate device address bitmap buffer @@ -163,6 +226,22 @@ DeviceExtension->IsFDO = FALSE; DeviceExtension->IsHub = TRUE; //FIXME DeviceExtension->Dispatcher = PDISPATCHIRP(this); + + // + // intialize device descriptor + // + C_ASSERT(sizeof(USB_DEVICE_DESCRIPTOR) == sizeof(ROOTHUB2_DEVICE_DESCRIPTOR)); + RtlMoveMemory(&m_DeviceDescriptor, ROOTHUB2_DEVICE_DESCRIPTOR, sizeof(USB_DEVICE_DESCRIPTOR)); + + if (NT_SUCCESS(m_Hardware->GetDeviceDetails(&VendorID, &DeviceID, &Dummy1, &Dummy1))) + { + // + // update device descriptor + // + m_DeviceDescriptor.idVendor = VendorID; + m_DeviceDescriptor.idProduct = DeviceID; + m_DeviceDescriptor.bcdUSB = 0x200; //FIXME + } // // clear init flag @@ -512,6 +591,174 @@ //----------------------------------------------------------------------------------------- NTSTATUS +CHubController::HandleClassDevice( + IN OUT PIRP Irp, + IN OUT PURB Urb) +{ + NTSTATUS Status = STATUS_NOT_IMPLEMENTED; + PUSB_HUB_DESCRIPTOR UsbHubDescriptor; + ULONG PortCount, Dummy2; + USHORT Dummy1; + + // + // check class request type + // + switch(Urb->UrbControlVendorClassRequest.Request) + { + case USB_DEVICE_CLASS_HUB: + { + // + // sanity checks + // + PC_ASSERT(Urb->UrbControlVendorClassRequest.TransferBuffer); + PC_ASSERT(Urb->UrbControlVendorClassRequest.TransferBufferLength >= sizeof(USB_HUB_DESCRIPTOR)); + + // + // get hub descriptor + // + UsbHubDescriptor = (PUSB_HUB_DESCRIPTOR)Urb->UrbControlVendorClassRequest.TransferBuffer; + + // + // one hub is handled + // + UsbHubDescriptor->bDescriptorLength = sizeof(USB_HUB_DESCRIPTOR); + Urb->UrbControlVendorClassRequest.TransferBufferLength = sizeof(USB_HUB_DESCRIPTOR); + + // + // type should 0x29 according to msdn + // + UsbHubDescriptor->bDescriptorType = 0x29; + + // + // get port count + // + Status = m_Hardware->GetDeviceDetails(&Dummy1, &Dummy1, &PortCount, &Dummy2); + PC_ASSERT(Status == STATUS_SUCCESS); + + // + // FIXME: retrieve values + // + UsbHubDescriptor->bNumberOfPorts = PortCount; + UsbHubDescriptor->wHubCharacteristics = 0x0012; + UsbHubDescriptor->bPowerOnToPowerGood = 0x01; + UsbHubDescriptor->bHubControlCurrent = 0x00; + + // + // done + // + Status = STATUS_SUCCESS; + break; + } + default: + DPRINT1("CHubController::HandleClassDevice Class %x not implemented\n", Urb->UrbControlVendorClassRequest.Request); + break; + } + + return Status; +} +//----------------------------------------------------------------------------------------- +NTSTATUS +CHubController::HandleGetDescriptor( + IN OUT PIRP Irp, + IN OUT PURB Urb) +{ + NTSTATUS Status = STATUS_NOT_IMPLEMENTED; + PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor; + PUCHAR Buffer; + + // + // check descriptor type + // + switch(Urb->UrbControlDescriptorRequest.DescriptorType) + { + case USB_DEVICE_DESCRIPTOR_TYPE: + { + // + // sanity check + // + PC_ASSERT(Urb->UrbControlDescriptorRequest.TransferBufferLength >= sizeof(USB_DEVICE_DESCRIPTOR)); + + if (Urb->UrbHeader.UsbdDeviceHandle == NULL) + { + DPRINT1("Root Hub descriptor\n"); + // + // copy root hub device descriptor + // + RtlCopyMemory((PUCHAR)Urb->UrbControlDescriptorRequest.TransferBuffer, &m_DeviceDescriptor, sizeof(USB_DEVICE_DESCRIPTOR)); + Status = STATUS_SUCCESS; + break; + } + break; + } + case USB_CONFIGURATION_DESCRIPTOR_TYPE: + { + // + // sanity checks + // + PC_ASSERT(Urb->UrbControlDescriptorRequest.TransferBuffer); + PC_ASSERT(Urb->UrbControlDescriptorRequest.TransferBufferLength >= sizeof(USB_CONFIGURATION_DESCRIPTOR)); + + // + // FIXME: support devices + // + PC_ASSERT(Urb->UrbHeader.UsbdDeviceHandle == NULL); + + // + // copy configuration descriptor template + // + C_ASSERT(sizeof(ROOTHUB2_CONFIGURATION_DESCRIPTOR) == sizeof(USB_CONFIGURATION_DESCRIPTOR)); + RtlCopyMemory(Urb->UrbControlDescriptorRequest.TransferBuffer, ROOTHUB2_CONFIGURATION_DESCRIPTOR, sizeof(USB_CONFIGURATION_DESCRIPTOR)); + + // + // get configuration descriptor, very retarded! + // + ConfigurationDescriptor = (PUSB_CONFIGURATION_DESCRIPTOR)Urb->UrbControlDescriptorRequest.TransferBuffer; + + // + // check if buffer can hold interface and endpoint descriptor + // + if (ConfigurationDescriptor->wTotalLength > Urb->UrbControlDescriptorRequest.TransferBufferLength) + { + // + // buffer too small + // + Status = STATUS_SUCCESS; + break; + } + + // + // copy interface descriptor template + // + Buffer = (PUCHAR)(ConfigurationDescriptor + 1); + C_ASSERT(sizeof(ROOTHUB2_INTERFACE_DESCRIPTOR) == sizeof(USB_INTERFACE_DESCRIPTOR)); + RtlCopyMemory(Buffer, ROOTHUB2_INTERFACE_DESCRIPTOR, sizeof(USB_INTERFACE_DESCRIPTOR)); + + // + // copy end point descriptor template + // + Buffer += sizeof(USB_INTERFACE_DESCRIPTOR); + C_ASSERT(sizeof(ROOTHUB2_ENDPOINT_DESCRIPTOR) == sizeof(USB_ENDPOINT_DESCRIPTOR)); + RtlCopyMemory(Buffer, ROOTHUB2_ENDPOINT_DESCRIPTOR, sizeof(USB_ENDPOINT_DESCRIPTOR)); + + // + // done + // + Status = STATUS_SUCCESS; + break; + } + default: + DPRINT1("CHubController::HandleGetDescriptor DescriptorType %x unimplemented\n", Urb->UrbControlDescriptorRequest.DescriptorType); + break; + } + + // + // done + // + return Status; +} + +//----------------------------------------------------------------------------------------- +NTSTATUS CHubController::HandleDeviceControl( IN PDEVICE_OBJECT DeviceObject, IN OUT PIRP Irp) @@ -553,10 +800,17 @@ DPRINT1("IOCTL_INTERNAL_USB_SUBMIT_URB Function %x Length %lu Status %x Handle %p Flags %x UNIMPLEMENTED\n", Urb->UrbHeader.Function, Urb->UrbHeader.Length, Urb->UrbHeader.Status, Urb->UrbHeader.UsbdDeviceHandle, Urb->UrbHeader.UsbdFlags); + switch (Urb->UrbHeader.Function) + { + case URB_FUNCTION_GET_DESCRIPTOR_FROM_DEVICE: + Status = HandleGetDescriptor(Irp, Urb); + break; + case URB_FUNCTION_CLASS_DEVICE: + Status = HandleClassDevice(Irp, Urb); + } // // request completed // - Status = STATUS_NOT_IMPLEMENTED; break; } case IOCTL_INTERNAL_USB_GET_DEVICE_HANDLE: @@ -854,7 +1108,6 @@ PUSBDEVICE UsbDevice) { PUSBDEVICE_ENTRY DeviceEntry; - NTSTATUS Status; KIRQL OldLevel; // @@ -1004,7 +1257,7 @@ // // now initialize device // - Status = NewUsbDevice->Initialize(PHUBCONTROLLER(Controller), Controller->GetUsbHardware(),PVOID(Controller), PortNumber); + Status = NewUsbDevice->Initialize(PHUBCONTROLLER(Controller), Controller->GetUsbHardware(),PVOID(Controller), PortNumber, PortStatus); // // check for success @@ -1359,9 +1612,8 @@ PUSB_DEVICE_INFORMATION_0 DeviceInfo; PUSBDEVICE UsbDevice; CHubController * Controller; - NTSTATUS Status; - - DPRINT1("USBHI_QueryDeviceInformation\n"); + + DPRINT1("USBHI_QueryDeviceInformation %p\n", BusContext); // // sanity check @@ -1382,17 +1634,54 @@ UsbDevice = (PUSBDEVICE)DeviceHandle; PC_ASSERT(UsbDevice); - // - // validate device handle - // - if (!Controller->ValidateUsbDevice(UsbDevice)) - { - DPRINT1("USBHI_QueryDeviceInformation invalid device handle %p\n", DeviceHandle); - - // - // invalid device handle - // - return STATUS_DEVICE_NOT_CONNECTED; + if (BusContext != DeviceHandle) + { + // + // validate device handle + // + if (!Controller->ValidateUsbDevice(UsbDevice)) + { + DPRINT1("USBHI_QueryDeviceInformation invalid device handle %p\n", DeviceHandle); + + // + // invalid device handle + // + return STATUS_DEVICE_NOT_CONNECTED; + } + + // + // access information buffer + // + DeviceInfo = (PUSB_DEVICE_INFORMATION_0)DeviceInformationBuffer; + + // + // initialize with default values + // + DeviceInfo->InformationLevel = 0; + DeviceInfo->ActualLength = sizeof(USB_DEVICE_INFORMATION_0); + DeviceInfo->PortNumber = UsbDevice->GetPort(); + DeviceInfo->CurrentConfigurationValue = UsbDevice->GetConfigurationValue(); + DeviceInfo->DeviceAddress = UsbDevice->GetDeviceAddress(); + DeviceInfo->HubAddress = 0; //FIXME + DeviceInfo->DeviceSpeed = UsbDevice->GetSpeed(); + DeviceInfo->DeviceType = UsbDevice->GetType(); + DeviceInfo->NumberOfOpenPipes = 0; //FIXME + + // + // get device descriptor + // + UsbDevice->GetDeviceDescriptor(&DeviceInfo->DeviceDescriptor); + + // + // FIXME return pipe information + // + + // + // store result length + // + *LengthReturned = sizeof(USB_DEVICE_INFORMATION_0); + + return STATUS_SUCCESS; } // @@ -1405,18 +1694,17 @@ // DeviceInfo->InformationLevel = 0; DeviceInfo->ActualLength = sizeof(USB_DEVICE_INFORMATION_0); - DeviceInfo->PortNumber = UsbDevice->GetPort(); - DeviceInfo->CurrentConfigurationValue = UsbDevice->GetConfigurationValue(); - DeviceInfo->DeviceAddress = 0; UsbDevice->GetDeviceAddress(); + DeviceInfo->PortNumber = 0; + DeviceInfo->CurrentConfigurationValue = 0; //FIXME; + DeviceInfo->DeviceAddress = 0; DeviceInfo->HubAddress = 0; //FIXME - DeviceInfo->DeviceSpeed = UsbDevice->GetSpeed(); - DeviceInfo->DeviceType = UsbDevice->GetType(); + DeviceInfo->DeviceSpeed = UsbHighSpeed; //FIXME + DeviceInfo->DeviceType = Usb20Device; //FIXME DeviceInfo->NumberOfOpenPipes = 0; //FIXME // - // get device descriptor - // - UsbDevice->GetDeviceDescriptor(&DeviceInfo->DeviceDescriptor); + // FIXME get device descriptor + // // // FIXME return pipe information @@ -1427,6 +1715,9 @@ // *LengthReturned = sizeof(USB_DEVICE_INFORMATION_0); + // + // done + // return STATUS_SUCCESS; } @@ -2077,12 +2368,7 @@ } } - // - // store PDO number - // - //m_PDODeviceNumber = UsbDeviceNumber; - - DPRINT1("CreateFDO: DeviceName %wZ\n", &DeviceName); + DPRINT1("CHubController::CreatePDO: DeviceName %wZ\n", &DeviceName); /* done */ return Status; Modified: branches/usb-bringup/drivers/usb/usbehci_new/interfaces.h URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/usb/usbehci…
============================================================================== --- branches/usb-bringup/drivers/usb/usbehci_new/interfaces.h [iso-8859-1] (original) +++ branches/usb-bringup/drivers/usb/usbehci_new/interfaces.h [iso-8859-1] Sun Apr 17 19:23:13 2011 @@ -344,6 +344,8 @@ }; +typedef IUSBRequest *PUSBREQUEST; + //========================================================================================= // // class IUSBQueue @@ -398,6 +400,8 @@ virtual NTSTATUS CreateUSBRequest(IUSBRequest **OutRequest) = 0; }; + +typedef IUSBQueue *PUSBQUEUE; //========================================================================================= // @@ -495,7 +499,8 @@ virtual NTSTATUS Initialize(IN PHUBCONTROLLER HubController, IN PUSBHARDWAREDEVICE Device, IN PVOID Parent, - IN ULONG Port) = 0; + IN ULONG Port, + IN ULONG PortStatus) = 0; //----------------------------------------------------------------------------------------- // @@ -584,7 +589,7 @@ // // Description: gets current selected configuration index - virtual UCHAR GetConfigurationValue(); + virtual UCHAR GetConfigurationValue() = 0; //----------------------------------------------------------------------------------------- // Modified: branches/usb-bringup/drivers/usb/usbehci_new/usb_device.cpp URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/usb/usbehci…
============================================================================== --- branches/usb-bringup/drivers/usb/usbehci_new/usb_device.cpp [iso-8859-1] (original) +++ branches/usb-bringup/drivers/usb/usbehci_new/usb_device.cpp [iso-8859-1] Sun Apr 17 19:23:13 2011 @@ -11,12 +11,518 @@ #define INITGUID #include "usbehci.h" - +class CUSBDevice : public IUSBDevice +{ +public: + STDMETHODIMP QueryInterface( REFIID InterfaceId, PVOID* Interface); + + STDMETHODIMP_(ULONG) AddRef() + { + InterlockedIncrement(&m_Ref); + return m_Ref; + } + STDMETHODIMP_(ULONG) Release() + { + InterlockedDecrement(&m_Ref); + + if (!m_Ref) + { + delete this; + return 0; + } + return m_Ref; + } + + // IUSBDevice interface functions + virtual NTSTATUS Initialize(IN PHUBCONTROLLER HubController, IN PUSBHARDWAREDEVICE Device, IN PVOID Parent, IN ULONG Port, IN ULONG PortStatus); + virtual BOOLEAN IsHub(); + virtual NTSTATUS GetParent(PVOID * Parent); + virtual ULONG GetDeviceAddress(); + virtual ULONG GetPort(); + virtual USB_DEVICE_SPEED GetSpeed(); + virtual USB_DEVICE_TYPE GetType(); + virtual ULONG GetState(); + virtual void SetDeviceHandleData(PVOID Data); + virtual NTSTATUS SetDeviceAddress(ULONG DeviceAddress); + virtual void GetDeviceDescriptor(PUSB_DEVICE_DESCRIPTOR DeviceDescriptor); + virtual UCHAR GetConfigurationValue(); + virtual NTSTATUS SubmitUrb(PURB Urb); + + // local function + virtual NTSTATUS CommitUrb(PURB Urb); + virtual NTSTATUS CommitSetupPacket(PUSB_DEFAULT_PIPE_SETUP_PACKET Packet, IN ULONG BufferLength, IN OUT PVOID Buffer, IN OPTIONAL PIRP Irp, IN OPTIONAL PKEVENT pEvent); + + // constructor / destructor + CUSBDevice(IUnknown *OuterUnknown){} + virtual ~CUSBDevice(){} + +protected: + LONG m_Ref; + PHUBCONTROLLER m_HubController; + PUSBHARDWAREDEVICE m_Device; + PVOID m_Parent; + ULONG m_Port; + ULONG m_DeviceAddress; + PVOID m_Data; + KSPIN_LOCK m_Lock; + USB_DEVICE_DESCRIPTOR m_DeviceDescriptor; + ULONG m_PortStatus; + PUSBQUEUE m_Queue; +}; + +//---------------------------------------------------------------------------------------- +NTSTATUS +STDMETHODCALLTYPE +CUSBDevice::QueryInterface( + IN REFIID refiid, + OUT PVOID* Output) +{ + return STATUS_UNSUCCESSFUL; +} + +//---------------------------------------------------------------------------------------- +NTSTATUS +CUSBDevice::Initialize( + IN PHUBCONTROLLER HubController, + IN PUSBHARDWAREDEVICE Device, + IN PVOID Parent, + IN ULONG Port, + IN ULONG PortStatus) +{ + NTSTATUS Status; + USB_DEFAULT_PIPE_SETUP_PACKET CtrlSetup; + + // + // initialize members + // + m_HubController = HubController; + m_Device = Device; + m_Parent = Parent; + m_Port = Port; + m_PortStatus = PortStatus; + + // + // initialize device lock + // + KeInitializeSpinLock(&m_Lock); + + // + // no device address has been set yet + // + m_DeviceAddress = 0; + + // + // get usb request queue + // + Status = m_Device->GetUSBQueue(&m_Queue); + if (!NT_SUCCESS(Status)) + { + // + // failed to get usb queue + // + DPRINT1("CUSBDevice::Initialize GetUsbQueue failed with %x\n", Status); + return Status; + } + + // + // zero descriptor + // + RtlZeroMemory(&m_DeviceDescriptor, sizeof(USB_DEVICE_DESCRIPTOR)); + RtlZeroMemory(&CtrlSetup, sizeof(USB_DEFAULT_PIPE_SETUP_PACKET)); + + // + // setup request + // + CtrlSetup.bRequest = USB_REQUEST_GET_DESCRIPTOR; + CtrlSetup.wValue.HiByte = USB_DEVICE_DESCRIPTOR_TYPE; + CtrlSetup.wLength = sizeof(USB_DEVICE_DESCRIPTOR); + CtrlSetup.bmRequestType.B = 0x80; + + // + // commit setup packet + // + Status = CommitSetupPacket(&CtrlSetup, sizeof(USB_DEVICE_DESCRIPTOR), &m_DeviceDescriptor, 0, 0); + + // + // check for success + // + if (!NT_SUCCESS(Status)) + { + DPRINT1("CUSBDevice::Initialize CommitSetupPacket failed with %x\n", Status); + } + + // + // done + // + return Status; +} + +//---------------------------------------------------------------------------------------- +BOOLEAN +CUSBDevice::IsHub() +{ + // + // USB Standard Device Class see
http://www.usb.org/developers/defined_class/#BaseClass09h
+ // for details + // + return (m_DeviceDescriptor.bDeviceClass == 0x09 && m_DeviceDescriptor.bDeviceSubClass == 0x00); +} + +//---------------------------------------------------------------------------------------- +NTSTATUS +CUSBDevice::GetParent( + PVOID * Parent) +{ + // + // returns parent + // + *Parent = m_Parent; + + // + // done + // + return STATUS_SUCCESS; +} + +//---------------------------------------------------------------------------------------- +ULONG +CUSBDevice::GetDeviceAddress() +{ + // + // get device address + // + return m_DeviceAddress; +} + +//---------------------------------------------------------------------------------------- +ULONG +CUSBDevice::GetPort() +{ + // + // get port to which this device is connected to + // + return m_Port; +} + +//---------------------------------------------------------------------------------------- +USB_DEVICE_SPEED +CUSBDevice::GetSpeed() +{ + if (m_PortStatus & USB_PORT_STATUS_LOW_SPEED) + { + // + // low speed device + // + return UsbLowSpeed; + } + else if (m_PortStatus & USB_PORT_STATUS_HIGH_SPEED) + { + // + // high speed device + // + return UsbHighSpeed; + } + + // + // default to full speed + // + return UsbFullSpeed; +} + +//---------------------------------------------------------------------------------------- +USB_DEVICE_TYPE +CUSBDevice::GetType() +{ + // + // device is encoded into bcdUSB + // + if (m_DeviceDescriptor.bcdUSB == 0x110) + { + // + // USB 1.1 device + // + return Usb11Device; + } + else if (m_DeviceDescriptor.bcdUSB == 0x200) + { + // + // USB 2.0 device + // + return Usb20Device; + } + + DPRINT1("CUSBDevice::GetType Unknown bcdUSB Type %x\n", m_DeviceDescriptor.bcdUSB); + PC_ASSERT(FALSE); + + return Usb11Device; +} + +//---------------------------------------------------------------------------------------- +ULONG +CUSBDevice::GetState() +{ + UNIMPLEMENTED + return FALSE; +} + +//---------------------------------------------------------------------------------------- +void +CUSBDevice::SetDeviceHandleData( + PVOID Data) +{ + // + // set device data, for debugging issues + // + m_Data = Data; +} + +//---------------------------------------------------------------------------------------- +NTSTATUS +CUSBDevice::SetDeviceAddress( + ULONG DeviceAddress) +{ + USB_DEFAULT_PIPE_SETUP_PACKET CtrlSetup; + NTSTATUS Status; + + // + // zero request + // + RtlZeroMemory(&CtrlSetup, sizeof(USB_DEFAULT_PIPE_SETUP_PACKET)); + + // + // initialize request + // + CtrlSetup.bRequest = USB_REQUEST_SET_ADDRESS; + CtrlSetup.wValue.W = DeviceAddress; + + // + // set device address + // + Status = CommitSetupPacket(&CtrlSetup, 0, 0, 0, 0); + + // + // check for success + // + if (!NT_SUCCESS(Status)) + { + // + // failed to set device address + // + DPRINT1("CUSBDevice::SetDeviceAddress> failed to set device address with %x Address %x\n", Status, DeviceAddress); + return Status; + } + + // + // store device address + // + m_DeviceAddress = DeviceAddress; + + // + // done + // + return STATUS_SUCCESS; +} + +//---------------------------------------------------------------------------------------- +void +CUSBDevice::GetDeviceDescriptor( + PUSB_DEVICE_DESCRIPTOR DeviceDescriptor) +{ + RtlMoveMemory(DeviceDescriptor, &m_DeviceDescriptor, sizeof(USB_DEVICE_DESCRIPTOR)); +} + +//---------------------------------------------------------------------------------------- +UCHAR +CUSBDevice::GetConfigurationValue() +{ + UNIMPLEMENTED + return 0x1; +} + +//---------------------------------------------------------------------------------------- +NTSTATUS +CUSBDevice::CommitUrb( + PURB Urb) +{ + UNIMPLEMENTED + return STATUS_NOT_IMPLEMENTED; +} + +//---------------------------------------------------------------------------------------- +NTSTATUS +CUSBDevice::SubmitUrb( + PURB Urb) +{ + KIRQL OldLevel; + NTSTATUS Status; + + // + // acquire device lock + // + KeAcquireSpinLock(&m_Lock, &OldLevel); + + // + // commit urb + // + Status = CommitUrb(Urb); + + // + // release lock + // + KeReleaseSpinLock(&m_Lock, OldLevel); + + return Status; +} +//---------------------------------------------------------------------------------------- +NTSTATUS +CUSBDevice::CommitSetupPacket( + PUSB_DEFAULT_PIPE_SETUP_PACKET Packet, + IN ULONG BufferLength, + IN OUT PVOID Buffer, + IN PIRP Irp, + IN PKEVENT pEvent) +{ + NTSTATUS Status; + PUSBREQUEST Request; + KEVENT Event; + BOOLEAN Wait = FALSE; + + if (!m_Queue) + { + // + // no queue, wtf? + // + DPRINT1("CUSBDevice::CommitSetupPacket> no queue!!!\n"); + return STATUS_UNSUCCESSFUL; + } + + // + // build usb request + // + Status = m_Queue->CreateUSBRequest(&Request); + if (!NT_SUCCESS(Status)) + { + // + // failed to build request + // + DPRINT1("CUSBDevice::CommitSetupPacket> CreateUSBRequest failed with %x\n", Status); + return Status; + } + + // + // initialize request + // + Status = Request->InitializeWithSetupPacket(Packet, BufferLength, Buffer); + if (!NT_SUCCESS(Status)) + { + // + // failed to initialize request + // + DPRINT1("CUSBDevice::CommitSetupPacket> failed to initialize usb request with %x\n", Status); + Request->Release(); + return Status; + } + + // + // is a irp or event provided ? + // + if (Irp == NULL && pEvent == NULL) + { + // + // no completion details provided, requestor wants synchronized + // + KeInitializeEvent(&Event, NotificationEvent, FALSE); + pEvent = &Event; + Wait = TRUE; + } + + // + // set completion details + // + Status = Request->SetCompletionDetails(Irp, pEvent); + if (!NT_SUCCESS(Status)) + { + // + // failed to set completion details + // + DPRINT1("CUSBDevice::CommitSetupPacket> failed to set completion details with %x\n", Status); + Request->Release(); + return Status; + } + + // + // now add the request + // + Status = m_Queue->AddUSBRequest(Request); + if (!NT_SUCCESS(Status)) + { + // + // failed to add request + // + DPRINT1("CUSBDevice::CommitSetupPacket> failed add request to queue with %x\n", Status); + Request->Release(); + return Status; + } + + if (Wait) + { + // + // wait for the operation to complete + // + KeWaitForSingleObject(pEvent, Executive, KernelMode, FALSE, NULL); + } + + //TODO: + // Get result code from operation + // + + // + // returns the result code when the operation has been finished + // + //Status = Request->GetResultCode(); + + // + // release request + // + Request->Release(); + + // + // done + // + return Status; +} +//---------------------------------------------------------------------------------------- NTSTATUS CreateUSBDevice( PUSBDEVICE *OutDevice) { - UNIMPLEMENTED - return STATUS_NOT_IMPLEMENTED; -} - + CUSBDevice * This; + + // + // allocate controller + // + This = new(NonPagedPool, TAG_USBEHCI) CUSBDevice(0); + if (!This) + { + // + // failed to allocate + // + return STATUS_INSUFFICIENT_RESOURCES; + } + + // + // add reference count + // + This->AddRef(); + + // + // return result + // + *OutDevice = (PUSBDEVICE)This; + + // + // done + // + return STATUS_SUCCESS; +} +
13 years, 8 months
1
0
0
0
← Newer
1
...
10
11
12
13
14
15
16
...
30
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
Results per page:
10
25
50
100
200