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
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
May 2011
----- 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
26 participants
511 discussions
Start a n
N
ew thread
[janderwald] 51585: [USBSTOR] - Rename common device extension, it conflicts with classpnp.h header structures - Start implementing disk ioctls - Implement SRB_FUNCTION_CLAIM_DEVICE, SRB_FUNCTION_R...
by janderwald@svn.reactos.org
Author: janderwald Date: Thu May 5 00:39:00 2011 New Revision: 51585 URL:
http://svn.reactos.org/svn/reactos?rev=51585&view=rev
Log: [USBSTOR] - Rename common device extension, it conflicts with classpnp.h header structures - Start implementing disk ioctls - Implement SRB_FUNCTION_CLAIM_DEVICE, SRB_FUNCTION_RELEASE_DEVICE Added: branches/usb-bringup/drivers/usb/usbstor/disk.c (with props) Modified: branches/usb-bringup/drivers/usb/usbstor/CMakeLists.txt branches/usb-bringup/drivers/usb/usbstor/usbstor.c branches/usb-bringup/drivers/usb/usbstor/usbstor.h Modified: branches/usb-bringup/drivers/usb/usbstor/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/usb/usbstor…
============================================================================== --- branches/usb-bringup/drivers/usb/usbstor/CMakeLists.txt [iso-8859-1] (original) +++ branches/usb-bringup/drivers/usb/usbstor/CMakeLists.txt [iso-8859-1] Thu May 5 00:39:00 2011 @@ -3,7 +3,7 @@ include_directories(${REACTOS_SOURCE_DIR}/ntoskrnl/include) -add_library(usbstor SHARED descriptor.c fdo.c misc.c pdo.c scsi.c usbstor.c usbstor.rc) +add_library(usbstor SHARED descriptor.c disk.c fdo.c misc.c pdo.c scsi.c usbstor.c usbstor.rc) set_module_type(usbstor kernelmodedriver) add_importlibs(usbstor ntoskrnl hal usbd) Added: branches/usb-bringup/drivers/usb/usbstor/disk.c URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/usb/usbstor…
============================================================================== --- branches/usb-bringup/drivers/usb/usbstor/disk.c (added) +++ branches/usb-bringup/drivers/usb/usbstor/disk.c [iso-8859-1] Thu May 5 00:39:00 2011 @@ -1,0 +1,169 @@ +/* + * PROJECT: ReactOS Universal Serial Bus Bulk Storage Driver + * LICENSE: GPL - See COPYING in the top level directory + * FILE: drivers/usb/usbstor/disk.c + * PURPOSE: USB block storage device driver. + * PROGRAMMERS: + * James Tabor + * Michael Martin (michael.martin(a)reactos.org) + * Johannes Anderwald (johannes.anderwald(a)reactos.org) + */ + +#include "usbstor.h" + +NTSTATUS +USBSTOR_HandleExecuteSCSI( + IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp, + IN OUT PSCSI_REQUEST_BLOCK Request, + IN PPDO_DEVICE_EXTENSION PDODeviceExtension) +{ + DPRINT1("USBSTOR_HandleExecuteSCSI\n"); + + DbgBreakPoint(); + + Request->SrbStatus = SRB_STATUS_ERROR; + return STATUS_NOT_SUPPORTED; +} + +NTSTATUS +USBSTOR_HandleInternalDeviceControl( + IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp) +{ + PIO_STACK_LOCATION IoStack; + PSCSI_REQUEST_BLOCK Request; + PPDO_DEVICE_EXTENSION PDODeviceExtension; + NTSTATUS Status; + + // + // get current stack location + // + IoStack = IoGetCurrentIrpStackLocation(Irp); + + // + // get request block + // + Request = (PSCSI_REQUEST_BLOCK)IoStack->Parameters.Others.Argument1; + + // + // get device extension + // + PDODeviceExtension = (PPDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension; + + // + // sanity check + // + ASSERT(Request); + ASSERT(PDODeviceExtension); + + switch(Request->Function) + { + case SRB_FUNCTION_EXECUTE_SCSI: + { + DPRINT1("SRB_FUNCTION_EXECUTE_SCSI\n"); + Status = USBSTOR_HandleExecuteSCSI(DeviceObject, Irp, Request, PDODeviceExtension); + + } + case SRB_FUNCTION_RELEASE_DEVICE: + { + DPRINT1("SRB_FUNCTION_RELEASE_DEVICE\n"); + // + // sanity check + // + ASSERT(PDODeviceExtension->Claimed == TRUE); + + // + // release claim + // + PDODeviceExtension->Claimed = TRUE; + Status = STATUS_SUCCESS; + break; + } + case SRB_FUNCTION_CLAIM_DEVICE: + { + DPRINT1("SRB_FUNCTION_CLAIM_DEVICE\n"); + // + // check if the device has been claimed + // + if (PDODeviceExtension->Claimed) + { + // + // device has already been claimed + // + Status = STATUS_DEVICE_BUSY; + Request->SrbStatus = SRB_STATUS_BUSY; + break; + } + + // + // claim device + // + PDODeviceExtension->Claimed = TRUE; + + // + // output device object + // + Request->DataBuffer = DeviceObject; + + // + // completed successfully + // + Status = STATUS_SUCCESS; + break; + } + case SRB_FUNCTION_RELEASE_QUEUE: + { + DPRINT1("SRB_FUNCTION_RELEASE_QUEUE UNIMPLEMENTED\n"); + Status = STATUS_NOT_IMPLEMENTED; + break; + } + case SRB_FUNCTION_FLUSH: + { + DPRINT1("SRB_FUNCTION_FLUSH UNIMPLEMENTED\n"); + Status = STATUS_NOT_IMPLEMENTED; + break; + } + case SRB_FUNCTION_SET_LINK_TIMEOUT: + { + DPRINT1("SRB_FUNCTION_FLUSH UNIMPLEMENTED\n"); + Status = STATUS_NOT_IMPLEMENTED; + break; + } + default: + { + // + // not supported + // + Status = STATUS_NOT_SUPPORTED; + Request->SrbStatus = SRB_STATUS_ERROR; + } + } + + return Status; +} + +NTSTATUS +USBSTOR_HandleDeviceControl( + IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp) +{ + PIO_STACK_LOCATION IoStack; + + // + // get current stack location + // + IoStack = IoGetCurrentIrpStackLocation(Irp); + + DPRINT1("USBSTOR_HandleDeviceControl IoControl %x\n", IoStack->Parameters.DeviceIoControl.IoControlCode); + DPRINT1("USBSTOR_HandleDeviceControl InputBufferLength %x\n", IoStack->Parameters.DeviceIoControl.InputBufferLength); + DPRINT1("USBSTOR_HandleDeviceControl OutputBufferLength %x\n", IoStack->Parameters.DeviceIoControl.OutputBufferLength); + DPRINT1("USBSTOR_HandleDeviceControl InputBuffer %x\n", IoStack->Parameters.DeviceIoControl.Type3InputBuffer); + DPRINT1("USBSTOR_HandleDeviceControl SystemBuffer %x\n", Irp->AssociatedIrp.SystemBuffer); + DPRINT1("USBSTOR_HandleDeviceControl UserBuffer %x\n", Irp->UserBuffer); + DPRINT1("USBSTOR_HandleDeviceControl MdlAddress %x\n", Irp->MdlAddress); + + //IOCTL_STORAGE_QUERY_PROPERTY + + return STATUS_NOT_SUPPORTED; +} Propchange: branches/usb-bringup/drivers/usb/usbstor/disk.c ------------------------------------------------------------------------------ svn:eol-style = native Modified: branches/usb-bringup/drivers/usb/usbstor/usbstor.c URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/usb/usbstor…
============================================================================== --- branches/usb-bringup/drivers/usb/usbstor/usbstor.c [iso-8859-1] (original) +++ branches/usb-bringup/drivers/usb/usbstor/usbstor.c [iso-8859-1] Thu May 5 00:39:00 2011 @@ -134,11 +134,16 @@ PDEVICE_OBJECT DeviceObject, PIRP Irp) { - DPRINT1("USBSTOR_DispatchDeviceControl\n"); - Irp->IoStatus.Information = 0; - Irp->IoStatus.Status = STATUS_SUCCESS; - IoCompleteRequest(Irp, IO_NO_INCREMENT); - return STATUS_SUCCESS; + NTSTATUS Status; + + // + // handle requests + // + Status = USBSTOR_HandleDeviceControl(DeviceObject, Irp); + + Irp->IoStatus.Information = 0; + Irp->IoStatus.Status = Status; + IoCompleteRequest(Irp, IO_NO_INCREMENT); } @@ -148,12 +153,17 @@ PDEVICE_OBJECT DeviceObject, PIRP Irp) { - DPRINT1("USBSTOR_DispatchScsi\n"); - - Irp->IoStatus.Information = 0; - Irp->IoStatus.Status = STATUS_SUCCESS; - IoCompleteRequest(Irp, IO_NO_INCREMENT); - return STATUS_SUCCESS; + NTSTATUS Status; + + // + // handle requests + // + Status = USBSTOR_HandleInternalDeviceControl(DeviceObject, Irp); + + Irp->IoStatus.Information = 0; + Irp->IoStatus.Status = Status; + IoCompleteRequest(Irp, IO_NO_INCREMENT); + return Status; } NTSTATUS @@ -165,7 +175,6 @@ // // read write ioctl is not supported // - DPRINT1("USBSTOR_DispatchReadWrite\n"); Irp->IoStatus.Information = 0; Irp->IoStatus.Status = STATUS_INVALID_PARAMETER; IoCompleteRequest(Irp, IO_NO_INCREMENT); @@ -178,12 +187,12 @@ PDEVICE_OBJECT DeviceObject, PIRP Irp) { - PCOMMON_DEVICE_EXTENSION DeviceExtension; + PUSBSTOR_COMMON_DEVICE_EXTENSION DeviceExtension; // // get common device extension // - DeviceExtension = (PCOMMON_DEVICE_EXTENSION)DeviceObject->DeviceExtension; + DeviceExtension = (PUSBSTOR_COMMON_DEVICE_EXTENSION)DeviceObject->DeviceExtension; // // is it for the FDO Modified: branches/usb-bringup/drivers/usb/usbstor/usbstor.h URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/usb/usbstor…
============================================================================== --- branches/usb-bringup/drivers/usb/usbstor/usbstor.h [iso-8859-1] (original) +++ branches/usb-bringup/drivers/usb/usbstor/usbstor.h [iso-8859-1] Thu May 5 00:39:00 2011 @@ -13,7 +13,7 @@ #include <usbdlib.h> #include <stdio.h> #include <wdmguid.h> - +#include <classpnp.h> #define USB_STOR_TAG 'sbsu' #define USB_MAXCHILDREN (16) @@ -24,15 +24,15 @@ IN PDEVICE_OBJECT TargetDevice, OUT PDEVICE_OBJECT *AttachedToDeviceObject); -typedef struct _COMMON_DEVICE_EXTENSION +typedef struct __COMMON_DEVICE_EXTENSION__ { BOOLEAN IsFDO; -}COMMON_DEVICE_EXTENSION, *PCOMMON_DEVICE_EXTENSION; - -typedef struct -{ - COMMON_DEVICE_EXTENSION Common; // common device extension +}USBSTOR_COMMON_DEVICE_EXTENSION, *PUSBSTOR_COMMON_DEVICE_EXTENSION; + +typedef struct +{ + USBSTOR_COMMON_DEVICE_EXTENSION Common; // common device extension PDEVICE_OBJECT FunctionalDeviceObject; // functional device object PDEVICE_OBJECT PhysicalDeviceObject; // physical device object @@ -50,12 +50,12 @@ typedef struct { - COMMON_DEVICE_EXTENSION Common; + USBSTOR_COMMON_DEVICE_EXTENSION Common; PDEVICE_OBJECT LowerDeviceObject; // points to FDO UCHAR LUN; // lun id PVOID InquiryData; // USB SCSI inquiry data + UCHAR Claimed; // indicating if it has been claimed by upper driver }PDO_DEVICE_EXTENSION, *PPDO_DEVICE_EXTENSION; - // // max lun command identifier @@ -213,3 +213,18 @@ NTSTATUS USBSTOR_SendInquiryCmd( IN PDEVICE_OBJECT DeviceObject); + + +//--------------------------------------------------------------------- +// +// disk.c routines +// +NTSTATUS +USBSTOR_HandleInternalDeviceControl( + IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp); + +NTSTATUS +USBSTOR_HandleDeviceControl( + IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp);
13 years, 6 months
1
0
0
0
[janderwald] 51584: [USBEHCI_NEW] - Silence debug flood
by janderwald@svn.reactos.org
Author: janderwald Date: Thu May 5 00:35:56 2011 New Revision: 51584 URL:
http://svn.reactos.org/svn/reactos?rev=51584&view=rev
Log: [USBEHCI_NEW] - Silence debug flood Modified: branches/usb-bringup/drivers/usb/usbehci_new/usbehci.h 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] Thu May 5 00:35:56 2011 @@ -2,7 +2,7 @@ #define USBEHCI_H__ #include <ntddk.h> -#define YDEBUG +#define NDEBUG #include <debug.h> #include <hubbusif.h> #include <usbbusif.h>
13 years, 6 months
1
0
0
0
[jimtabor] 51583: [Win32k] - Move hook call close to the keyboard message post. This allows the registering of Aly keys before the hook call. This fixes all but one GetKeyState Api Test. - Fix GetA...
by jimtabor@svn.reactos.org
Author: jimtabor Date: Wed May 4 23:37:35 2011 New Revision: 51583 URL:
http://svn.reactos.org/svn/reactos?rev=51583&view=rev
Log: [Win32k] - Move hook call close to the keyboard message post. This allows the registering of Aly keys before the hook call. This fixes all but one GetKeyState Api Test. - Fix GetAsync/KeyState error codes and the return for GetAsyncKeyState. See
http://appdb.winehq.org/objectManager.php?sClass=version&iId=8516&iTestingI…
- Fix TranslateMessage, check for window and use the window pti for re-posting to message queue. - Peeking hardware queue should be the same as other Peek queue. Modified: trunk/reactos/subsystems/win32/win32k/ntuser/input.c trunk/reactos/subsystems/win32/win32k/ntuser/keyboard.c trunk/reactos/subsystems/win32/win32k/ntuser/msgqueue.c Modified: trunk/reactos/subsystems/win32/win32k/ntuser/input.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/nt…
============================================================================== --- trunk/reactos/subsystems/win32/win32k/ntuser/input.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/ntuser/input.c [iso-8859-1] Wed May 4 23:37:35 2011 @@ -1333,6 +1333,27 @@ Msg.lParam = MAKELPARAM(1 /* repeat count */, ki->wScan); } + if (!(ki->dwFlags & KEYEVENTF_UNICODE)) + { + if (ki->dwFlags & KEYEVENTF_KEYUP) + { + gQueueKeyStateTable[wVk] &= ~0x80; + gQueueKeyStateTable[wVkStripped] = gQueueKeyStateTable[wVkL] | gQueueKeyStateTable[wVkR]; + } + else + { + if (!(gQueueKeyStateTable[wVk] & 0x80)) gQueueKeyStateTable[wVk] ^= 0x01; + gQueueKeyStateTable[wVk] |= 0xc0; + gQueueKeyStateTable[wVkStripped] = gQueueKeyStateTable[wVkL] | gQueueKeyStateTable[wVkR]; + } + + if (gQueueKeyStateTable[VK_MENU] & 0x80) flags |= KF_ALTDOWN; + + if (wVkStripped == VK_SHIFT) flags &= ~KF_EXTENDED; + + Msg.lParam = MAKELPARAM(1 /* repeat count */, flags); + } + FocusMessageQueue = IntGetFocusMessageQueue(); Msg.hwnd = 0; @@ -1365,27 +1386,6 @@ return FALSE; } - if (!(ki->dwFlags & KEYEVENTF_UNICODE)) - { - if (ki->dwFlags & KEYEVENTF_KEYUP) - { - gQueueKeyStateTable[wVk] &= ~0x80; - gQueueKeyStateTable[wVkStripped] = gQueueKeyStateTable[wVkL] | gQueueKeyStateTable[wVkR]; - } - else - { - if (!(gQueueKeyStateTable[wVk] & 0x80)) gQueueKeyStateTable[wVk] ^= 0x01; - gQueueKeyStateTable[wVk] |= 0xc0; - gQueueKeyStateTable[wVkStripped] = gQueueKeyStateTable[wVkL] | gQueueKeyStateTable[wVkR]; - } - - if (gQueueKeyStateTable[VK_MENU] & 0x80) flags |= KF_ALTDOWN; - - if (wVkStripped == VK_SHIFT) flags &= ~KF_EXTENDED; - - Msg.lParam = MAKELPARAM(1 /* repeat count */, flags); - } - if (FocusMessageQueue == NULL) { DPRINT("No focus message queue\n"); @@ -1400,7 +1400,6 @@ FocusMessageQueue->Desktop->pDeskInfo->LastInputWasKbd = TRUE; - Msg.pt = gpsi->ptCursor; // Post to hardware queue, based on the first part of wine "some GetMessage tests" // in test_PeekMessage() MsqPostMessage(FocusMessageQueue, &Msg, TRUE, QS_KEY); 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] Wed May 4 23:37:35 2011 @@ -341,8 +341,13 @@ { ret = ((DWORD)(gQueueKeyStateTable[key] & KS_DOWN_BIT) << 8 ) | (gQueueKeyStateTable[key] & KS_LOCK_BIT); - } - + if ( ret & 0x8000 ) + ret |= 0xFFFF0000; // If down, windows returns 0xFFFF8000. + } + else + { + EngSetLastError(ERROR_INVALID_PARAMETER); + } return ret; } @@ -355,19 +360,19 @@ if (gpsi->aiSysMet[SM_SWAPBUTTON]) { - if (UserGetAsyncKeyState(VK_RBUTTON) & 0x80) ret |= MK_LBUTTON; - if (UserGetAsyncKeyState(VK_LBUTTON) & 0x80) ret |= MK_RBUTTON; + if (gQueueKeyStateTable[VK_RBUTTON] & 0x80) ret |= MK_LBUTTON; + if (gQueueKeyStateTable[VK_LBUTTON] & 0x80) ret |= MK_RBUTTON; } else { - if (UserGetAsyncKeyState(VK_LBUTTON) & 0x80) ret |= MK_LBUTTON; - if (UserGetAsyncKeyState(VK_RBUTTON) & 0x80) ret |= MK_RBUTTON; + if (gQueueKeyStateTable[VK_LBUTTON] & 0x80) ret |= MK_LBUTTON; + if (gQueueKeyStateTable[VK_RBUTTON] & 0x80) ret |= MK_RBUTTON; } - if (UserGetAsyncKeyState(VK_MBUTTON) & 0x80) ret |= MK_MBUTTON; - if (UserGetAsyncKeyState(VK_SHIFT) & 0x80) ret |= MK_SHIFT; - if (UserGetAsyncKeyState(VK_CONTROL) & 0x80) ret |= MK_CONTROL; - if (UserGetAsyncKeyState(VK_XBUTTON1) & 0x80) ret |= MK_XBUTTON1; - if (UserGetAsyncKeyState(VK_XBUTTON2) & 0x80) ret |= MK_XBUTTON2; + if (gQueueKeyStateTable[VK_MBUTTON] & 0x80) ret |= MK_MBUTTON; + if (gQueueKeyStateTable[VK_SHIFT] & 0x80) ret |= MK_SHIFT; + if (gQueueKeyStateTable[VK_CONTROL] & 0x80) ret |= MK_CONTROL; + if (gQueueKeyStateTable[VK_XBUTTON1] & 0x80) ret |= MK_XBUTTON1; + if (gQueueKeyStateTable[VK_XBUTTON2] & 0x80) ret |= MK_XBUTTON2; return ret; } @@ -401,9 +406,17 @@ WCHAR wp[2] = { 0 }; MSG NewMsg = { 0 }; PKBDTABLES keyLayout; + PWND pWndMsg; BOOL Result = FALSE; - pti = PsGetCurrentThreadWin32Thread(); + pWndMsg = UserGetWindowObject(lpMsg->hwnd); + if (!pWndMsg) // Must have a window! + { + DPRINT1("No Window for Translate.\n"); + return FALSE; + } + + pti = pWndMsg->head.pti; keyLayout = pti->KeyboardLayout->KBTables; if( !keyLayout ) return FALSE; @@ -415,6 +428,8 @@ /* All messages have to contain the cursor point. */ NewMsg.pt = gpsi->ptCursor; + + DPRINT("IntTranslateKbdMessage %s\n", lpMsg->message == WM_SYSKEYDOWN ? "WM_SYSKEYDOWN" : "WM_KEYDOWN"); switch (lpMsg->wParam) { @@ -427,9 +442,13 @@ return TRUE; } - UState = ToUnicodeInner(lpMsg->wParam, HIWORD(lpMsg->lParam) & 0xff, - gQueueKeyStateTable, wp, 2, 0, - keyLayout ); + UState = ToUnicodeInner( lpMsg->wParam, + HIWORD(lpMsg->lParam) & 0xff, + gQueueKeyStateTable, + wp, + 2, + 0, + keyLayout ); if (UState == 1) { @@ -482,7 +501,7 @@ MsqPostMessage(pti->MessageQueue, &NewMsg, FALSE, QS_KEY); Result = TRUE; } - + DPRINT("IntTranslateKbdMessage E %s\n", NewMsg.message == WM_CHAR ? "WM_CHAR" : "WM_SYSCHAR"); return Result; } @@ -839,6 +858,8 @@ * * Shift and the LP_EXT_BIT cancel. */ ScanCode = (Msg->lParam >> 16) & 0xff; + DPRINT("ScanCode %04x\n",ScanCode); + BaseMapping = Msg->wParam = IntMapVirtualKeyEx( ScanCode, 1, KeyboardLayout ); if( Prefix == 0 ) 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] Wed May 4 23:37:35 2011 @@ -56,7 +56,10 @@ if (MessageQueue->KeyState[key] & KS_DOWN_BIT) ret |= 0xFF00; // If down, windows returns 0xFF80. } - + else + { + EngSetLastError(ERROR_INVALID_PARAMETER); + } return ret; } @@ -1457,9 +1460,17 @@ if (IsListEmpty(CurrentEntry)) break; if (!CurrentMessage) break; CurrentEntry = CurrentMessage->ListEntry.Flink; - - if ( (( MsgFilterLow == 0 && MsgFilterHigh == 0 ) && (CurrentMessage->QS_Flags & QSflags)) || - ( MsgFilterLow <= CurrentMessage->Msg.message && MsgFilterHigh >= CurrentMessage->Msg.message ) ) +/* + MSDN: + 1: any window that belongs to the current thread, and any messages on the current thread's message queue whose hwnd value is NULL. + 2: retrieves only messages on the current thread's message queue whose hwnd value is NULL. + 3: handle to the window whose messages are to be retrieved. + */ + if ( ( !Window || // 1 + ( Window == HWND_BOTTOM && CurrentMessage->Msg.hwnd == NULL ) || // 2 + ( Window != HWND_BOTTOM && Window->head.h == CurrentMessage->Msg.hwnd ) ) && // 3 + ( ( ( MsgFilterLow == 0 && MsgFilterHigh == 0 ) && CurrentMessage->QS_Flags & QSflags ) || + ( MsgFilterLow <= CurrentMessage->Msg.message && MsgFilterHigh >= CurrentMessage->Msg.message ) ) ) { msg = CurrentMessage->Msg;
13 years, 6 months
1
0
0
0
[janderwald] 51582: [USBSTOR] - Make DeviceId generation to match ms usbstor - Don't hardcode the device type in USBSTOR_PdoHandleQueryHardwareId - Don't hardcode device type in USBSTOR_PdoHandleQu...
by janderwald@svn.reactos.org
Author: janderwald Date: Wed May 4 23:14:32 2011 New Revision: 51582 URL:
http://svn.reactos.org/svn/reactos?rev=51582&view=rev
Log: [USBSTOR] - Make DeviceId generation to match ms usbstor - Don't hardcode the device type in USBSTOR_PdoHandleQueryHardwareId - Don't hardcode device type in USBSTOR_PdoHandleQueryCompatibleId - Hackfix generation of instance id - Add comments - Cleanup code - Usbstor now receives ioctl from disk.sys Modified: branches/usb-bringup/drivers/usb/usbstor/pdo.c Modified: branches/usb-bringup/drivers/usb/usbstor/pdo.c URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/usb/usbstor…
============================================================================== --- branches/usb-bringup/drivers/usb/usbstor/pdo.c [iso-8859-1] (original) +++ branches/usb-bringup/drivers/usb/usbstor/pdo.c [iso-8859-1] Wed May 4 23:14:32 2011 @@ -80,7 +80,7 @@ } } -LPCWSTR +LPCSTR USBSTOR_GetGenericType( IN PUFI_INQUIRY_RESPONSE InquiryData) { @@ -96,7 +96,7 @@ // // FIXME: check if floppy // - return L"GenDisk"; + return "GenDisk"; } // @@ -109,42 +109,42 @@ // // sequential device, i.e magnetic tape // - return L"GenSequential"; + return "GenSequential"; } case 4: { // // write once device // - return L"GenWorm"; + return "GenWorm"; } case 5: { // // CDROM device // - return L"GenCdRom"; + return "GenCdRom"; } case 7: { // // optical memory device // - return L"GenOptical"; + return "GenOptical"; } case 8: { // // medium change device // - return L"GenChanger"; + return "GenChanger"; } default: { // // other device // - return L"UsbstorOther"; + return "UsbstorOther"; } } } @@ -252,8 +252,6 @@ } } - - NTSTATUS @@ -270,8 +268,6 @@ ANSI_STRING AnsiString; UNICODE_STRING DeviceId; - DPRINT1("USBSTOR_PdoHandleQueryDeviceId\n"); - // // get device extension // @@ -300,21 +296,13 @@ // // lets create device string // - Offset = sprintf(&Buffer[Offset], "USBSTOR\\") + 1; - - // - // copy vendor id - // + Offset = sprintf(&Buffer[Offset], "USBSTOR\\"); + Offset += sprintf(&Buffer[Offset], DeviceType); + Offset += sprintf(&Buffer[Offset], "&Ven_"); Offset += CopyField(InquiryData->Vendor, &Buffer[Offset], 8); - - // - // copy product identifier - // + Offset += sprintf(&Buffer[Offset], "&Prod_"); Offset += CopyField(InquiryData->Product, &Buffer[Offset], 16); - - // - // copy revision identifer - // + Offset += sprintf(&Buffer[Offset], "&Rev_"); Offset += CopyField(InquiryData->Revision, &Buffer[Offset], 4); // @@ -374,14 +362,23 @@ ASSERT(ResultBufferLength); ASSERT(ResultBufferLength > ResultBufferOffset); - DPRINT1("ResultBufferOffset %lu ResultBufferLength %lu Buffer %s Length %lu\n", ResultBufferOffset, ResultBufferLength, Buffer, strlen(Buffer)); - + DPRINT("ResultBufferOffset %lu ResultBufferLength %lu Buffer %s Length %lu\n", ResultBufferOffset, ResultBufferLength, Buffer, strlen(Buffer)); + + // + // construct destination string + // DeviceString.Buffer = &ResultBuffer[ResultBufferOffset]; DeviceString.Length = 0; DeviceString.MaximumLength = (ResultBufferLength - ResultBufferOffset) * sizeof(WCHAR); + // + // initialize source string + // RtlInitAnsiString(&AnsiString, Buffer); + // + // convert to unicode + // Status = RtlAnsiStringToUnicodeString(&DeviceString, &AnsiString, FALSE); ASSERT(Status == STATUS_SUCCESS); @@ -406,15 +403,13 @@ { PPDO_DEVICE_EXTENSION PDODeviceExtension; PFDO_DEVICE_EXTENSION FDODeviceExtension; - LPCWSTR GenericType; + LPCSTR GenericType, DeviceType; LPWSTR Buffer; CHAR Id1[50], Id2[50], Id3[50], Id4[50], Id5[50], Id6[50]; ULONG Id1Length, Id2Length, Id3Length, Id4Length, Id5Length,Id6Length; ULONG Offset, TotalLength, Length; PUFI_INQUIRY_RESPONSE InquiryData; - DPRINT1("USBSTOR_PdoHandleQueryHardwareId\n"); - // // get PDO device extension // @@ -437,9 +432,11 @@ // - // get generic type - // + // get device type and generic type + // + DeviceType = USBSTOR_GetDeviceType(InquiryData); GenericType = USBSTOR_GetGenericType(InquiryData); + ASSERT(GenericType); // @@ -449,12 +446,12 @@ RtlZeroMemory(Id1, sizeof(Id1)); Offset = 0; Offset = sprintf(&Id1[Offset], "USBSTOR\\"); - Offset += sprintf(&Id1[Offset], "Disk"); //FIXME + Offset += sprintf(&Id1[Offset], DeviceType); Offset += CopyField(InquiryData->Vendor, &Id1[Offset], 8); Offset += CopyField(InquiryData->Product, &Id1[Offset], 16); Offset += CopyField(InquiryData->Revision, &Id1[Offset], 4); Id1Length = strlen(Id1) + 1; - DPRINT1("HardwareId1 %s\n", Id1); + DPRINT1("USBSTOR_PdoHandleQueryHardwareId HardwareId1 %s\n", Id1); // // generate id 2 @@ -463,11 +460,11 @@ RtlZeroMemory(Id2, sizeof(Id2)); Offset = 0; Offset = sprintf(&Id2[Offset], "USBSTOR\\"); - Offset += sprintf(&Id2[Offset], "Disk"); //FIXME + Offset += sprintf(&Id2[Offset], DeviceType); Offset += CopyField(InquiryData->Vendor, &Id2[Offset], 8); Offset += CopyField(InquiryData->Product, &Id2[Offset], 16); Id2Length = strlen(Id2) + 1; - DPRINT1("HardwareId2 %s\n", Id2); + DPRINT1("USBSTOR_PdoHandleQueryHardwareId HardwareId2 %s\n", Id2); // // generate id 3 @@ -476,10 +473,10 @@ RtlZeroMemory(Id3, sizeof(Id3)); Offset = 0; Offset = sprintf(&Id3[Offset], "USBSTOR\\"); - Offset += sprintf(&Id3[Offset], "Disk"); //FIXME + Offset += sprintf(&Id3[Offset], DeviceType); Offset += CopyField(InquiryData->Vendor, &Id3[Offset], 8); Id3Length = strlen(Id3) + 1; - DPRINT1("HardwareId3 %s\n", Id3); + DPRINT1("USBSTOR_PdoHandleQueryHardwareId HardwareId3 %s\n", Id3); // // generate id 4 @@ -488,12 +485,12 @@ RtlZeroMemory(Id4, sizeof(Id4)); Offset = 0; Offset = sprintf(&Id4[Offset], "USBSTOR\\"); - Offset += sprintf(&Id4[Offset], "Disk"); //FIXME + Offset += sprintf(&Id4[Offset], DeviceType); Offset += CopyField(InquiryData->Vendor, &Id4[Offset], 8); Offset += CopyField(InquiryData->Product, &Id4[Offset], 16); Offset += CopyField(InquiryData->Revision, &Id4[Offset], 1); Id4Length = strlen(Id4) + 1; - DPRINT1("HardwareId4 %s\n", Id4); + DPRINT1("USBSTOR_PdoHandleQueryHardwareId HardwareId4 %s\n", Id4); // // generate id 5 @@ -502,9 +499,9 @@ RtlZeroMemory(Id5, sizeof(Id5)); Offset = 0; Offset = sprintf(&Id5[Offset], "USBSTOR\\"); - Offset += sprintf(&Id5[Offset], "GenDisk"); //FIXME + Offset += sprintf(&Id5[Offset], GenericType); Id5Length = strlen(Id5) + 1; - DPRINT1("HardwareId5 %s\n", Id5); + DPRINT1("USBSTOR_PdoHandleQueryHardwareId HardwareId5 %s\n", Id5); // // generate id 6 @@ -512,9 +509,9 @@ // RtlZeroMemory(Id6, sizeof(Id6)); Offset = 0; - Offset = sprintf(&Id6[Offset], "GenDisk"); //FIXME + Offset = sprintf(&Id6[Offset], GenericType); Id6Length = strlen(Id6) + 1; - DPRINT1("HardwareId6 %s\n", Id6); + DPRINT1("USBSTOR_PdoHandleQueryHardwareId HardwareId6 %s\n", Id6); // // compute total length @@ -547,7 +544,10 @@ USBSTOR_ConvertToUnicodeString(Id5, Length, Offset, Buffer, &Offset); USBSTOR_ConvertToUnicodeString(Id6, Length, Offset, Buffer, &Offset); - DPRINT1("Offset %lu Length %lu\n", Offset, Length); + // + // sanity check + // + ASSERT(Offset + 1 == Length); // // store result @@ -567,13 +567,11 @@ { PPDO_DEVICE_EXTENSION PDODeviceExtension; PFDO_DEVICE_EXTENSION FDODeviceExtension; - WCHAR Buffer[100]; - ULONG Length; + CHAR Buffer[100]; + ULONG Length, Offset; LPWSTR InstanceId; LPCSTR DeviceType; - DPRINT1("USBSTOR_PdoHandleQueryCompatibleId\n"); - // // get PDO device extension // @@ -602,22 +600,8 @@ // // format instance id // - Length = swprintf(Buffer, L"USBSTOR\\%s", L"Disk") + 1; - Length += swprintf(&Buffer[Length], L"USBSTOR\\%s", L"RAW") + 2; - - // - // verify this - // - // Length += swprintf(&Buffer[Length], L"USBSTOR\\RAW") + 1; - - //Buffer[Length] = UNICODE_NULL; - //Buffer[Length+1] = UNICODE_NULL; - //Length++; - - // - // calculate length - // - + Length = sprintf(Buffer, L"USBSTOR\\%s", DeviceType) + 1; + Length += sprintf(&Buffer[Length], L"USBSTOR\\%s", L"RAW") + 2; // // allocate instance id @@ -632,12 +616,10 @@ return STATUS_INSUFFICIENT_RESOURCES; } - // - // copy instance id - // - wcscpy(InstanceId, Buffer); - - DPRINT1("USBSTOR_PdoHandleQueryInstanceId %S\n", InstanceId); + USBSTOR_ConvertToUnicodeString(Buffer, Length, 0, InstanceId, &Offset); + USBSTOR_ConvertToUnicodeString(&Buffer[Offset], Length, Offset, InstanceId, &Offset); + + DPRINT1("USBSTOR_PdoHandleQueryCompatibleId %S\n", InstanceId); // // store result @@ -656,32 +638,20 @@ IN OUT PIRP Irp) { PPDO_DEVICE_EXTENSION PDODeviceExtension; - PFDO_DEVICE_EXTENSION FDODeviceExtension; WCHAR Buffer[100]; ULONG Length; LPWSTR InstanceId; - DPRINT1("USBSTOR_PdoHandleQueryInstanceId\n"); - // // get PDO device extension // PDODeviceExtension = (PPDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension; // - // get FDO device extension - // - FDODeviceExtension = (PFDO_DEVICE_EXTENSION)PDODeviceExtension->LowerDeviceObject->DeviceExtension; - - // - // sanity check - // - ASSERT(FDODeviceExtension->DeviceDescriptor); - - // // format instance id - // - swprintf(Buffer, L"USB\\VID_%04x&PID_%04x\\%s", FDODeviceExtension->DeviceDescriptor->idVendor, FDODeviceExtension->DeviceDescriptor->idProduct, L"09188212515A"); + // FIXME: retrieve serial number from string device descriptor + // + swprintf(Buffer, L"%s&%d", L"09188212515A", PDODeviceExtension->LUN); // // calculate length @@ -927,7 +897,7 @@ // // create child device object // - Status = IoCreateDevice(DeviceObject->DriverObject, sizeof(PDO_DEVICE_EXTENSION), NULL, FILE_DEVICE_MASS_STORAGE, FILE_AUTOGENERATED_DEVICE_NAME, FALSE, &PDO); + Status = IoCreateDevice(DeviceObject->DriverObject, sizeof(PDO_DEVICE_EXTENSION), NULL, FILE_DEVICE_MASS_STORAGE, FILE_AUTOGENERATED_DEVICE_NAME | FILE_DEVICE_SECURE_OPEN, FALSE, &PDO); if (!NT_SUCCESS(Status)) { //
13 years, 6 months
1
0
0
0
[mjmartin] 51581: [USBHUB_NEW] - Add UsbDeviceHandle to child device extensions structure to be passed with URB requests. - Reimplement the Worker Thread DeviceStatusChangeThread called on SCE comp...
by mjmartin@svn.reactos.org
Author: mjmartin Date: Wed May 4 21:45:55 2011 New Revision: 51581 URL:
http://svn.reactos.org/svn/reactos?rev=51581&view=rev
Log: [USBHUB_NEW] - Add UsbDeviceHandle to child device extensions structure to be passed with URB requests. - Reimplement the Worker Thread DeviceStatusChangeThread called on SCE completion. Each SetFeature and ClearFeature resend SCE request. Only create the usb child device if the PortStatusChange member of the device extensions was modified. - Implement CreateUsbChildDeviceObject used for creating a deviceobject for the USB device and initializing it. - Implement GetUsbStringDescriptor for getting DeviceId, TextDescription and InstanceId from USB Device. - Move the initial QueryStatusChangeEndpoint to after the hub device receives start pnp. - USBHUB driver is now back to the same functionality of previous version. Showing the device wizard for connected devices. Modified: branches/usb-bringup/drivers/usb/usbhub_new/fdo.c branches/usb-bringup/drivers/usb/usbhub_new/pdo.c branches/usb-bringup/drivers/usb/usbhub_new/usbhub.h Modified: branches/usb-bringup/drivers/usb/usbhub_new/fdo.c URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/usb/usbhub_…
============================================================================== --- branches/usb-bringup/drivers/usb/usbhub_new/fdo.c [iso-8859-1] (original) +++ branches/usb-bringup/drivers/usb/usbhub_new/fdo.c [iso-8859-1] Wed May 4 21:45:55 2011 @@ -16,6 +16,12 @@ NTSTATUS QueryStatusChangeEndpoint( IN PDEVICE_OBJECT DeviceObject); + +NTSTATUS +CreateUsbChildDeviceObject( + IN PDEVICE_OBJECT UsbHubDeviceObject, + IN LONG PortId, + OUT PDEVICE_OBJECT *UsbChildDeviceObject); NTSTATUS SubmitRequestToRootHub( @@ -69,14 +75,12 @@ if (Status == STATUS_PENDING) { - DPRINT1("USBHUB: Operation pending\n"); KeWaitForSingleObject(&Event, Suspended, KernelMode, FALSE, NULL); Status = IoStatus.Status; } return Status; } - NTSTATUS GetPortStatusAndChange( @@ -244,19 +248,17 @@ PHUB_DEVICE_EXTENSION HubDeviceExtension; PWORK_ITEM_DATA WorkItemData; PORT_STATUS_CHANGE PortStatus; - LONG PortId, i; + LONG PortId; WorkItemData = (PWORK_ITEM_DATA)Context; DeviceObject = (PDEVICE_OBJECT)WorkItemData->Context; HubDeviceExtension = (PHUB_DEVICE_EXTENSION)DeviceObject->DeviceExtension; // - // Itterate all ports + // Loop all ports // for (PortId = 1; PortId <= HubDeviceExtension->UsbExtHubInfo.NumberOfPorts; PortId++) { - PortStatus.Change = 0; - PortStatus.Status = 0; // // Get Port Status // @@ -268,10 +270,13 @@ return; } + DPRINT1("Port %d Status %x\n", PortId, PortStatus.Status); + DPRINT1("Port %d Change %x\n", PortId, PortStatus.Change); + // // Check for new device connection // - if (PortStatus.Change == USB_PORT_STATUS_CONNECT) + if ((PortStatus.Change == USB_PORT_STATUS_CONNECT) && (PortStatus.Status & USB_PORT_STATUS_CONNECT)) { // // Clear Connection Status @@ -280,41 +285,64 @@ if (!NT_SUCCESS(Status)) { DPRINT1("Failed to clear connection change for port %d\n", PortId); - // FIXME: Do we really want to halt further SCE requests? - return; - } - - // - // Get Port Status and ensure it updated - // - Status = GetPortStatusAndChange(HubDeviceExtension->RootHubPhysicalDeviceObject, PortId, &PortStatus); + } + + // No SCE completion done for clearing C_PORT_CONNECT + + // + // Reset Port + // + Status = SetPortFeature(HubDeviceExtension->RootHubPhysicalDeviceObject, PortId, PORT_RESET); if (!NT_SUCCESS(Status)) { - DPRINT1("Failed to get port status for port %d, Status %x\n", PortId, Status); - // FIXME: Do we really want to halt further SCE requests? - return; - } - - if (PortStatus.Change != 0) - { - DPRINT1("Port %d did not clear Connection Change!\n"); - // FIXME: Do we really want to halt further SCE requests? - return; - } - - // - // FIXME: Create the device object and enable the port - // - //CreateUsbChildDeviceObject - } - } + DPRINT1("Failed to reset port %d\n", PortId); + } + } + else if ((PortStatus.Change == USB_PORT_STATUS_ENABLE) && + (PortStatus.Status & (USB_PORT_STATUS_CONNECT | USB_PORT_STATUS_ENABLE))) + { + // + // Clear Enable + // + Status = ClearPortFeature(HubDeviceExtension->RootHubPhysicalDeviceObject, PortId, C_PORT_ENABLE); + if (!NT_SUCCESS(Status)) + { + DPRINT1("Failed to clear enable change on port %d\n", PortId); + } + } + else if ((PortStatus.Change == USB_PORT_STATUS_RESET) && + (PortStatus.Status & (USB_PORT_STATUS_CONNECT | USB_PORT_STATUS_ENABLE))) + { + // + // Clear Reset + // + Status = ClearPortFeature(HubDeviceExtension->RootHubPhysicalDeviceObject, PortId, C_PORT_RESET); + if (!NT_SUCCESS(Status)) + { + DPRINT1("Failed to clear reset change on port %d\n", PortId); + } + + // FIXME: Double Check Port Status + + // + // Create the device object only if the port manipulation was started by a device connect + // + if (HubDeviceExtension->PortStatusChange[PortId-1].Status) + { + HubDeviceExtension->PortStatusChange[PortId-1].Status = 0; + Status = CreateUsbChildDeviceObject(DeviceObject, PortId, NULL); + } + } + } + + ExFreePool(WorkItemData); // // Send another SCE Request // QueryStatusChangeEndpoint(DeviceObject); - ExFreePool(WorkItemData); + } NTSTATUS @@ -326,22 +354,12 @@ PDEVICE_OBJECT RealDeviceObject; PHUB_DEVICE_EXTENSION HubDeviceExtension; PWORK_ITEM_DATA WorkItemData; - LONG i; RealDeviceObject = (PDEVICE_OBJECT)Context; HubDeviceExtension = (PHUB_DEVICE_EXTENSION)RealDeviceObject->DeviceExtension; // - // Determine which port has changed - // - for (i=0; i < HubDeviceExtension->UsbExtHubInfo.NumberOfPorts; i++) - { - DPRINT1("Port %x HubDeviceExtension->PortStatus %x\n",i+1, HubDeviceExtension->PortStatusChange[i].Status); - DPRINT1("Port %x HubDeviceExtension->PortChange %x\n",i+1, HubDeviceExtension->PortStatusChange[i].Change); - } - - // - // Free the Irp and return more processing required so the IO Manger doesnât try to free it + // Free the Irp // IoFreeIrp(Irp); @@ -354,7 +372,6 @@ DPRINT1("Failed to allocate memory!n"); return STATUS_INSUFFICIENT_RESOURCES; } - WorkItemData->Context = RealDeviceObject; ExInitializeWorkItem(&WorkItemData->WorkItem, (PWORKER_THREAD_ROUTINE)DeviceStatusChangeThread, (PVOID)WorkItemData); @@ -363,6 +380,9 @@ // ExQueueWorkItem(&WorkItemData->WorkItem, DelayedWorkQueue); + // + // Return more processing required so the IO Manger doesnât try to mess with IRP just freed + // return STATUS_MORE_PROCESSING_REQUIRED; } @@ -540,15 +560,15 @@ NULL); // - // Lock the Mdl + // Update Physical Pages // _SEH2_TRY { - MmProbeAndLockPages(BufferMdl, KernelMode, IoWriteAccess); + MmBuildMdlForNonPagedPool(BufferMdl); } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { - DPRINT1("MmProbeAndLockPages Failed!\n"); + DPRINT1("MmBuildMdlForNonPagedPool Failed!\n"); Status = _SEH2_GetExceptionCode(); } _SEH2_END; @@ -569,7 +589,7 @@ // // Set the device handle // - Urb->UrbHeader.UsbdDeviceHandle = (PVOID)ChildDeviceObject; + Urb->UrbHeader.UsbdDeviceHandle = (PVOID)ChildDeviceExtension->UsbDeviceHandle; // // Query the Root Hub @@ -585,6 +605,95 @@ IoFreeMdl(BufferMdl); return Status; +} + +NTSTATUS +GetUsbStringDescriptor( + IN PDEVICE_OBJECT ChildDeviceObject, + IN UCHAR Index, + IN USHORT LangId, + OUT PVOID *TransferBuffer) +{ + NTSTATUS Status; + PUSB_STRING_DESCRIPTOR StringDesc = NULL; + ULONG SizeNeeded; + + StringDesc = ExAllocatePoolWithTag(NonPagedPool, + sizeof(USB_STRING_DESCRIPTOR), + USB_HUB_TAG); + if (!StringDesc) + { + DPRINT1("Failed to allocate buffer for string!\n"); + return STATUS_INSUFFICIENT_RESOURCES; + } + + // + // Get the index string descriptor length + // + Status = GetUsbDeviceDescriptor(ChildDeviceObject, + USB_STRING_DESCRIPTOR_TYPE, + Index, + 0, + StringDesc, + sizeof(USB_STRING_DESCRIPTOR)); + SizeNeeded = StringDesc->bLength; + + // + // Free String + // + ExFreePool(StringDesc); + + // + // Recreate with appropriate size + // + StringDesc = ExAllocatePoolWithTag(NonPagedPool, + SizeNeeded + sizeof(USB_STRING_DESCRIPTOR), + USB_HUB_TAG); + if (!StringDesc) + { + DPRINT1("Failed to allocate buffer for string!\n"); + return STATUS_INSUFFICIENT_RESOURCES; + } + + // + // Get the string + // + Status = GetUsbDeviceDescriptor(ChildDeviceObject, + USB_STRING_DESCRIPTOR_TYPE, + Index, + 0, + StringDesc, + SizeNeeded + sizeof(USB_STRING_DESCRIPTOR)); + if (!NT_SUCCESS(Status)) + { + DPRINT1("Failed to get string from device\n"); + ExFreePool(StringDesc); + return Status; + } + + // + // Allocate Buffer and Save it + // + *TransferBuffer = ExAllocatePoolWithTag(NonPagedPool, + SizeNeeded, + USB_HUB_TAG); + if (!*TransferBuffer) + { + DPRINT1("Failed to allocate buffer for string!\n"); + ExFreePool(StringDesc); + return STATUS_INSUFFICIENT_RESOURCES; + } + + RtlZeroMemory(*TransferBuffer, SizeNeeded); + + // + // Copy the string to destination + // + RtlCopyMemory(*TransferBuffer, StringDesc->bString, SizeNeeded); + + ExFreePool(StringDesc); + + return STATUS_SUCCESS; } NTSTATUS @@ -593,10 +702,196 @@ IN LONG PortId, OUT PDEVICE_OBJECT *UsbChildDeviceObject) { - //NTSTATUS Status; - //PHUB_CHILDDEVICE_EXTENSION UsbChildExtension; - + NTSTATUS Status; + PDEVICE_OBJECT RootHubDeviceObject, NewChildDeviceObject; + PHUB_DEVICE_EXTENSION HubDeviceExtension; + PHUB_CHILDDEVICE_EXTENSION UsbChildExtension; + PUSB_BUS_INTERFACE_HUB_V5 HubInterface; + ULONG ChildDeviceCount; + WCHAR CharDeviceName[64]; + ULONG UsbDeviceNumber = 0; + UNICODE_STRING DeviceName; + USB_DEVICE_DESCRIPTOR DeviceDesc; + USB_CONFIGURATION_DESCRIPTOR ConfigDesc; + ULONG DeviceDescSize, ConfigDescSize; + + HubDeviceExtension = (PHUB_DEVICE_EXTENSION) UsbHubDeviceObject->DeviceExtension; + HubInterface = &HubDeviceExtension->HubInterface; + RootHubDeviceObject = HubDeviceExtension->RootHubPhysicalDeviceObject; + + // + // Find an empty slot in the child device array + // + for (ChildDeviceCount = 0; ChildDeviceCount < USB_MAXCHILDREN; ChildDeviceCount++) + { + if (HubDeviceExtension->ChildDeviceObject[ChildDeviceCount] == NULL) + { + break; + } + } + + // + // Check if the limit has been reached for maximum usb devices + // + if (ChildDeviceCount == USB_MAXCHILDREN) + { + DPRINT1("Too many child devices!\n"); + return STATUS_UNSUCCESSFUL; + } + + while (TRUE) + { + // + // Create a Device Name + // + swprintf(CharDeviceName, L"\\Device\\USBPDO-%d", UsbDeviceNumber); + + // + // Initialize UnicodeString + // + RtlInitUnicodeString(&DeviceName, CharDeviceName); + + // + // Create a DeviceObject + // + + Status = IoCreateDevice(UsbHubDeviceObject->DriverObject, + sizeof(HUB_CHILDDEVICE_EXTENSION), + NULL, + FILE_DEVICE_CONTROLLER, + FILE_AUTOGENERATED_DEVICE_NAME, + FALSE, + &NewChildDeviceObject); + + // + // Check if the name is already in use + // + if ((Status == STATUS_OBJECT_NAME_EXISTS) || (Status == STATUS_OBJECT_NAME_COLLISION)) + { + // + // Try next name + // + UsbDeviceNumber++; + continue; + } + + // + // Check for other errors + // + if (!NT_SUCCESS(Status)) + { + DPRINT1("IoCreateDevice failed with status %x\n", Status); + return Status; + } + + DPRINT1("USBHUB: Created Device %x\n", NewChildDeviceObject); + break; + } + + NewChildDeviceObject->Flags |= DO_BUS_ENUMERATED_DEVICE; + + // + // Assign the device extensions + // + UsbChildExtension = (PHUB_CHILDDEVICE_EXTENSION)NewChildDeviceObject->DeviceExtension; + RtlZeroMemory(UsbChildExtension, sizeof(HUB_CHILDDEVICE_EXTENSION)); + UsbChildExtension->ParentDeviceObject = UsbHubDeviceObject; + + // + // Create the UsbDeviceObject + // + Status = HubInterface->CreateUsbDevice(RootHubDeviceObject, + (PVOID)&UsbChildExtension->UsbDeviceHandle, + HubDeviceExtension->RootHubHandle, + 0x503, //hack + PortId); + if (!NT_SUCCESS(Status)) + { + DPRINT1("CreateUsbDevice failed with status %x\n", Status); + goto Cleanup; + } + + // + // Initialize UsbDevice + // + Status = HubInterface->InitializeUsbDevice(RootHubDeviceObject, UsbChildExtension->UsbDeviceHandle); + if (!NT_SUCCESS(Status)) + { + DPRINT1("InitializeUsbDevice failed with status %x\n", Status); + goto Cleanup; + } + + DeviceDescSize = sizeof(USB_DEVICE_DESCRIPTOR); + ConfigDescSize = sizeof(USB_CONFIGURATION_DESCRIPTOR); + + // + // Get the descriptors + // + Status = HubInterface->GetUsbDescriptors(RootHubDeviceObject, + UsbChildExtension->UsbDeviceHandle, + (PUCHAR)&DeviceDesc, + &DeviceDescSize, + (PUCHAR)&ConfigDesc, + &ConfigDescSize); + if (!NT_SUCCESS(Status)) + { + DPRINT1("GetUsbDescriptors failed with status %x\n", Status); + goto Cleanup; + } + + // + // Allocate memory for DeviceId + // + UsbChildExtension->DeviceId = ExAllocatePoolWithTag(NonPagedPool, 32 * sizeof(WCHAR), USB_HUB_TAG); + + // + // Construct DeviceId from vendor and product values + // + swprintf(UsbChildExtension->DeviceId, L"USB\\Vid_%04x&Pid_%04x", DeviceDesc.idVendor, DeviceDesc.idProduct); + + DPRINT1("Usb Device Id %S\n", UsbChildExtension->DeviceId); + + // + // FIXME: Handle Lang ids, will use default for now + // + + // + // Get the product string + // + Status = GetUsbStringDescriptor(NewChildDeviceObject, + DeviceDesc.iProduct, + 0, + (PVOID*)&UsbChildExtension->TextDescription); + if (!NT_SUCCESS(Status)) + { + DPRINT1("GetUsbStringDescriptor failed with status %x\n", Status); + goto Cleanup; + } + + DPRINT1("Usb TextDescription %S\n", UsbChildExtension->TextDescription); + + Status = GetUsbStringDescriptor(NewChildDeviceObject, + DeviceDesc.iSerialNumber, + 0, + (PVOID*)&UsbChildExtension->InstanceId); + + DPRINT1("Usb InstanceId %S\n", UsbChildExtension->InstanceId); + if (!NT_SUCCESS(Status)) + { + DPRINT1("GetUsbStringDescriptor failed with status %x\n", Status); + goto Cleanup; + } + + HubDeviceExtension->ChildDeviceObject[ChildDeviceCount] = NewChildDeviceObject; + + IoInvalidateDeviceRelations(RootHubDeviceObject, BusRelations); return STATUS_SUCCESS; + +Cleanup: + + IoDeleteDevice(NewChildDeviceObject); + return Status; + } NTSTATUS @@ -648,17 +943,13 @@ if (HubDeviceExtension->ChildDeviceObject[i]) { ObReferenceObject(HubDeviceExtension->ChildDeviceObject[i]); + HubDeviceExtension->ChildDeviceObject[i]->Flags &= ~DO_DEVICE_INITIALIZING; DeviceRelations->Objects[Children++] = HubDeviceExtension->ChildDeviceObject[i]; } } ASSERT(Children == DeviceRelations->Count); *pDeviceRelations = DeviceRelations; - - // - // Send the first SCE Request - // - QueryStatusChangeEndpoint(DeviceObject); return STATUS_SUCCESS; } @@ -942,6 +1233,11 @@ DPRINT1("Failed to power on port %d\n", PortId); } + // + // Send the first SCE Request + // + QueryStatusChangeEndpoint(DeviceObject); + ExFreePool(Urb); break; } Modified: branches/usb-bringup/drivers/usb/usbhub_new/pdo.c URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/usb/usbhub_…
============================================================================== --- branches/usb-bringup/drivers/usb/usbhub_new/pdo.c [iso-8859-1] (original) +++ branches/usb-bringup/drivers/usb/usbhub_new/pdo.c [iso-8859-1] Wed May 4 21:45:55 2011 @@ -23,7 +23,7 @@ ULONG_PTR Information = 0; NTSTATUS Status; - DPRINT1("UsbhubInternalDeviceControlPdo() called\n"); + DPRINT1("UsbhubInternalDeviceControlPdo(%x) called\n", DeviceObject); Stack = IoGetCurrentIrpStackLocation(Irp); Status = Irp->IoStatus.Status; @@ -74,7 +74,7 @@ { PHUB_DEVICE_EXTENSION DeviceExtension; NTSTATUS Status = STATUS_UNSUCCESSFUL; - DPRINT1("USBHUB_PdoStartDevice\n"); + DPRINT1("USBHUB_PdoStartDevice %x\n", DeviceObject); DeviceExtension = (PHUB_DEVICE_EXTENSION)DeviceObject->DeviceExtension; UNIMPLEMENTED @@ -107,12 +107,14 @@ { DPRINT1("IRP_MJ_PNP / IRP_MN_QUERY_ID / BusQueryHardwareIDs\n"); SourceString = ChildDeviceExtension->HardwareIds; + Status = STATUS_NOT_SUPPORTED; break; } case BusQueryCompatibleIDs: { DPRINT1("IRP_MJ_PNP / IRP_MN_QUERY_ID / BusQueryCompatibleIDs\n"); SourceString = ChildDeviceExtension->CompatibleIds; + Status = STATUS_NOT_SUPPORTED; break; } case BusQueryInstanceID: Modified: branches/usb-bringup/drivers/usb/usbhub_new/usbhub.h URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/usb/usbhub_…
============================================================================== --- branches/usb-bringup/drivers/usb/usbhub_new/usbhub.h [iso-8859-1] (original) +++ branches/usb-bringup/drivers/usb/usbhub_new/usbhub.h [iso-8859-1] Wed May 4 21:45:55 2011 @@ -5,6 +5,7 @@ #include <usbbusif.h> #include <usbioctl.h> #include <usb.h> +#include <stdio.h> #include <usbdlib.h> #include <debug.h> //BROKEN: #include <usbprotocoldefs.h> @@ -52,6 +53,7 @@ { COMMON_DEVICE_EXTENSION Common; PDEVICE_OBJECT ParentDeviceObject; + PUSB_DEVICE_HANDLE UsbDeviceHandle; PWCHAR DeviceId; PWCHAR InstanceId; PWCHAR HardwareIds;
13 years, 6 months
1
0
0
0
[janderwald] 51580: [USBSTOR] - Rewrite hardware id / instance id matching - Implement support for compatible id - UsbStor still not attached to disk.sys, needs more research on how to get this done
by janderwald@svn.reactos.org
Author: janderwald Date: Wed May 4 20:19:33 2011 New Revision: 51580 URL:
http://svn.reactos.org/svn/reactos?rev=51580&view=rev
Log: [USBSTOR] - Rewrite hardware id / instance id matching - Implement support for compatible id - UsbStor still not attached to disk.sys, needs more research on how to get this done Modified: branches/usb-bringup/drivers/usb/usbstor/pdo.c branches/usb-bringup/drivers/usb/usbstor/usbstor.c Modified: branches/usb-bringup/drivers/usb/usbstor/pdo.c URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/usb/usbstor…
============================================================================== --- branches/usb-bringup/drivers/usb/usbstor/pdo.c [iso-8859-1] (original) +++ branches/usb-bringup/drivers/usb/usbstor/pdo.c [iso-8859-1] Wed May 4 20:19:33 2011 @@ -160,14 +160,100 @@ for(Index = 0; Index < MaxLength; Index++) { - if (Name[Index] == '\0') - return Index; - - Buffer[Index] = Name[Index]; + if (Name[Index] <= ' ' || Name[Index] >= 0x7F /* last printable ascii character */ || Name[Index] == ',') + { + // + // convert to underscore + // + Buffer[Index] = '_'; + } + else + { + // + // just copy character + // + Buffer[Index] = Name[Index]; + } } return MaxLength; } + +NTSTATUS +USBSTOR_PdoHandleQueryDeviceText( + IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp) +{ + //PPDO_DEVICE_EXTENSION DeviceExtension; + PIO_STACK_LOCATION IoStack; + LPWSTR Buffer; + static WCHAR DeviceText[] = L"USB Mass Storage Device"; + + // + // get current stack location + // + IoStack = IoGetCurrentIrpStackLocation(Irp); + + if (IoStack->Parameters.QueryDeviceText.DeviceTextType == DeviceTextDescription) + { + DPRINT1("USBSTOR_PdoHandleQueryDeviceText DeviceTextDescription\n"); + + // + // allocate item + // + Buffer = (LPWSTR)AllocateItem(PagedPool, sizeof(DeviceText)); + if (!Buffer) + { + // + // no memory + // + Irp->IoStatus.Information = 0; + return STATUS_INSUFFICIENT_RESOURCES; + } + + // + // copy buffer + // + wcscpy(Buffer, DeviceText); + + // + // save result + // + Irp->IoStatus.Information = (ULONG_PTR)Buffer; + return STATUS_SUCCESS; + } + else + { + DPRINT1("USBSTOR_PdoHandleQueryDeviceText DeviceTextLocationInformation\n"); + + // + // allocate item + // + Buffer = (LPWSTR)AllocateItem(PagedPool, sizeof(DeviceText)); + if (!Buffer) + { + // + // no memory + // + Irp->IoStatus.Information = 0; + return STATUS_INSUFFICIENT_RESOURCES; + } + + // + // copy buffer + // + wcscpy(Buffer, DeviceText); + + // + // save result + // + Irp->IoStatus.Information = (ULONG_PTR)Buffer; + return STATUS_SUCCESS; + } + +} + + NTSTATUS @@ -179,7 +265,7 @@ NTSTATUS Status; UCHAR Buffer[100]; LPCSTR DeviceType; - ULONG Offset = 0, Index; + ULONG Offset = 0; PUFI_INQUIRY_RESPONSE InquiryData; ANSI_STRING AnsiString; UNICODE_STRING DeviceId; @@ -214,7 +300,7 @@ // // lets create device string // - Offset = sprintf(&Buffer[Offset], "USBSTOR\\%s&Ven_", DeviceType); + Offset = sprintf(&Buffer[Offset], "USBSTOR\\") + 1; // // copy vendor id @@ -222,43 +308,14 @@ Offset += CopyField(InquiryData->Vendor, &Buffer[Offset], 8); // - // copy product string - // - Offset += sprintf(&Buffer[Offset], "&Prod_"); - - // // copy product identifier // Offset += CopyField(InquiryData->Product, &Buffer[Offset], 16); // - // copy revision string - // - Offset += sprintf(&Buffer[Offset], "&Rev_"); - - // // copy revision identifer // Offset += CopyField(InquiryData->Revision, &Buffer[Offset], 4); - - // - // FIXME: device serial number - // - Offset +=sprintf(&Buffer[Offset], "\\00000000&%d", DeviceExtension->LUN); - - // - // now convert restricted characters to underscores - // - for(Index = 0; Index < Offset; Index++) - { - if (Buffer[Index] <= ' ' || Buffer[Index] >= 0x7F /* last printable ascii character */ || Buffer[Index] == ',') - { - // - // convert to underscore - // - Buffer[Index] = '_'; - } - } // // now initialize ansi string @@ -302,6 +359,46 @@ return Status; } +VOID +USBSTOR_ConvertToUnicodeString( + IN CHAR * Buffer, + IN ULONG ResultBufferLength, + IN ULONG ResultBufferOffset, + OUT LPWSTR ResultBuffer, + OUT PULONG NewResultBufferOffset) +{ + UNICODE_STRING DeviceString; + ANSI_STRING AnsiString; + NTSTATUS Status; + + ASSERT(ResultBufferLength); + ASSERT(ResultBufferLength > ResultBufferOffset); + + DPRINT1("ResultBufferOffset %lu ResultBufferLength %lu Buffer %s Length %lu\n", ResultBufferOffset, ResultBufferLength, Buffer, strlen(Buffer)); + + DeviceString.Buffer = &ResultBuffer[ResultBufferOffset]; + DeviceString.Length = 0; + DeviceString.MaximumLength = (ResultBufferLength - ResultBufferOffset) * sizeof(WCHAR); + + RtlInitAnsiString(&AnsiString, Buffer); + + Status = RtlAnsiStringToUnicodeString(&DeviceString, &AnsiString, FALSE); + ASSERT(Status == STATUS_SUCCESS); + + // + // subtract consumed bytes + // + ResultBufferLength -= (DeviceString.Length + sizeof(WCHAR)) / sizeof(WCHAR); + ResultBufferOffset += (DeviceString.Length + sizeof(WCHAR)) / sizeof(WCHAR); + + // + // store new offset + // + *NewResultBufferOffset = ResultBufferOffset; +} + + + NTSTATUS USBSTOR_PdoHandleQueryHardwareId( IN PDEVICE_OBJECT DeviceObject, @@ -309,12 +406,14 @@ { PPDO_DEVICE_EXTENSION PDODeviceExtension; PFDO_DEVICE_EXTENSION FDODeviceExtension; - WCHAR Buffer[200]; - ULONG Length; - LPWSTR DeviceName; LPCWSTR GenericType; - - DPRINT1("USBSTOR_PdoHandleQueryInstanceId\n"); + LPWSTR Buffer; + CHAR Id1[50], Id2[50], Id3[50], Id4[50], Id5[50], Id6[50]; + ULONG Id1Length, Id2Length, Id3Length, Id4Length, Id5Length,Id6Length; + ULONG Offset, TotalLength, Length; + PUFI_INQUIRY_RESPONSE InquiryData; + + DPRINT1("USBSTOR_PdoHandleQueryHardwareId\n"); // // get PDO device extension @@ -332,39 +431,101 @@ ASSERT(FDODeviceExtension->DeviceDescriptor); // + // get inquiry data + // + InquiryData = (PUFI_INQUIRY_RESPONSE)PDODeviceExtension->InquiryData; + + + // // get generic type // - GenericType = USBSTOR_GetGenericType((PUFI_INQUIRY_RESPONSE)PDODeviceExtension->InquiryData); + GenericType = USBSTOR_GetGenericType(InquiryData); ASSERT(GenericType); // - // zero buffer - // - RtlZeroMemory(Buffer, sizeof(Buffer)); - - // - // format hardware id - // - Length = swprintf(Buffer, L"USB\\VID_%04x&Pid_%04x&Rev_%04x", FDODeviceExtension->DeviceDescriptor->idVendor, FDODeviceExtension->DeviceDescriptor->idProduct, FDODeviceExtension->DeviceDescriptor->bcdDevice) + 1; - Length += swprintf(&Buffer[Length], L"USB\\VID_%04x&Pid_%04x", FDODeviceExtension->DeviceDescriptor->idVendor, FDODeviceExtension->DeviceDescriptor->idProduct) + 1; - Length += swprintf(&Buffer[Length], L"USBSTOR\\%s", GenericType) + 1; - Length += swprintf(&Buffer[Length], L"%s", GenericType) + 1; - - // - // TODO: add more ids - // - - Buffer[Length] = UNICODE_NULL; - Length++; - - DPRINT1("Name %S\n", Buffer); + // generate id 1 + // USBSTOR\SCSIType_Vendor(8)_Product(16)_Revision(4) + // + RtlZeroMemory(Id1, sizeof(Id1)); + Offset = 0; + Offset = sprintf(&Id1[Offset], "USBSTOR\\"); + Offset += sprintf(&Id1[Offset], "Disk"); //FIXME + Offset += CopyField(InquiryData->Vendor, &Id1[Offset], 8); + Offset += CopyField(InquiryData->Product, &Id1[Offset], 16); + Offset += CopyField(InquiryData->Revision, &Id1[Offset], 4); + Id1Length = strlen(Id1) + 1; + DPRINT1("HardwareId1 %s\n", Id1); + + // + // generate id 2 + // USBSTOR\SCSIType_VENDOR(8)_Product(16) + // + RtlZeroMemory(Id2, sizeof(Id2)); + Offset = 0; + Offset = sprintf(&Id2[Offset], "USBSTOR\\"); + Offset += sprintf(&Id2[Offset], "Disk"); //FIXME + Offset += CopyField(InquiryData->Vendor, &Id2[Offset], 8); + Offset += CopyField(InquiryData->Product, &Id2[Offset], 16); + Id2Length = strlen(Id2) + 1; + DPRINT1("HardwareId2 %s\n", Id2); + + // + // generate id 3 + // USBSTOR\SCSIType_VENDOR(8) + // + RtlZeroMemory(Id3, sizeof(Id3)); + Offset = 0; + Offset = sprintf(&Id3[Offset], "USBSTOR\\"); + Offset += sprintf(&Id3[Offset], "Disk"); //FIXME + Offset += CopyField(InquiryData->Vendor, &Id3[Offset], 8); + Id3Length = strlen(Id3) + 1; + DPRINT1("HardwareId3 %s\n", Id3); + + // + // generate id 4 + // USBSTOR\SCSIType_VENDOR(8)_Product(16)_Revision(1) + // + RtlZeroMemory(Id4, sizeof(Id4)); + Offset = 0; + Offset = sprintf(&Id4[Offset], "USBSTOR\\"); + Offset += sprintf(&Id4[Offset], "Disk"); //FIXME + Offset += CopyField(InquiryData->Vendor, &Id4[Offset], 8); + Offset += CopyField(InquiryData->Product, &Id4[Offset], 16); + Offset += CopyField(InquiryData->Revision, &Id4[Offset], 1); + Id4Length = strlen(Id4) + 1; + DPRINT1("HardwareId4 %s\n", Id4); + + // + // generate id 5 + // USBSTOR\SCSIType + // + RtlZeroMemory(Id5, sizeof(Id5)); + Offset = 0; + Offset = sprintf(&Id5[Offset], "USBSTOR\\"); + Offset += sprintf(&Id5[Offset], "GenDisk"); //FIXME + Id5Length = strlen(Id5) + 1; + DPRINT1("HardwareId5 %s\n", Id5); + + // + // generate id 6 + // SCSIType + // + RtlZeroMemory(Id6, sizeof(Id6)); + Offset = 0; + Offset = sprintf(&Id6[Offset], "GenDisk"); //FIXME + Id6Length = strlen(Id6) + 1; + DPRINT1("HardwareId6 %s\n", Id6); + + // + // compute total length + // + TotalLength = Id1Length + Id2Length + Id3Length + Id4Length + Id5Length + Id6Length + 1; // // allocate buffer // - DeviceName = (LPWSTR)AllocateItem(PagedPool, Length * sizeof(WCHAR)); - - if (!DeviceName) + Buffer = (LPWSTR)AllocateItem(PagedPool, TotalLength * sizeof(WCHAR)); + if (!Buffer) { // // no memory @@ -374,14 +535,24 @@ } // - // copy device name - // - RtlMoveMemory(DeviceName, Buffer, Length * sizeof(WCHAR)); + // reset offset + // + Offset = 0; + Length = TotalLength; + + USBSTOR_ConvertToUnicodeString(Id1, Length, Offset, Buffer, &Offset); + USBSTOR_ConvertToUnicodeString(Id2, Length, Offset, Buffer, &Offset); + USBSTOR_ConvertToUnicodeString(Id3, Length, Offset, Buffer, &Offset); + USBSTOR_ConvertToUnicodeString(Id4, Length, Offset, Buffer, &Offset); + USBSTOR_ConvertToUnicodeString(Id5, Length, Offset, Buffer, &Offset); + USBSTOR_ConvertToUnicodeString(Id6, Length, Offset, Buffer, &Offset); + + DPRINT1("Offset %lu Length %lu\n", Offset, Length); // // store result // - Irp->IoStatus.Information = (ULONG_PTR)DeviceName; + Irp->IoStatus.Information = (ULONG_PTR)Buffer; // // done @@ -390,7 +561,7 @@ } NTSTATUS -USBSTOR_PdoHandleQueryInstanceId( +USBSTOR_PdoHandleQueryCompatibleId( IN PDEVICE_OBJECT DeviceObject, IN OUT PIRP Irp) { @@ -399,6 +570,96 @@ WCHAR Buffer[100]; ULONG Length; LPWSTR InstanceId; + LPCSTR DeviceType; + + DPRINT1("USBSTOR_PdoHandleQueryCompatibleId\n"); + + // + // get PDO device extension + // + PDODeviceExtension = (PPDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension; + + // + // get FDO device extension + // + FDODeviceExtension = (PFDO_DEVICE_EXTENSION)PDODeviceExtension->LowerDeviceObject->DeviceExtension; + + // + // sanity check + // + ASSERT(FDODeviceExtension->DeviceDescriptor); + + // + // get target device type + // + DeviceType = USBSTOR_GetDeviceType((PUFI_INQUIRY_RESPONSE)PDODeviceExtension->InquiryData); + + // + // zero memory + // + RtlZeroMemory(Buffer, sizeof(Buffer)); + + // + // format instance id + // + Length = swprintf(Buffer, L"USBSTOR\\%s", L"Disk") + 1; + Length += swprintf(&Buffer[Length], L"USBSTOR\\%s", L"RAW") + 2; + + // + // verify this + // + // Length += swprintf(&Buffer[Length], L"USBSTOR\\RAW") + 1; + + //Buffer[Length] = UNICODE_NULL; + //Buffer[Length+1] = UNICODE_NULL; + //Length++; + + // + // calculate length + // + + + // + // allocate instance id + // + InstanceId = (LPWSTR)AllocateItem(PagedPool, Length * sizeof(WCHAR)); + if (!InstanceId) + { + // + // no memory + // + Irp->IoStatus.Information = 0; + return STATUS_INSUFFICIENT_RESOURCES; + } + + // + // copy instance id + // + wcscpy(InstanceId, Buffer); + + DPRINT1("USBSTOR_PdoHandleQueryInstanceId %S\n", InstanceId); + + // + // store result + // + Irp->IoStatus.Information = (ULONG_PTR)InstanceId; + + // + // completed successfully + // + return STATUS_SUCCESS; +} + +NTSTATUS +USBSTOR_PdoHandleQueryInstanceId( + IN PDEVICE_OBJECT DeviceObject, + IN OUT PIRP Irp) +{ + PPDO_DEVICE_EXTENSION PDODeviceExtension; + PFDO_DEVICE_EXTENSION FDODeviceExtension; + WCHAR Buffer[100]; + ULONG Length; + LPWSTR InstanceId; DPRINT1("USBSTOR_PdoHandleQueryInstanceId\n"); @@ -420,7 +681,7 @@ // // format instance id // - swprintf(Buffer, L"USB\\VID_%04x&PID_%04x\\%s", FDODeviceExtension->DeviceDescriptor->idVendor, FDODeviceExtension->DeviceDescriptor->idProduct, L"00000000"); + swprintf(Buffer, L"USB\\VID_%04x&PID_%04x\\%s", FDODeviceExtension->DeviceDescriptor->idVendor, FDODeviceExtension->DeviceDescriptor->idProduct, L"09188212515A"); // // calculate length @@ -548,9 +809,10 @@ break; } case IRP_MN_QUERY_DEVICE_TEXT: - DPRINT1("USBSTOR_PdoHandlePnp: IRP_MN_QUERY_DEVICE_TEXT unimplemented\n"); - Status = STATUS_NOT_SUPPORTED; + { + Status = USBSTOR_PdoHandleQueryDeviceText(DeviceObject, Irp); break; + } case IRP_MN_QUERY_ID: { if (IoStack->Parameters.QueryId.IdType == BusQueryDeviceID) @@ -577,6 +839,14 @@ Status = USBSTOR_PdoHandleQueryInstanceId(DeviceObject, Irp); break; } + else if (IoStack->Parameters.QueryId.IdType == BusQueryCompatibleIDs) + { + // + // handle instance id + // + Status = USBSTOR_PdoHandleQueryCompatibleId(DeviceObject, Irp); + break; + } DPRINT1("USBSTOR_PdoHandlePnp: IRP_MN_QUERY_ID IdType %x unimplemented\n", IoStack->Parameters.QueryId.IdType); Status = STATUS_NOT_SUPPORTED; @@ -593,6 +863,7 @@ // just forward irp to lower device // Status = USBSTOR_SyncForwardIrp(DeviceExtension->LowerDeviceObject, Irp); + ASSERT(Status == STATUS_SUCCESS); if (NT_SUCCESS(Status)) { @@ -600,7 +871,7 @@ // check if no unique id // Caps = (PDEVICE_CAPABILITIES)IoStack->Parameters.DeviceCapabilities.Capabilities; - Caps->UniqueID = FALSE; //FIXME + Caps->UniqueID = TRUE; //FIXME Caps->Removable = TRUE; //FIXME } break; @@ -656,7 +927,7 @@ // // create child device object // - Status = IoCreateDevice(DeviceObject->DriverObject, sizeof(PDO_DEVICE_EXTENSION), NULL, FILE_DEVICE_MASS_STORAGE, 0, FALSE, &PDO); + Status = IoCreateDevice(DeviceObject->DriverObject, sizeof(PDO_DEVICE_EXTENSION), NULL, FILE_DEVICE_MASS_STORAGE, FILE_AUTOGENERATED_DEVICE_NAME, FALSE, &PDO); if (!NT_SUCCESS(Status)) { // @@ -685,7 +956,7 @@ // // set device flags // - PDO->Flags |= DO_BUFFERED_IO | DO_POWER_PAGABLE; + PDO->Flags |= DO_DIRECT_IO | DO_MAP_IO_BUFFER; // // device is initialized Modified: branches/usb-bringup/drivers/usb/usbstor/usbstor.c URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/usb/usbstor…
============================================================================== --- branches/usb-bringup/drivers/usb/usbstor/usbstor.c [iso-8859-1] (original) +++ branches/usb-bringup/drivers/usb/usbstor/usbstor.c [iso-8859-1] Wed May 4 20:19:33 2011 @@ -29,7 +29,7 @@ // // lets create the device // - Status = IoCreateDevice(DriverObject, sizeof(FDO_DEVICE_EXTENSION), 0, FILE_DEVICE_BUS_EXTENDER, 0, FALSE, &DeviceObject); + Status = IoCreateDevice(DriverObject, sizeof(FDO_DEVICE_EXTENSION), 0, FILE_DEVICE_BUS_EXTENDER, FILE_AUTOGENERATED_DEVICE_NAME | FILE_DEVICE_SECURE_OPEN, FALSE, &DeviceObject); // // check for success @@ -120,6 +120,7 @@ // // function always succeeds ;) // + DPRINT1("USBSTOR_DispatchScsi\n"); Irp->IoStatus.Information = 0; Irp->IoStatus.Status = STATUS_SUCCESS; IoCompleteRequest(Irp, IO_NO_INCREMENT); @@ -133,8 +134,7 @@ PDEVICE_OBJECT DeviceObject, PIRP Irp) { - UNIMPLEMENTED - + DPRINT1("USBSTOR_DispatchDeviceControl\n"); Irp->IoStatus.Information = 0; Irp->IoStatus.Status = STATUS_SUCCESS; IoCompleteRequest(Irp, IO_NO_INCREMENT); @@ -148,7 +148,7 @@ PDEVICE_OBJECT DeviceObject, PIRP Irp) { - UNIMPLEMENTED + DPRINT1("USBSTOR_DispatchScsi\n"); Irp->IoStatus.Information = 0; Irp->IoStatus.Status = STATUS_SUCCESS; @@ -165,6 +165,7 @@ // // read write ioctl is not supported // + DPRINT1("USBSTOR_DispatchReadWrite\n"); Irp->IoStatus.Information = 0; Irp->IoStatus.Status = STATUS_INVALID_PARAMETER; IoCompleteRequest(Irp, IO_NO_INCREMENT);
13 years, 6 months
1
0
0
0
[tkreuzer] 51579: [GDI FONT DRIVER] Commit my first version of the font driver. current status: - It loads OpenType / Type1 files (couldn't test others) - It creates all neccessary structures for l...
by tkreuzer@svn.reactos.org
Author: tkreuzer Date: Wed May 4 19:48:29 2011 New Revision: 51579 URL:
http://svn.reactos.org/svn/reactos?rev=51579&view=rev
Log: [GDI FONT DRIVER] Commit my first version of the font driver. current status: - It loads OpenType / Type1 files (couldn't test others) - It creates all neccessary structures for later management - It creates the glyphset (unicode->glyph handle translation) - it creates an IFIMETRICS structure, based on freetype info and TTF/OTF OS/2 table data, mostly complete Added: branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/opentype.c (with props) branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/todo.txt (with props) Modified: branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/CMakeLists.txt branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/enable.c branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/font.c branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/ftfd.h branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/glyph.c branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/rosglue.c Modified: branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/GdiFontDriver/drivers…
============================================================================== --- branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/CMakeLists.txt [iso-8859-1] (original) +++ branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/CMakeLists.txt [iso-8859-1] Wed May 4 19:48:29 2011 @@ -5,10 +5,11 @@ add_library(ftfd SHARED enable.c + file.c font.c glyph.c + opentype.c rosglue.c - sprintf.c ${CMAKE_CURRENT_BINARY_DIR}/ftfd.def) set_entrypoint(ftfd FtfdEnableDriver@12) Modified: branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/enable.c URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/GdiFontDriver/drivers…
============================================================================== --- branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/enable.c [iso-8859-1] (original) +++ branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/enable.c [iso-8859-1] Wed May 4 19:48:29 2011 @@ -1,7 +1,7 @@ /* * PROJECT: ReactOS win32 subsystem * LICENSE: GPL - See COPYING in the top level directory - * PURPOSE: GDI font driver for bitmap fonts + * PURPOSE: GDI font driver based on freetype * PROGRAMMER: Timo Kreuzer (timo.kreuzer(a)reactos.org) */ @@ -9,22 +9,28 @@ static DRVFN gadrvfn[] = { - {INDEX_DrvEnablePDEV, (PFN)FtfdEnablePDEV}, - {INDEX_DrvCompletePDEV, (PFN)FtfdCompletePDEV}, - {INDEX_DrvDisablePDEV, (PFN)FtfdDisablePDEV}, - {INDEX_DrvLoadFontFile, (PFN)FtfdLoadFontFile}, - {INDEX_DrvUnloadFontFile, (PFN)FtfdUnloadFontFile}, - {INDEX_DrvQueryFontFile, (PFN)FtfdQueryFontFile}, - {INDEX_DrvQueryFontCaps, (PFN)FtfdQueryFontCaps}, - {INDEX_DrvQueryFontTree, (PFN)FtfdQueryFontTree}, - {INDEX_DrvQueryFont, (PFN)FtfdQueryFont}, - {INDEX_DrvFree, (PFN)FtfdFree}, - {INDEX_DrvQueryGlyphAttrs, (PFN)FtfdQueryGlyphAttrs}, - {INDEX_DrvQueryFontData, (PFN)FtfdQueryFontData}, + {INDEX_DrvEnablePDEV, (PFN)FtfdEnablePDEV}, + {INDEX_DrvCompletePDEV, (PFN)FtfdCompletePDEV}, + {INDEX_DrvDisablePDEV, (PFN)FtfdDisablePDEV}, + {INDEX_DrvLoadFontFile, (PFN)FtfdLoadFontFile}, + {INDEX_DrvUnloadFontFile, (PFN)FtfdUnloadFontFile}, + {INDEX_DrvQueryFontFile, (PFN)FtfdQueryFontFile}, + {INDEX_DrvQueryFontCaps, (PFN)FtfdQueryFontCaps}, + {INDEX_DrvQueryFontTree, (PFN)FtfdQueryFontTree}, + {INDEX_DrvQueryFont, (PFN)FtfdQueryFont}, + {INDEX_DrvDestroyFont, (PFN)FtfdDestroyFont}, +// {INDEX_DrvFree, (PFN)FtfdFree}, + {INDEX_DrvQueryGlyphAttrs, (PFN)FtfdQueryGlyphAttrs}, + {INDEX_DrvQueryFontData, (PFN)FtfdQueryFontData}, + {INDEX_DrvQueryAdvanceWidths, (PFN)FtfdQueryAdvanceWidths}, + {INDEX_DrvQueryTrueTypeOutline, (PFN)FtfdQueryTrueTypeOutline}, + {INDEX_DrvQueryTrueTypeTable, (PFN)FtfdQueryTrueTypeTable}, + {INDEX_DrvEscape, (PFN)FtfdEscape}, + {INDEX_DrvFontManagement, (PFN)FtfdFontManagement}, + {INDEX_DrvGetTrueTypeFile, (PFN)FtfdGetTrueTypeFile}, }; FT_Library gftlibrary; - BOOL APIENTRY @@ -33,7 +39,7 @@ ULONG cj, PDRVENABLEDATA pded) { - FT_Error fterror; + FT_Error fterror; DbgPrint("FtfdEnableDriver()\n"); @@ -77,8 +83,6 @@ IN HANDLE hDriver) { DbgPrint("FtfdEnablePDEV(hdev=%p)\n", hdev); - __debugbreak(); - /* Return a dummy DHPDEV */ return (PVOID)1; @@ -104,3 +108,19 @@ DbgPrint("FtfdDisablePDEV()\n"); /* Nothing to do */ } + +ULONG +APIENTRY +FtfdEscape( + SURFOBJ *pso, + ULONG iEsc, + ULONG cjIn, + PVOID pvIn, + ULONG cjOut, + PVOID pvOut) +{ + DbgPrint("FtfdEscape\n"); + __debugbreak(); + return 0; +} + Modified: branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/font.c URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/GdiFontDriver/drivers…
============================================================================== --- branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/font.c [iso-8859-1] (original) +++ branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/font.c [iso-8859-1] Wed May 4 19:48:29 2011 @@ -1,26 +1,438 @@ /* * PROJECT: ReactOS win32 subsystem * LICENSE: GPL - See COPYING in the top level directory - * PURPOSE: GDI font driver for bitmap fonts + * PURPOSE: GDI font driver based on freetype * PROGRAMMER: Timo Kreuzer (timo.kreuzer(a)reactos.org) */ #include "ftfd.h" +FWORD +CalculateAveCharWidth( + FT_Face ftface) +{ + ULONG cGlyphs = 0, ulAccumCharWidth = 0; + WCHAR wc; + FT_UInt index; + FT_Error fterror; + + /* Loop all glyphs from 'a' to 'z' */ + for (wc = L'a'; wc <= L'z'; wc++) + { + /* Load the glyph into the glyph slot */ + fterror = FT_Load_Char(ftface, wc, FT_LOAD_NO_SCALE|FT_LOAD_NO_BITMAP); + if (fterror) goto allglyphs; + + /* Calculate accumulative char width */ + ulAccumCharWidth += ftface->glyph->metrics.width; + cGlyphs++; + } + goto done; + +allglyphs: + DbgPrint("using all glyphs\n"); + + /* Start over */ + ulAccumCharWidth = 0; + cGlyphs = 0; + + /* Loop all glyphs in the font */ + for (index = 0; index <= (UINT)ftface->num_glyphs; index++) + { + /* Load the glyph into the glyph slot */ + fterror = FT_Load_Glyph(ftface, index, FT_LOAD_NO_SCALE|FT_LOAD_NO_BITMAP); + if (fterror) continue; + + /* Calculate accumulative char width */ + ulAccumCharWidth += ftface->glyph->metrics.width; // fIXME: weighted + cGlyphs++; + } + +done: + return (FWORD)(ulAccumCharWidth / cGlyphs); +} + +BOOL +NTAPI +FtfdInitIfiMetrics( + PFTFD_FACE pface) +{ + PFTFD_IFIMETRICS pifiex; + PIFIMETRICS pifi; + FT_Face ftface; + ULONG i; + + DbgPrint("FtfdInitIfiMetrics()\n"); + + /* Get the freetype face pointer */ + ftface = pface->ftface; + + /* Fill IFIMETRICS */ + pifiex = &pface->ifiex; + pifi = &pface->ifiex.ifi; + pifi->cjThis = sizeof(FTFD_IFIMETRICS); + pifi->cjIfiExtra = 0; + + /* Set relative offsets */ + pifi->dpwszFamilyName = FIELD_OFFSET(FTFD_IFIMETRICS, awcFamilyName); + pifi->dpwszStyleName = FIELD_OFFSET(FTFD_IFIMETRICS, awcStyleName); + pifi->dpwszFaceName = FIELD_OFFSET(FTFD_IFIMETRICS, awcFaceName); + pifi->dpwszUniqueName = FIELD_OFFSET(FTFD_IFIMETRICS, awcUniqueName); + pifi->dpCharSets = FIELD_OFFSET(FTFD_IFIMETRICS, ajCharSet); + pifi->dpFontSim = 0; + + /* Charsets */ + pifi->jWinCharSet = ANSI_CHARSET; + pifiex->ajCharSet[0] = pifi->jWinCharSet; + for (i = 1; i < 16; i++) + { + pifiex->ajCharSet[i] = DEFAULT_CHARSET; + } + + pifi->lEmbedId = 0; + pifi->lItalicAngle = 0; + pifi->lCharBias = 0; + pifi->jWinPitchAndFamily = 0; // FIXME: generic way to get this? + + /* Set flags */ + pifi->flInfo = FM_INFO_RETURNS_BITMAPS | FM_INFO_1BPP | FM_INFO_4BPP; + if (pface->ulFontFormat == FMT_TYPE1) + pifi->flInfo |= FM_INFO_TECH_TYPE1; + if (pface->ulFontFormat == FMT_CFF) + pifi->flInfo |= FM_INFO_TECH_TYPE1 | FM_INFO_TECH_CFF; + if (pface->ulFontFormat == FMT_TRUETYPE) + pifi->flInfo |= FM_INFO_TECH_TRUETYPE; + else + pifi->flInfo |= FM_INFO_TECH_OUTLINE_NOT_TRUETYPE; + if (pface->cRuns > 1) + pifi->flInfo |= FM_INFO_NOT_CONTIGUOUS; + if (pface->ulFontFormat != FMT_FNT) + pifi->flInfo |= FM_INFO_RETURNS_OUTLINES | FM_INFO_ARB_XFORMS; + pifi->flInfo |= FM_INFO_RIGHT_HANDED; // FIXME: how to determine? + + /* Font style */ + pifi->fsSelection = FM_SEL_REGULAR; + pifi->usWinWeight = FW_REGULAR; + if (ftface->style_flags & FT_STYLE_FLAG_BOLD) + { + pifi->fsSelection &= ~FM_SEL_REGULAR; + pifi->fsSelection |= FM_SEL_BOLD; + pifi->usWinWeight = FW_BOLD; + } + if (ftface->style_flags & FT_STYLE_FLAG_ITALIC) + { + pifi->fsSelection &= ~FM_SEL_REGULAR; // ??? remove it? + pifi->fsSelection |= FM_SEL_ITALIC; + } + + pifi->fsType = 0; + + /* Font resolution */ + pifi->fwdUnitsPerEm = ftface->units_per_EM; + pifi->fwdLowestPPEm = 3; // FIXME + + /* Font metrics */ + pifi->fwdWinAscender = (ftface->ascender * 213) / 170; + pifi->fwdWinDescender = -(ftface->descender * 213) / 170; + pifi->fwdMacAscender = ftface->ascender; + pifi->fwdMacDescender = ftface->descender; + pifi->fwdMacLineGap = 0; + pifi->fwdAveCharWidth = 0; + pifi->fwdTypoAscender = pifi->fwdMacAscender; + pifi->fwdTypoDescender = pifi->fwdMacDescender; + pifi->fwdTypoLineGap = 0; + pifi->fwdMaxCharInc = ftface->max_advance_width; + pifi->fwdCapHeight = 0; + pifi->fwdXHeight = 0; + pifi->fwdSubscriptXSize = 0; + pifi->fwdSubscriptYSize = 0; + pifi->fwdSubscriptXOffset = 0; + pifi->fwdSubscriptYOffset = 0; + pifi->fwdSuperscriptXSize = 0; + pifi->fwdSuperscriptYSize = 0; + pifi->fwdSuperscriptXOffset = 0; + pifi->fwdSuperscriptYOffset = 0; + pifi->fwdUnderscoreSize = ftface->underline_thickness; + pifi->fwdUnderscorePosition = ftface->underline_position; // FIXME: off by 10 + pifi->fwdStrikeoutSize = pifi->fwdUnitsPerEm / 20; + pifi->fwdStrikeoutPosition = pifi->fwdUnitsPerEm / 4; + + pifi->ptlBaseline.x = 1; // FIXME + pifi->ptlBaseline.y = 0; // FIXME + pifi->ptlAspect.x = 0x3e9; // FIXME + pifi->ptlAspect.y = 0x3e9; // FIXME + pifi->ptlCaret.x = 0; // FIXME + pifi->ptlCaret.y = 1; // FIXME + + /* Set the biggest characters bounding box */ + pifi->rclFontBox.left = ftface->bbox.xMin; + pifi->rclFontBox.right = ftface->bbox.xMax; + pifi->rclFontBox.top = ftface->bbox.yMax; + pifi->rclFontBox.bottom = ftface->bbox.yMin; + + /* Special characters */ + pifi->chFirstChar = 0x00; + pifi->chLastChar = 0xff; + pifi->chDefaultChar = 0x20; + pifi->chBreakChar = 0x20; + //pifi->wcFirstChar = 0; + //pifi->wcLastChar = 0x00ff; + pifi->wcDefaultChar = 0x0020; + pifi->wcBreakChar = 0x0020; + + *(DWORD*)&pifi->achVendId = '0000'; + pifi->cKerningPairs = 0; + pifi->ulPanoseCulture = FM_PANOSE_CULTURE_LATIN; + + pifi->panose.bFamilyType = PAN_FAMILY_TEXT_DISPLAY; + pifi->panose.bSerifStyle = PAN_ANY; + pifi->panose.bWeight = PAN_ANY; + pifi->panose.bProportion = PAN_ANY; + pifi->panose.bContrast = PAN_ANY; + pifi->panose.bStrokeVariation = PAN_ANY; + pifi->panose.bArmStyle = PAN_ANY; + pifi->panose.bLetterform = PAN_ANY; + pifi->panose.bMidline = PAN_ANY; + pifi->panose.bXHeight = PAN_ANY; + + EngMultiByteToUnicodeN(pifiex->awcFamilyName, + LF_FACESIZE, + NULL, + ftface->family_name, + strnlen(ftface->family_name, MAX_PATH)); + + EngMultiByteToUnicodeN(pifiex->awcStyleName, + LF_FACESIZE, + NULL, + ftface->style_name, + strnlen(ftface->style_name, MAX_PATH)); + + EngMultiByteToUnicodeN(pifiex->awcFaceName, + LF_FACESIZE, + NULL, + ftface->family_name, + strnlen(ftface->family_name, MAX_PATH)); + + /* Use OS/2 TrueType or OpenType tables */ + OtfGetIfiMetrics(pface, pifi); + + if (pifi->fwdAveCharWidth == 0) + pifi->fwdAveCharWidth = CalculateAveCharWidth(ftface); + + /* Create a unique name */ + wcscpy(pifiex->awcUniqueName, L"1.000;ABCD;"); + wcsncat(pifiex->awcUniqueName, pifiex->awcFamilyName, LF_FACESIZE); + pifiex->awcUniqueName[0] = L'1'; // + version? + //pifiex->awcUniqueName[2] = L'0'; // + version? + EngMultiByteToUnicodeN(pifiex->awcUniqueName + 6, + 4, + NULL, + pifi->achVendId, + 4); + + DbgPrint("Finished with the ifi: %p\n", pifi); + __debugbreak(); + + return TRUE; +} + PVOID -HackFixup( - PVOID pvView, - ULONG cjView) -{ - CHAR *pc; - - pc = EngAllocMem(0, cjView, 'tmp '); - memcpy(pc, pvView, cjView); - - *pc = 0; - - return pc; -} +APIENTRY +FtfdInitGlyphSet( + PFTFD_FACE pface) +{ + FT_Face ftface = pface->ftface; + FD_GLYPHSET *pGlyphSet; + FT_UInt index; + ULONG i, j, cjSize; + HGLYPH * phglyphs; + WCHAR wcCurrent, wcPrev; + + DbgPrint("FtfdInitGlyphSet()\n"); + + /* Calculate FD_GLYPHSET size */ + cjSize = sizeof(FD_GLYPHSET) + (pface->cRuns - 1) * sizeof(WCRUN); + + /* Allocate the FD_GLYPHSET structure plus an array of HGLYPHs */ + pGlyphSet = EngAllocMem(0, cjSize + pface->cMappings * sizeof(HGLYPH), TAG_GLYPHSET); + if (!pGlyphSet) + { + DbgPrint("EngAllocMem() failed.\n"); + return NULL; + } + + /* Get a pointer to the HGLYPH array */ + phglyphs = (PHGLYPH)&pGlyphSet->awcrun[pface->cRuns]; + + /* Initialize FD_GLYPHSET */ + pGlyphSet->cjThis = cjSize; + pGlyphSet->flAccel = 0; + pGlyphSet->cGlyphsSupported = pface->cMappings; + pGlyphSet->cRuns = pface->cRuns; + + /* Loop through all character mappings */ + wcPrev = wcCurrent = (WCHAR)FT_Get_First_Char(ftface, &index); + for (i = 0, j = 0; i < pface->cMappings && index; i++) + { + /* Use index as glyph handle */ + phglyphs[i] = (HGLYPH)index; + + /* Check whether we can append the wchar to a run */ + if (wcCurrent == wcPrev + 1) + { + /* Append to current WCRUN */ + pGlyphSet->awcrun[j].cGlyphs++; + } + else + { + /* Add a new WCRUN */ + pGlyphSet->awcrun[j].wcLow = wcCurrent; + pGlyphSet->awcrun[j].cGlyphs = 1; + pGlyphSet->awcrun[j].phg = &phglyphs[i]; + j++; + //DbgPrint("adding new run i=%ld, j=%ld, wc=%x\n", i, j, wcCurrent); + } + + /* Get the next charcode and index */ + wcPrev = wcCurrent; + wcCurrent = (WCHAR)FT_Get_Next_Char(ftface, wcCurrent, &index); + } + + DbgPrint("Done with font tree, %d runs\n", pGlyphSet->cRuns); + pface->pGlyphSet = pGlyphSet; + return pGlyphSet; +} + +VOID +FtfdInitKerningPairs( + PFTFD_FACE pface) +{ + //DbgPrint("unimplemented\n"); +} + +static +ULONG +FtfdGetFontFormat(FT_Face ftface) +{ + const char *pstrFormat; + + /* FreeType only provides a string :-/ */ + pstrFormat = FT_Get_X11_Font_Format(ftface); + if (strcmp(pstrFormat, "TrueType") == 0) return FMT_TRUETYPE; + if (strcmp(pstrFormat, "Type 1") == 0) return FMT_TYPE1; + if (strcmp(pstrFormat, "CFF") == 0) return FMT_CFF; + if (strcmp(pstrFormat, "Windows FNT") == 0) return FMT_FNT; + if (strcmp(pstrFormat, "BDF") == 0) return FMT_BDF; + if (strcmp(pstrFormat, "PCF") == 0) return FMT_PCF; + if (strcmp(pstrFormat, "Type 42") == 0) return FMT_TYPE42; + if (strcmp(pstrFormat, "CID Type 1") == 0) return FMT_CIDTYPE1; + if (strcmp(pstrFormat, "PFR") == 0) return FMT_PFR; + return FMT_UNKNOWN; +} + +FtfdGetFileFormat( + PFTFD_FILE pfile) +{ + ULONG ulFontFormat = pfile->apface[0]->ulFontFormat; + + if (ulFontFormat == FMT_CFF) return FILEFMT_OTF; + if (ulFontFormat == FMT_FNT) return FILEFMT_FNT; + if (ulFontFormat == FMT_TRUETYPE) + { + if (*(DWORD*)pfile->pvView == 'OTTO') return FILEFMT_OTF; + return FILEFMT_TTF; + } + + __debugbreak(); + return 0; +} + +PFTFD_FACE +NTAPI +FtfdCreateFace( + PFTFD_FILE pfile, + FT_Face ftface) +{ + PFTFD_FACE pface; + FT_Error fterror; + ULONG ulAccumCharWidth = 0; + WCHAR wcCurrent, wcPrev; + FT_UInt index; + + pface = EngAllocMem(FL_ZERO_MEMORY, sizeof(FTFD_FACE), 'dftF'); + if (!pface) + { + DbgPrint("Couldn't allcate a face\n"); + return NULL; + } + + pface->pfile = pfile; + pface->ftface = ftface; + pface->cGlyphs = ftface->num_glyphs; + + /* Get the font format */ + pface->ulFontFormat = FtfdGetFontFormat(ftface); + + /* Load a unicode charmap */ + fterror = FT_Select_Charmap(ftface, FT_ENCODING_UNICODE); + if (fterror) + { + DbgPrint("ERROR: Could not load unicode charmap\n"); + return NULL; + } + + /* Start with 0 runs and 0 mappings */ + pface->cMappings = 0; + pface->cRuns = 0; + + /* Loop through all character mappings */ + wcPrev = wcCurrent = (WCHAR)FT_Get_First_Char(ftface, &index); + pface->ifiex.ifi.wcFirstChar = wcCurrent; + while (index) + { + /* Count the mapping */ + pface->cMappings++; + + /* If character is not subsequent, count a new run */ + if (wcCurrent != wcPrev + 1) pface->cRuns++; + wcPrev = wcCurrent; + + /* Get the next charcode and index */ + wcCurrent = (WCHAR)FT_Get_Next_Char(ftface, wcCurrent, &index); + } + + pface->ifiex.ifi.wcLastChar = wcPrev; + + /* Initialize IFIMETRICS */ + FtfdInitIfiMetrics(pface); + + /* Initialize glyphset */ + FtfdInitGlyphSet(pface); + + /* Initialize kerning pairs */ + FtfdInitKerningPairs(pface); + + return pface; +} + +static +VOID +FtfdDestroyFace( + PFTFD_FACE pface) +{ + /* Cleanup the freetype face */ + FT_Done_Face(pface->ftface); + + /* Free the glyphset structure */ + EngFreeMem(pface->pGlyphSet); + + /* Free the kerning pairs structure */ + if (pface->pKerningPairs) EngFreeMem(pface->pKerningPairs); + + /* Finally free the face structure */ + EngFreeMem(pface); +} + /** Public Interface **********************************************************/ @@ -36,92 +448,178 @@ ULONG ulFastCheckSum) { PVOID pvView; - ULONG cjView, i; + ULONG cjView, cjSize, cNumFaces, i; FT_Error fterror; FT_Face ftface; - PFTFD_FILE pfile; - ULONG cjSize, cNumFaces; + PFTFD_FILE pfile = NULL; DbgPrint("FtfdLoadFontFile()\n"); /* Check parameters */ if (cFiles != 1) { - DbgPrint("Only 1 File is allowed, got %ld!\n", cFiles); + DbgPrint("ERROR: Only 1 File is allowed, got %ld!\n", cFiles); return HFF_INVALID; } /* Map the font file */ if (!EngMapFontFileFD(*piFile, (PULONG*)&pvView, &cjView)) { - DbgPrint("Could not map font file!\n"); + DbgPrint("ERROR: Could not map font file!\n"); return HFF_INVALID; } - // HACK!!! - pvView = HackFixup(pvView, cjView); - + /* Load the first face */ fterror = FT_New_Memory_Face(gftlibrary, pvView, cjView, 0, &ftface); if (fterror) { - DbgPrint("No faces found in file\n"); - - /* Unmap the file */ - EngUnmapFontFileFD(*piFile); - /* Failure! */ - return HFF_INVALID; + DbgPrint("ERROR: No faces found in file\n"); + goto error; } /* Get number of faces from the first face */ cNumFaces = ftface->num_faces; - cjSize = sizeof(FTFD_FILE) + cNumFaces * sizeof(FT_Face); + /* Allocate the file structure */ + cjSize = sizeof(FTFD_FILE) + cNumFaces * sizeof(PVOID); pfile = EngAllocMem(0, cjSize, 'dftF'); if (!pfile) { - DbgPrint("EngAllocMem() failed.\n"); - - /* Unmap the file */ - EngUnmapFontFileFD(*piFile); - /* Failure! */ - return HFF_INVALID; - } - + DbgPrint("ERROR: EngAllocMem() failed.\n"); + goto error; + } + + /* Initialize the file structure */ pfile->cNumFaces = cNumFaces; pfile->iFile = *piFile; - pfile->pvView = pvView; - pfile->cjView = cjView; - - for (i = 0; i < pfile->cNumFaces; i++) - { - pfile->aftface[i] = ftface; - FT_Select_Charmap(ftface, FT_ENCODING_UNICODE); + pfile->pvView = *ppvView; + pfile->cjView = *pcjView; + pfile->ulFastCheckSum = ulFastCheckSum; + + /* Create a face */ + pfile->apface[0] = FtfdCreateFace(pfile, ftface); + if (!pfile->apface[0]) + { + DbgPrint("ERROR: FtfdCreateFace() failed.\n"); + goto error; + } + + /* Get the file format */ + pfile->ulFileFormat = FtfdGetFileFormat(pfile); + + /* Loop all additional faces in this file */ + for (i = 1; i < cNumFaces; i++) + { + /* Load the face */ + fterror = FT_New_Memory_Face(gftlibrary, *ppvView, *pcjView, i, &ftface); + if (fterror) + { + DbgPrint("error\n"); + __debugbreak(); + goto error; + } + + /* Store the face in the file structure */ + pfile->apface[i] = FtfdCreateFace(pfile, ftface); } DbgPrint("Success! Returning %ld faces\n", cNumFaces); - return (ULONG_PTR)pfile; + +error: + if (pfile) EngFreeMem(pfile); + + /* Unmap the file */ + EngUnmapFontFileFD(*piFile); + + /* Failure! */ + return HFF_INVALID; +} + +PIFIMETRICS +APIENTRY +FtfdQueryFont( + IN DHPDEV dhpdev, + IN ULONG_PTR diFile, + IN ULONG iFace, + IN ULONG_PTR *pid) +{ + PFTFD_FILE pfile = (PFTFD_FILE)diFile; + PFTFD_FACE pface = pfile->apface[iFace - 1]; + + DbgPrint("FtfdQueryFont()\n"); + + /* Validate parameters */ + if (iFace > pfile->cNumFaces || !pid) + { + DbgPrint("ERROR: iFace > pfile->cNumFaces || !pid\n"); + return NULL; + } + + /* Nothing to free */ + *pid = 0; + + /* Return pointer to the IFIMETRICS */ + return &pface->ifiex.ifi; +} + +PVOID +APIENTRY +FtfdQueryFontTree( + DHPDEV dhpdev, + ULONG_PTR diFile, + ULONG iFace, + ULONG iMode, + ULONG_PTR *pid) +{ + PFTFD_FILE pfile = (PFTFD_FILE)diFile; + PFTFD_FACE pface; + + DbgPrint("FtfdQueryFontTree(iMode=%ld)\n", iMode); + + /* Validate parameters */ + if (iFace > pfile->cNumFaces || !pid) + { + DbgPrint("ERROR: iFace > pfile->cNumFaces || !pid\n"); + return NULL; + } + + /* get pointer to the requested face */ + pface = pfile->apface[iFace - 1]; + + switch (iMode) + { + case QFT_GLYPHSET: + *pid = 0; + return pface->pGlyphSet; + + case QFT_KERNPAIRS: + *pid = 0; + return pface->pKerningPairs; + + default: + DbgPrint("ERROR: invalid iMode: %ld\n", iMode); + } + + return NULL; } BOOL APIENTRY FtfdUnloadFontFile( - IN ULONG_PTR iFile) -{ - PFTFD_FILE pfile = (PFTFD_FILE)iFile; + IN ULONG_PTR diFile) +{ + PFTFD_FILE pfile = (PFTFD_FILE)diFile; ULONG i; DbgPrint("FtfdUnloadFontFile()\n"); - - // HACK!!! - EngFreeMem(pfile->pvView); /* Cleanup faces */ for (i = 0; i < pfile->cNumFaces; i++) { - FT_Done_Face(pfile->aftface[i]); + FtfdDestroyFace(pfile->apface[i]); } /* Unmap the font file */ @@ -137,15 +635,14 @@ LONG APIENTRY FtfdQueryFontFile( - ULONG_PTR iFile, + ULONG_PTR diFile, ULONG ulMode, ULONG cjBuf, ULONG *pulBuf) { - PFTFD_FILE pfile = (PFTFD_FILE)iFile; + PFTFD_FILE pfile = (PFTFD_FILE)diFile; DbgPrint("FtfdQueryFontFile(ulMode=%ld)\n", ulMode); -// __debugbreak(); switch (ulMode) { @@ -163,171 +660,6 @@ return FD_ERROR; } - -PIFIMETRICS -APIENTRY -FtfdQueryFont( - IN DHPDEV dhpdev, - IN ULONG_PTR iFile, - IN ULONG iFace, - IN ULONG_PTR *pid) -{ - PFTFD_FILE pfile = (PFTFD_FILE)iFile; - PFTFD_IFIMETRICS pifiX; - PIFIMETRICS pifi; - FT_Face ftface; - FT_Error fterror; - ULONG i; - - DbgPrint("FtfdQueryFont()\n"); - - /* Validate parameters */ - if (iFace > pfile->cNumFaces || !pid) - { - DbgPrint("iFace > pfile->cNumFaces || !pid\n"); - return NULL; - } - - fterror = FT_New_Memory_Face(gftlibrary, - pfile->pvView, - pfile->cjView, - iFace - 1, - &ftface); - if (fterror) - { - DbgPrint("FT_New_Memory_Face failed\n"); - return NULL; - } - - /* Allocate the ifi metrics structure */ - pifiX = EngAllocMem(FL_ZERO_MEMORY, sizeof(FTFD_IFIMETRICS), TAG_IFIMETRICS); - if (!pifiX) - { - DbgPrint("EngAllocMem() failed.\n"); - FT_Done_Face(ftface); - return NULL; - } - - /* Fill IFIMETRICS */ - pifi = &pifiX->ifim; - pifi->cjThis = sizeof(FTFD_IFIMETRICS); - pifi->cjIfiExtra = 0; - - /* Relative offsets */ - pifi->dpwszFamilyName = FIELD_OFFSET(FTFD_IFIMETRICS, wszFamilyName); - pifi->dpwszStyleName = FIELD_OFFSET(FTFD_IFIMETRICS, wszStyleName); - pifi->dpwszFaceName = FIELD_OFFSET(FTFD_IFIMETRICS, wszFaceName); - pifi->dpwszUniqueName = FIELD_OFFSET(FTFD_IFIMETRICS, wszFaceName); - pifi->dpCharSets = FIELD_OFFSET(FTFD_IFIMETRICS, ajCharSet); - pifi->dpFontSim = 0; - - /* Charsets */ - pifi->jWinCharSet = ANSI_CHARSET; - pifiX->ajCharSet[0] = pifi->jWinCharSet; - for (i = 1; i < 16; i++) - { - pifiX->ajCharSet[i] = DEFAULT_CHARSET; - } - - pifi->lEmbedId = 0; - pifi->lItalicAngle = 0; - pifi->lCharBias = 0; - pifi->jWinPitchAndFamily = VARIABLE_PITCH | FF_DONTCARE; // FIXME - pifi->usWinWeight = FW_MEDIUM; // FIXME - pifi->flInfo = FM_INFO_TECH_TRUETYPE | FM_INFO_ARB_XFORMS | - FM_INFO_1BPP | FM_INFO_4BPP | - FM_INFO_RETURNS_OUTLINES | - FM_INFO_RETURNS_BITMAPS | - FM_INFO_RIGHT_HANDED; - pifi->fsSelection = 0; - pifi->fsType = 0; - - /* Font resolution */ - pifi->fwdUnitsPerEm = ftface->units_per_EM; - pifi->fwdLowestPPEm = 8; // FIXME - - /* Font metrics */ - pifi->fwdWinAscender = ftface->ascender; - pifi->fwdWinDescender = - ftface->descender; - pifi->fwdMacAscender = pifi->fwdWinAscender; - pifi->fwdMacDescender = - pifi->fwdWinDescender; - pifi->fwdMacLineGap = 0; - pifi->fwdTypoAscender = pifi->fwdWinAscender; - pifi->fwdTypoDescender = 0; // FIXME!!! - pifi->fwdWinDescender; - pifi->fwdTypoLineGap = 0; - pifi->fwdAveCharWidth = 1085; // FIXME - pifi->fwdMaxCharInc = ftface->max_advance_width; - pifi->fwdCapHeight = pifi->fwdUnitsPerEm / 2; - pifi->fwdXHeight = pifi->fwdUnitsPerEm / 4; - pifi->fwdSubscriptXSize = 0; - pifi->fwdSubscriptYSize = 0; - pifi->fwdSubscriptXOffset = 0; - pifi->fwdSubscriptYOffset = 0; - pifi->fwdSuperscriptXSize = 0; - pifi->fwdSuperscriptYSize = 0; - pifi->fwdSuperscriptXOffset = 0; - pifi->fwdSuperscriptYOffset = 0; - pifi->fwdUnderscoreSize = 1; - pifi->fwdUnderscorePosition = -1; - pifi->fwdStrikeoutSize = 1; - pifi->fwdStrikeoutPosition = pifi->fwdXHeight + 1; - - pifi->ptlBaseline.x = 1; - pifi->ptlBaseline.y = 0; - pifi->ptlAspect.x = 1; - pifi->ptlAspect.y = 1; - pifi->ptlCaret.x = 0; - pifi->ptlCaret.y = 1; - - /* Set the biggest characters bounding box */ - pifi->rclFontBox.left = ftface->bbox.xMin; - pifi->rclFontBox.right = ftface->bbox.xMax; - pifi->rclFontBox.top = ftface->bbox.yMax; - pifi->rclFontBox.bottom = ftface->bbox.yMin; - - /* Special characters */ - pifi->chFirstChar = 0x1c; // FIXME - pifi->chLastChar = 0x79; - pifi->chDefaultChar = 0x1d; - pifi->chBreakChar = 0x1e; - pifi->wcFirstChar = 0x1e; - pifi->wcLastChar = 0x79; - pifi->wcDefaultChar = 0x1d; - pifi->wcBreakChar = 0x1e; - - - *(DWORD*)&pifi->achVendId = 0x30303030; // FIXME - pifi->cKerningPairs = 0; - pifi->ulPanoseCulture = FM_PANOSE_CULTURE_LATIN; -// pifi->panose = panose; - - EngMultiByteToUnicodeN(pifiX->wszFamilyName, - LF_FACESIZE, - NULL, - ftface->family_name, - strnlen(ftface->family_name, MAX_PATH)); - - EngMultiByteToUnicodeN(pifiX->wszStyleName, - LF_FACESIZE, - NULL, - ftface->style_name, - strnlen(ftface->style_name, MAX_PATH)); - - EngMultiByteToUnicodeN(pifiX->wszFaceName, - LF_FACESIZE, - NULL, - ftface->family_name, - strnlen(ftface->family_name, MAX_PATH)); - - FT_Done_Face(ftface); - - DbgPrint("Finished with the ifi: %p\n", pifiX); - __debugbreak(); - - return pifi; -} - - LONG APIENTRY FtfdQueryFontCaps( @@ -342,138 +674,42 @@ return FD_ERROR; } - /* We only support 1 bpp */ + /* We only support bitmaps for now */ pulCaps[0] = 2; - pulCaps[1] = QC_1BIT; + pulCaps[1] = QC_1BIT | QC_4BIT; return 2; } +LONG +APIENTRY +FtfdQueryTrueTypeTable( + ULONG_PTR diFile, + ULONG ulFont, + ULONG ulTag, + PTRDIFF dpStart, + ULONG cjBuf, + BYTE *pjBuf, + PBYTE *ppjTable, + ULONG *pcjTable) +{ + DbgPrint("FtfdQueryTrueTypeTable\n"); + __debugbreak(); + return FD_ERROR; +} PVOID APIENTRY -FtfdQueryFontTree( - DHPDEV dhpdev, - ULONG_PTR iFile, - ULONG iFace, - ULONG iMode, - ULONG_PTR *pid) -{ - PFTFD_FILE pfile = (PFTFD_FILE)iFile; - FT_Face ftface; - FT_Error fterror; - FTFD_CHARPAIR *pcp; - FD_GLYPHSET *pGlyphSet; - FT_ULong charcode; - ULONG i, j, cGlyphs, cRuns, cjSize; - WCRUN *pwcrun; - HGLYPH * phglyphs; - - DbgPrint("FtfdQueryFontTree()\n"); - - fterror = FT_New_Memory_Face(gftlibrary, - pfile->pvView, - pfile->cjView, - iFace - 1, - &ftface); - if (fterror) - { - DbgPrint("FT_New_Memory_Face() failed.\n"); - return NULL; - } - - /* Get inital value for cGlyphs from ftface */ - cGlyphs = ftface->num_glyphs + 1; - - /* Allocate a buffer for the char codes and glyph indexes */ - pcp = EngAllocMem(0, cGlyphs * sizeof(FTFD_CHARPAIR), 'pcp '); - if (!pcp) - { - DbgPrint("EngAllocMem() failed.\n"); - return NULL; - } - - /* Gather char codes and indexes and count WCRUNs */ - pcp[0].code = FT_Get_First_Char(ftface, &pcp[0].index); - charcode = pcp[0].code; - for (i = 1, cRuns = 1; charcode && i < cGlyphs; i++) - { - charcode = FT_Get_Next_Char(ftface, charcode, &pcp[i].index); - DbgPrint("charcode=0x%lx, index=0x%lx\n", charcode, pcp[i].index); - pcp[i].code = charcode; - if (charcode != pcp[i - 1].code + 1) - { - cRuns++; - } - } - - /* Update cGlyphs to real value */ - cGlyphs = i - 1; - - /* Calculate FD_GLYPHSET size */ - cjSize = sizeof(FD_GLYPHSET) - + (cRuns - 1) * sizeof(WCRUN) - + cGlyphs * sizeof(HGLYPH); - - /* Allocate the FD_GLYPHSET structure */ - pGlyphSet = EngAllocMem(0, cjSize, TAG_GLYPHSET); - if (!pGlyphSet) - { - DbgPrint("EngAllocMem() failed.\n"); - return NULL; - } - - /* Initialize FD_GLYPHSET */ - pGlyphSet->cjThis = cjSize; - pGlyphSet->flAccel = 0; - pGlyphSet->cGlyphsSupported = cGlyphs; - pGlyphSet->cRuns = cRuns; - - /* Initialize 1st WCRUN */ - pwcrun = pGlyphSet->awcrun; - phglyphs = (PHGLYPH)&pGlyphSet->awcrun[cRuns]; - pwcrun[0].wcLow = pcp[0].code; - pwcrun[0].cGlyphs = 1; - pwcrun[0].phg = &phglyphs[0]; - phglyphs[0] = pcp[0].index; - -DbgPrint("pcp[0].index = 0x%lx\n", pcp[0].index); - - /* Walk through all supported chars */ - for (i = 1, j = 0; i < cGlyphs; i++) - { - /* Use glyph index as HGLYPH */ - phglyphs[i] = pcp[i].index; - - /* Check whether we can append the wchar to a run */ - if (pcp[i].code == pcp[i - 1].code + 1) - { - /* Append to current WCRUN */ - pwcrun[j].cGlyphs++; - } - else - { - /* Add a new WCRUN */ - DbgPrint("adding new run\n"); - j++; - pwcrun[j].wcLow = pcp[i].code; - pwcrun[j].cGlyphs = 1; - pwcrun[j].phg = &phglyphs[i]; - } - } - - /* Free the temporary buffer */ - EngFreeMem(pcp); - - /* Set *pid to the allocated structure for use in FtfdFree */ - *pid = (ULONG_PTR)pGlyphSet; - -DbgPrint("pGlyphSet=%p\n", pGlyphSet); -__debugbreak(); - - return pGlyphSet; -} - +FtfdGetTrueTypeFile( + ULONG_PTR diFile, + ULONG *pcj) +{ + DbgPrint("FtfdGetTrueTypeFile\n"); + __debugbreak(); + return 0; +} + +#if 0 // not needed atm VOID APIENTRY FtfdFree( @@ -481,11 +717,8 @@ ULONG_PTR id) { DbgPrint("FtfdFree()\n"); - if (id) - { - EngFreeMem((PVOID)id); - } -} - - - + EngFreeMem(pv); +} +#endif + + Modified: branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/ftfd.h URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/GdiFontDriver/drivers…
============================================================================== --- branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/ftfd.h [iso-8859-1] (original) +++ branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/ftfd.h [iso-8859-1] Wed May 4 19:48:29 2011 @@ -11,7 +11,9 @@ #include <winddi.h> #include <ft2build.h> -#include FT_FREETYPE_H +#include <freetype/ftadvanc.h> +#include <freetype/ftxf86.h> +#include FT_FREETYPE_H extern FT_Library gftlibrary; @@ -20,32 +22,74 @@ /** Driver specific types *****************************************************/ +typedef enum +{ + FMT_UNKNOWN, + FMT_TRUETYPE, + FMT_TYPE1, + FMT_CFF, + FMT_FNT, + FMT_BDF, + FMT_PCF, + FMT_TYPE42, + FMT_CIDTYPE1, + FMT_PFR +} FONT_FORMAT; + +typedef enum +{ + FILEFMT_TTF, + FILEFMT_OTF, + FILEFMT_FNT, +} FLE_FORMAT; + +//"Bold Italic Underline Strikeout" +#define MAX_STYLESIZE 35 typedef struct { - FT_UInt index; - FT_ULong code; -} FTFD_CHARPAIR; + IFIMETRICS ifi; + BYTE ajCharSet[16]; + FONTSIM fontsim; + WCHAR awcFamilyName[LF_FACESIZE]; + WCHAR awcFaceName[LF_FACESIZE]; + WCHAR awcStyleName[MAX_STYLESIZE]; + WCHAR awcUniqueName[LF_FACESIZE + 11]; +} FTFD_IFIMETRICS, *PFTFD_IFIMETRICS; typedef struct +{ + struct _FTFD_FILE *pfile; + FT_Face ftface; + ULONG ulFontFormat; + ULONG cGlyphs; + ULONG cMappings; + ULONG cRuns; + FD_GLYPHSET *pGlyphSet; + FD_KERNINGPAIR *pKerningPairs; + FTFD_IFIMETRICS ifiex; +} FTFD_FACE, *PFTFD_FACE; + +typedef struct _FTFD_FILE { PVOID pvView; ULONG cjView; ULONG_PTR iFile; ULONG cNumFaces; - FT_Face aftface[1]; + ULONG ulFastCheckSum; + ULONG ulFileFormat; + PFTFD_FACE apface[1]; } FTFD_FILE, *PFTFD_FILE; -//"Bold Italic Underline Strikeout" -#define MAX_STYLESIZE 35 typedef struct { - IFIMETRICS ifim; - BYTE ajCharSet[16]; - FONTSIM fontsim; - WCHAR wszFamilyName[LF_FACESIZE]; - WCHAR wszFaceName[LF_FACESIZE]; - WCHAR wszStyleName[MAX_STYLESIZE]; -} FTFD_IFIMETRICS, *PFTFD_IFIMETRICS; + FONTOBJ *pfo; + PFTFD_FILE pfile; + ULONG iFace; + FT_Face ftface; + HGLYPH hgSelected; + ULONG cjSelected; +} FTFD_FONT, *PFTFD_FONT; + /** Function prototypes *******************************************************/ @@ -127,6 +171,11 @@ VOID APIENTRY +FtfdDestroyFont( + FONTOBJ *pfo); + +VOID +APIENTRY FtfdFree( PVOID pv, ULONG_PTR id); @@ -148,3 +197,68 @@ PVOID pv, ULONG cjSize); +BOOL +APIENTRY +FtfdQueryAdvanceWidths( + DHPDEV dhpdev, + FONTOBJ *pfo, + ULONG iMode, + HGLYPH *phg, + PVOID pvWidths, + ULONG cGlyphs); + +LONG +APIENTRY +FtfdQueryTrueTypeOutline( + DHPDEV dhpdev, + FONTOBJ *pfo, + HGLYPH hglyph, + BOOL bMetricsOnly, + GLYPHDATA *pgldt, + ULONG cjBuf, + TTPOLYGONHEADER *ppoly); + +LONG +APIENTRY +FtfdQueryTrueTypeTable( + ULONG_PTR iFile, + ULONG ulFont, + ULONG ulTag, + PTRDIFF dpStart, + ULONG cjBuf, + BYTE *pjBuf, + PBYTE *ppjTable, + ULONG *pcjTable); + +ULONG +APIENTRY +FtfdEscape( + SURFOBJ *pso, + ULONG iEsc, + ULONG cjIn, + PVOID pvIn, + ULONG cjOut, + PVOID pvOut); + +ULONG +APIENTRY +FtfdFontManagement( + SURFOBJ *pso, + FONTOBJ *pfo, + ULONG iMode, + ULONG cjIn, + PVOID pvIn, + ULONG cjOut, + PVOID pvOut); + +PVOID +APIENTRY +FtfdGetTrueTypeFile( + ULONG_PTR iFile, + ULONG *pcj); + +VOID +NTAPI +OtfGetIfiMetrics( + PFTFD_FACE pface, + PIFIMETRICS pifi); Modified: branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/glyph.c URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/GdiFontDriver/drivers…
============================================================================== --- branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/glyph.c [iso-8859-1] (original) +++ branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/glyph.c [iso-8859-1] Wed May 4 19:48:29 2011 @@ -1,23 +1,284 @@ /* * PROJECT: ReactOS win32 subsystem * LICENSE: GPL - See COPYING in the top level directory - * PURPOSE: GDI font driver for bitmap fonts + * PURPOSE: GDI font driver based on freetype * PROGRAMMER: Timo Kreuzer (timo.kreuzer(a)reactos.org) */ #include "ftfd.h" +/** Private Interface *********************************************************/ + +#define GLYPHBITS_SIZE(cx, cy, bpp) \ + (FIELD_OFFSET(GLYPHBITS, aj) + ((((cx * bpp) + 31) >> 5) * cy * 4)) + +PFTFD_FONT +NTAPI +FtfdCreateFontInstance( + FONTOBJ *pfo) +{ + PFTFD_FILE pfile = (PFTFD_FILE)pfo->iFile; + PFTFD_FONT pfont; + XFORMOBJ* pxo; + FT_Error fterror; + FT_Face ftface; + + /* Allocate a font structure */ + pfont = EngAllocMem(0, sizeof(FTFD_FONT), 0); + if (!pfont) + { + return NULL; + } + + /* Set basic fields */ + pfont->pfo = pfo; + pfont->pfile = pfile; + pfont->iFace = pfo->iFace; + pfont->hgSelected = -1; + + /* Create a freetype face */ + fterror = FT_New_Memory_Face(gftlibrary, + pfile->pvView, + pfile->cjView, + pfo->iFace - 1, + &ftface); + if (fterror) + { + /* Failure! */ + DbgPrint("Error creating face\n"); + return NULL; + } + + pxo = FONTOBJ_pxoGetXform(pfo); + + fterror = FT_Set_Char_Size(ftface, + 0, + 16 * 64, + pfo->sizLogResPpi.cx, + pfo->sizLogResPpi.cy); + if (fterror) + { + /* Failure! */ + DbgPrint("Error setting face size\n"); + return NULL; + } + + /* Set non-orthogonal transformation */ + // FT_Set_Transform + + pfont->ftface = ftface; + + /* Set the pvProducer member of the fontobj */ + pfo->pvProducer = pfont; + return pfont; +} + +static +PFTFD_FONT +FtfdGetFontInstance( + FONTOBJ *pfo) +{ + PFTFD_FONT pfont = pfo->pvProducer; + + if (!pfont) + { + pfont = FtfdCreateFontInstance(pfo); + } + + /* Return the font instance */ + return pfont; +} + +#define FLOATL_1 0x3f800000 + +ULONG +NTAPI +FtfdQueryMaxExtents( + FONTOBJ *pfo, + PFD_DEVICEMETRICS pfddm, + ULONG cjSize) +{ + PFTFD_FONT pfont = FtfdGetFontInstance(pfo); + ULONG cjMaxWidth, cjMaxBitmapSize; + + DbgPrint("FtfdQueryMaxExtents\n"); + + if (pfddm) + { + if (cjSize < sizeof(FD_DEVICEMETRICS)) + { + /* Not enough space, fail */ + DbgPrint("ERROR: cjSize = %ld\n", cjSize); + return FD_ERROR; + } + + //xScale = pfont->xScale; + //yScale = pfont->yScale; + + /* Fill FD_DEVICEMETRICS */ + pfddm->flRealizedType = 0; + pfddm->pteBase.x = FLOATL_1; + pfddm->pteBase.y = 0; + pfddm->pteSide.x = 0; + pfddm->pteSide.y = FLOATL_1; + pfddm->ptlUnderline1.x = 0; + pfddm->ptlUnderline1.y = 1; + pfddm->ptlStrikeout.x = 0; + pfddm->ptlStrikeout.y = -4; + pfddm->ptlULThickness.x = 0; + pfddm->ptlULThickness.y = 1; + pfddm->ptlSOThickness.x = 0; + pfddm->ptlSOThickness.y = 1; + pfddm->lMinA = 0; + pfddm->lMinC = 0; + pfddm->lMinD = 0; + +#if 0 + if (pfont->ulAngle == 90 || pfont->ulAngle == 270) + { + pfddm->cxMax = xScale * GETVAL(pFontInfo->dfPixHeight); + pfddm->cyMax = yScale * GETVAL(pFontInfo->dfMaxWidth); + pfddm->fxMaxAscender = yScale * GETVAL(pFontInfo->dfAscent) << 4; + pfddm->fxMaxDescender = (pfddm->cyMax << 4) - pfddm->fxMaxAscender; + } + else + { + pfddm->cxMax = xScale * GETVAL(pFontInfo->dfMaxWidth); + pfddm->cyMax = yScale * GETVAL(pFontInfo->dfPixHeight); + pfddm->fxMaxAscender = yScale * GETVAL(pFontInfo->dfAscent) << 4; + pfddm->fxMaxDescender = (pfddm->cyMax << 4) - pfddm->fxMaxAscender; + } +#endif + + pfddm->lD = pfddm->cxMax; + + /* Calculate Width in bytes */ + cjMaxWidth = ((pfddm->cxMax + 7) >> 3); + + /* Calculate size of the bitmap, rounded to DWORDs */ + cjMaxBitmapSize = ((cjMaxWidth * pfddm->cyMax) + 3) & ~3; + + /* cjGlyphMax is the full size of the GLYPHBITS structure */ + pfddm->cjGlyphMax = FIELD_OFFSET(GLYPHBITS, aj) + cjMaxBitmapSize; + + /* NOTE: fdxQuantized and NonLinear... stay unchanged */ + } + + /* Return the size of the structure */ + return sizeof(FD_DEVICEMETRICS); +} + +static +BOOL +FtfdLoadGlyph( + PFTFD_FONT pfont, + HGLYPH hg, + ULONG iFormat) // 0 = bitmap, 1 = outline +{ + FT_Error fterror; + + /* Check if the glyph needs to be updated */ + if (pfont->hgSelected != hg) + { + /* Load the glypg into the freetype face slot */ + fterror = FT_Load_Glyph(pfont->ftface, hg, 0); + if (fterror) + { + DbgPrint("FtfdLoadGlyph: couldn't load glyph 0x%lx\n", hg); + pfont->hgSelected = -1; + return FALSE; + } + + /* Update the selected glyph */ + pfont->hgSelected = hg; + } + + return TRUE; +} + +static +VOID +FtfdQueryGlyphData( + FONTOBJ *pfo, + HGLYPH hg, + GLYPHDATA *pgd, + PVOID pvGlyphData) +{ + PFTFD_FONT pfont = pfo->pvProducer; + FT_GlyphSlot ftglyph = pfont->ftface->glyph; + +if (hg > 1) __debugbreak(); + + pgd->gdf.pgb = pvGlyphData; + pgd->hg = hg; + + if (1 /* layout horizontal */) + { + pgd->fxA = ftglyph->metrics.horiBearingX; + pgd->fxAB = pgd->fxA + ftglyph->metrics.width; + pgd->fxD = ftglyph->metrics.horiAdvance; + } + else + { + pgd->fxA = ftglyph->metrics.vertBearingX; + pgd->fxAB = pgd->fxA + ftglyph->metrics.height; + pgd->fxD = ftglyph->metrics.vertAdvance; + } + + pgd->fxInkTop = 0; + pgd->fxInkBottom = 0; + pgd->rclInk.left = ftglyph->bitmap_left; + pgd->rclInk.top = ftglyph->bitmap_top; + pgd->rclInk.right = pgd->rclInk.left + ftglyph->bitmap.width; + pgd->rclInk.bottom = pgd->rclInk.top + ftglyph->bitmap.rows; + + /* Make the bitmap at least 1x1 pixel */ + if (ftglyph->bitmap.width == 0) pgd->rclInk.right++; + if (ftglyph->bitmap.rows == 0) pgd->rclInk.bottom++; + + pgd->ptqD.x.LowPart = 0; + pgd->ptqD.x.HighPart = pgd->fxD; + pgd->ptqD.y.LowPart = 0; + pgd->ptqD.y.HighPart = 0; + //pgd->ptqD.x.QuadPart = 0; + //pgd->ptqD.y.QuadPart = 0; + + +if (hg > 1) __debugbreak(); + +} + +VOID +FtfdQueryGlyphBits( + FONTOBJ *pfo, + HGLYPH hg, + GLYPHBITS *pgb, + ULONG cjSize) +{ + PFTFD_FONT pfont = pfo->pvProducer; + FT_GlyphSlot ftglyph = pfont->ftface->glyph; + +if (hg > 1) __debugbreak(); + + pgb->ptlOrigin.x = 0; + pgb->ptlOrigin.y = 0; + pgb->sizlBitmap.cx = ftglyph->bitmap.width; + pgb->sizlBitmap.cy = ftglyph->bitmap.rows; + +if (hg > 1) __debugbreak(); +} + +VOID +FtfdQueryGlyphOutline( + FONTOBJ *pfo, + HGLYPH hg, + PATHOBJ *ppo, + ULONG cjSize) +{ + +} /** Public Interface **********************************************************/ - -PFD_GLYPHATTR -APIENTRY -FtfdQueryGlyphAttrs( - FONTOBJ *pfo, - ULONG iMode) -{ - return NULL; -} LONG APIENTRY @@ -30,5 +291,183 @@ PVOID pv, ULONG cjSize) { + PFTFD_FONT pfont = FtfdGetFontInstance(pfo); + + DbgPrint("FtfdQueryFontData, iMode=%ld, hg=%lx, pgd=%p, pv=%p, cjSize=%ld\n", + iMode, hg, pgd, pv, cjSize); + + switch (iMode) + { + case QFD_GLYPHANDBITMAP: + DbgPrint("QFD_GLYPHANDBITMAP\n"); + + /* Load the requested glyph */ + if (!FtfdLoadGlyph(pfont, hg, 0)) return FD_ERROR; + + if (pgd) FtfdQueryGlyphData(pfo, hg, pgd, pv); + + + if (pv) + { + FtfdQueryGlyphBits(pfo, hg, pv, cjSize); + } + + /* Return the size for a 1bpp bitmap */ + return GLYPHBITS_SIZE(pfont->ftface->glyph->bitmap.width, + pfont->ftface->glyph->bitmap.rows, + 1); + + case QFD_GLYPHANDOUTLINE: + DbgPrint("QFD_GLYPHANDOUTLINE\n"); + + /* Load the requested glyph */ + if (!FtfdLoadGlyph(pfont, hg, 1)) return FD_ERROR; + + if (pgd) + { + FtfdQueryGlyphData(pfo, hg, pgd, pv); + } + + if (pv) + { + FtfdQueryGlyphOutline(pfo, hg, pv, cjSize); + } + break; + + case QFD_MAXEXTENTS: + return FtfdQueryMaxExtents(pfo, pv, cjSize); + + case QFD_TT_GRAY1_BITMAP: + DbgPrint("QFD_TT_GRAY1_BITMAP\n"); + break; + case QFD_TT_GRAY2_BITMAP: + DbgPrint("QFD_TT_GRAY2_BITMAP\n"); + break; + case QFD_TT_GRAY4_BITMAP: + DbgPrint("QFD_TT_GRAY4_BITMAP\n"); + break; + case QFD_TT_GRAY8_BITMAP: + DbgPrint("QFD_TT_GRAY8_BITMAP\n"); + break; + default: + DbgPrint("Impossible iMode value: %lx\n", iMode); + EngSetLastError(ERROR_INVALID_PARAMETER); + return FD_ERROR; + } + + __debugbreak(); + + return FD_ERROR; } + +PFD_GLYPHATTR +APIENTRY +FtfdQueryGlyphAttrs( + FONTOBJ *pfo, + ULONG iMode) +{ + DbgPrint("FtfdQueryGlyphAttrs\n"); + + /* Verify parameters */ + if (!pfo || iMode != FO_ATTR_MODE_ROTATE) + { + DbgPrint("ERROR: invalid parameters: %p, %ld\n", pfo, iMode); + return NULL; + } + + + + __debugbreak(); + return NULL; +} + +BOOL +APIENTRY +FtfdQueryAdvanceWidths( + DHPDEV dhpdev, + FONTOBJ *pfo, + ULONG iMode, + HGLYPH *phg, + PVOID pvWidths, + ULONG cGlyphs) +{ + PFTFD_FONT pfont = FtfdGetFontInstance(pfo); + PUSHORT pusWidths = pvWidths; + BOOL bResult = TRUE; + ULONG i, fl; + FT_Face ftface = pfont->ftface; + FT_Error fterror; + FT_Fixed advance; + + DbgPrint("FtfdQueryAdvanceWidths\n"); + + // FIXME: layout horizontal/vertical + fl = (iMode == QAW_GETEASYWIDTHS) ? FT_ADVANCE_FLAG_FAST_ONLY : 0; +// | (ftface->face_flags & FT_FACE_FLAG_VERTICAL) ? FT_LOAD_VERTICAL_LAYOUT : 0; +fl = 0; + + /* Loop all requested glyphs */ + for (i = 0; i < cGlyphs; i++) + { + /* Query advance width */ + fterror = FT_Get_Advance(ftface, (FT_UInt)phg[i], fl, &advance); + if (fterror || advance > 0x0FFFF000) + { + DbgPrint("ERROR: failed to query advance width hg=%lx, fl=0x%lx\n", + phg[i], fl); + pusWidths[i] = 0xffff; + bResult = FALSE; + } + else + { + DbgPrint("Got advance width: hg=%lx, adv=%d\n", phg[i], advance >> 12); + pusWidths[i] = (USHORT)advance >> 12; + } + } + + //__debugbreak(); + return bResult; +} + +LONG +APIENTRY +FtfdQueryTrueTypeOutline( + DHPDEV dhpdev, + FONTOBJ *pfo, + HGLYPH hg, + BOOL bMetricsOnly, + GLYPHDATA *pgldt, + ULONG cjBuf, + TTPOLYGONHEADER *ppoly) +{ + DbgPrint("FtfdQueryTrueTypeOutline\n"); + __debugbreak(); + return 0; +} + +ULONG +APIENTRY +FtfdFontManagement( + SURFOBJ *pso, + FONTOBJ *pfo, + ULONG iMode, + ULONG cjIn, + PVOID pvIn, + ULONG cjOut, + PVOID pvOut) +{ + DbgPrint("FtfdFontManagement\n"); + __debugbreak(); + return 0; +} + +VOID +APIENTRY +FtfdDestroyFont( + FONTOBJ *pfo) +{ + DbgPrint("FtfdDestroyFont()\n"); + __debugbreak(); +} + Added: branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/opentype.c URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/GdiFontDriver/drivers…
============================================================================== --- branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/opentype.c (added) +++ branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/opentype.c [iso-8859-1] Wed May 4 19:48:29 2011 @@ -1,0 +1,308 @@ +/* + * PROJECT: ReactOS win32 subsystem + * LICENSE: GPL - See COPYING in the top level directory + * PURPOSE: OpenType support for GDI font driver based on freetype + * PROGRAMMER: Timo Kreuzer (timo.kreuzer(a)reactos.org) + * REFERENCES:
http://www.microsoft.com/typography/otspec/
+ *
http://www.microsoft.com/typography/otspec/os2.htm
+ */ + +#include "ftfd.h" +#include <freetype/t1tables.h> + +#define SWAPW(x) _byteswap_ushort(x) +#define SWAPD(x) _byteswap_ulong(x) + +typedef struct _OTF_TABLE_ENTRY +{ + ULONG ulTag; + ULONG ulCheckSum; + ULONG ulOffset; + ULONG ulLength; +} OTF_TABLE_ENTRY, *POTF_TABLE_ENTRY; + +typedef struct _OTF_FILE_HEADER +{ + ULONG ulIdentifier; + USHORT usNumTables; + USHORT usSearchRange; + USHORT usEntrySelector; + USHORT usRangeshift; + + OTF_TABLE_ENTRY aTableEntries[1]; + +} OTF_FILE_HEADER, *POTF_FILE_HEADER; + +#include <pshpack1.h> +typedef struct _OTF_OS2_DATA +{ + USHORT version; // 0x0004 + SHORT xAvgCharWidth; + USHORT usWeightClass; + USHORT usWidthClass; + USHORT fsType; + SHORT ySubscriptXSize; + SHORT ySubscriptYSize; + SHORT ySubscriptXOffset; + SHORT ySubscriptYOffset; + SHORT ySuperscriptXSize; + SHORT ySuperscriptYSize; + SHORT ySuperscriptXOffset; + SHORT ySuperscriptYOffset; + SHORT yStrikeoutSize; + SHORT yStrikeoutPosition; + union + { + struct + { + BYTE jClassId; + BYTE jSubClassId; + }; + SHORT sFamilyClass; + }; + BYTE panose[10]; + ULONG ulUnicodeRange1; // Bits 0-31 + ULONG ulUnicodeRange2; // Bits 32-63 + ULONG ulUnicodeRange3; // Bits 64-95 + ULONG ulUnicodeRange4; // Bits 96-127 + CHAR achVendID[4]; + USHORT fsSelection; + USHORT usFirstCharIndex; + USHORT usLastCharIndex; + SHORT sTypoAscender; + SHORT sTypoDescender; + SHORT sTypoLineGap; + USHORT usWinAscent; + USHORT usWinDescent; + ULONG ulCodePageRange1; // Bits 0-31 + ULONG ulCodePageRange2; // Bits 32-63 + SHORT sxHeight; + SHORT sCapHeight; + USHORT usDefaultChar; + USHORT usBreakChar; + USHORT usMaxContext; +} OTF_OS2_DATA, *POTF_OS2_DATA; +#include <poppack.h> + +BOOL +OtfGetType1FontInfo( + PFTFD_FACE pface, + PIFIMETRICS pifi) +{ + FT_Error fterror; + PS_FontInfoRec fontinfo; + + fterror = FT_Get_PS_Font_Info(pface->ftface, &fontinfo); + if (fterror) + { + DbgPrint("ERROR: Failed to retrieve font info\n"); + return FALSE; + } + + /* Try to find the font weight */ + if (strncpy(fontinfo.weight, "Normal", 7) == 0) + pifi->usWinWeight = FW_NORMAL; + // else if (..) + else + pifi->usWinWeight = FW_REGULAR; + + pifi->lItalicAngle = fontinfo.italic_angle; + + /* Clear lower 2 bits and set FIXED_PITCH or VARIABLE_PITCH */ + pifi->jWinPitchAndFamily &= ~3; + if (fontinfo.is_fixed_pitch) + pifi->jWinPitchAndFamily |= FIXED_PITCH; + else + pifi->jWinPitchAndFamily |= VARIABLE_PITCH; + + return TRUE; +} + +PVOID +OtfFindTable( + PVOID pvView, + ULONG cjView, + ULONG ulTag, + PULONG pulLength) +{ + POTF_FILE_HEADER pFileHeader = pvView; + ULONG i, ulOffset, ulLength, ulNumTables; + + /* Verify the file header */ + if (pFileHeader->ulIdentifier != 'OTTO' && + pFileHeader->ulIdentifier != 'fctt' && + pFileHeader->ulIdentifier != 0x00000100) + { + DbgPrint("ERROR: Couldn't verify identifier: 0x%lx\n", + pFileHeader->ulIdentifier); + return NULL; + } + + /* Check if number of tables is ok */ + ulNumTables = SWAPW(pFileHeader->usNumTables); + ulLength = ulNumTables * sizeof(OTF_TABLE_ENTRY); + if (ulLength + sizeof(OTF_FILE_HEADER) > cjView) + { + DbgPrint("ERROR: Too many tables (%ld)\n", ulNumTables); + return NULL; + } + + /* Loop all tables */ + for (i = 0; i < ulNumTables; i++) + { + /* Compare the tag */ + if (pFileHeader->aTableEntries[i].ulTag == ulTag) + { + /* Get table offset and length */ + ulOffset = SWAPD(pFileHeader->aTableEntries[i].ulOffset); + ulLength = SWAPD(pFileHeader->aTableEntries[i].ulLength); + + /* Check if this is inside the file */ + if (ulOffset + ulLength > cjView || + ulOffset + ulLength < ulOffset) + { + DbgPrint("invalid table entry. %ld, %ld \n", ulOffset, ulLength); + return NULL; + } + + if (pulLength) *pulLength = ulLength; + return (PUCHAR)pvView + ulOffset; + } + } + + /* Not found */ + return NULL; +} + +BYTE +OtfGetWinFamily(BYTE jClassId, BYTE jSubclassId) +{ + BYTE jFamily = 0; + + switch (jClassId) + { + case 0: // Class ID = 0 No Classification + /* We rely on the already set value */ + break; + + case 1: // Class ID = 1 Oldstyle Serifs + switch (jSubclassId) + { + case 0: // Subclass ID = 0 : No Classification + case 1: // Subclass ID = 1 : IBM Rounded Legibility + case 2: // Subclass ID = 2 : Garalde + case 3: // Subclass ID = 3 : Venetian + case 4: // Subclass ID = 4 : Modified Venetian + case 5: // Subclass ID = 5 : Dutch Modern + case 6: // Subclass ID = 6 : Dutch Traditional + case 7: // Subclass ID = 7 : Contemporary + case 8: // Subclass ID = 8 : Calligraphic + jFamily = FF_SCRIPT; break; + + case 15: // Subclass ID = 15 : Miscellaneous + + default: // Subclass ID = 9-14 : (reserved for future use) + break; + } + case 2: // Class ID = 2 Transitional Serifs + case 3: // Class ID = 3 Modern Serifs + case 4: // Class ID = 4 Clarendon Serifs + case 5: // Class ID = 5 Slab Serifs + case 6: // Class ID = 6 (reserved for future use) + case 7: // Class ID = 7 Freeform Serifs + case 8: // Class ID = 8 Sans Serif + switch (jSubclassId) + { + case 15: // Subclass ID = 15 : Miscellaneous + jFamily = FF_SWISS | FF_ROMAN; break; + default: + break; + } + case 9: // Class ID = 9 Ornamentals + case 10: // Class ID = 10 Scripts + case 11: // Class ID = 11 (reserved for future use) + case 12: // Class ID = 12 Symbolic + case 13: // Class ID = 13 Reserved + case 14: // Class ID = 14 Reserved + break; + } +__debugbreak(); + return jFamily; +} + +VOID +NTAPI +OtfGetIfiMetrics( + PFTFD_FACE pface, + PIFIMETRICS pifi) +{ + PFTFD_FILE pfile = pface->pfile; + PVOID pvView = pfile->pvView; + POTF_OS2_DATA pOs2; + + /* Try to get type 1 info */ + OtfGetType1FontInfo(pface, pifi); + + /* Get the OS/2 table for the face */ + // FIXME: get the right table for the face, when multiple faces + pOs2 = OtfFindTable(pvView, pfile->cjView, '2/SO', NULL); + if (!pOs2) + { + DbgPrint("Couldn't find OS/2 table\n"); + return; + } + + //pifi->lEmbedId; + //pifi->lItalicAngle; + //pifi->lCharBias; + //pifi->jWinCharSet; + pifi->jWinPitchAndFamily &= 3; + pifi->jWinPitchAndFamily |= OtfGetWinFamily(pOs2->jClassId, pOs2->jSubClassId); + pifi->usWinWeight = SWAPW(pOs2->usWeightClass); + //pifi->flInfo; + pifi->fsSelection = SWAPW(pOs2->fsSelection); + pifi->fsType = SWAPW(pOs2->fsType); + //pifi->fwdUnitsPerEm; + //pifi->fwdLowestPPEm; + pifi->fwdWinAscender = SWAPW(pOs2->usWinAscent); + pifi->fwdWinDescender = SWAPW(pOs2->usWinDescent); + //pifi->fwdMacAscender; + //pifi->fwdMacDescender; + //pifi->fwdMacLineGap; + pifi->fwdTypoAscender = SWAPW(pOs2->sTypoAscender); + pifi->fwdTypoDescender = SWAPW(pOs2->sTypoDescender); + pifi->fwdTypoLineGap = SWAPW(pOs2->sTypoLineGap); + pifi->fwdAveCharWidth = SWAPW(pOs2->xAvgCharWidth); + //pifi->fwdMaxCharInc; + pifi->fwdCapHeight = SWAPW(pOs2->sCapHeight); + pifi->fwdXHeight = SWAPW(pOs2->sxHeight); + pifi->fwdSubscriptXSize = SWAPW(pOs2->ySubscriptXSize); + pifi->fwdSubscriptYSize = SWAPW(pOs2->ySubscriptYSize); + pifi->fwdSubscriptXOffset = SWAPW(pOs2->ySubscriptXOffset); + pifi->fwdSubscriptYOffset = SWAPW(pOs2->ySubscriptYOffset); + pifi->fwdSuperscriptXSize = SWAPW(pOs2->ySuperscriptXSize); + pifi->fwdSuperscriptYSize = SWAPW(pOs2->ySuperscriptYSize); + pifi->fwdSuperscriptXOffset = SWAPW(pOs2->ySuperscriptXOffset); + pifi->fwdSuperscriptYOffset = SWAPW(pOs2->ySuperscriptYOffset); + //pifi->fwdUnderscoreSize; + //pifi->fwdUnderscorePosition; + pifi->fwdStrikeoutSize = SWAPW(pOs2->yStrikeoutSize); + pifi->fwdStrikeoutPosition = SWAPW(pOs2->yStrikeoutPosition); + pifi->wcFirstChar = SWAPW(pOs2->usFirstCharIndex); + pifi->wcLastChar = SWAPW(pOs2->usLastCharIndex); + pifi->wcDefaultChar = SWAPW(pOs2->usDefaultChar); + pifi->wcBreakChar = SWAPW(pOs2->usBreakChar); + //pifi->chFirstChar = (CHAR)pifi->wcFirstChar; // FIXME: convert + //pifi->chLastChar = (CHAR)pifi->wcLastChar; + pifi->chDefaultChar = (CHAR)pifi->wcDefaultChar; + pifi->chBreakChar = (CHAR)pifi->wcBreakChar; + //pifi->ptlBaseline; + //pifi->ptlAspect; + //pifi->ptlCaret; + //pifi->rclFontBox; + *(DWORD*)pifi->achVendId = *(DWORD*)pOs2->achVendID; + //pifi->cKerningPairs; + //pifi->ulPanoseCulture; + pifi->panose = *(PANOSE*)pOs2->panose; +} + Propchange: branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/opentype.c ------------------------------------------------------------------------------ svn:eol-style = native Modified: branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/rosglue.c URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/GdiFontDriver/drivers…
============================================================================== --- branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/rosglue.c [iso-8859-1] (original) +++ branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/rosglue.c [iso-8859-1] Wed May 4 19:48:29 2011 @@ -29,7 +29,7 @@ va_list args; va_start(args, Format); - EngDebugPrint("ft2: ", (PCHAR)Format, args); + EngDebugPrint("ftfd: ", (PCHAR)Format, args); va_end(args); return 0; } Added: branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/todo.txt URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/GdiFontDriver/drivers…
============================================================================== --- branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/todo.txt (added) +++ branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/todo.txt [iso-8859-1] Wed May 4 19:48:29 2011 @@ -1,0 +1,57 @@ + +Public interface: +------------------ +- FtfdEnableDriver: 100% done +- FtfdEnablePDEV: 100% done +- FtfdCompletePDEV: 100% done +- FtfdDisablePDEV: 100% done +- FtfdEscape: unimplemented, probably unneccessary +- FtfdLoadFontFile: 90% done + - handle DESIGNVECTOR +- FtfdQueryFont: 70% done, depends on FtfdInitIfiMetrics +- FtfdQueryFontTree: 70% done, depends on FtfdInitGlyphSet and FtfdInitKerningPairs +- FtfdUnloadFontFile: 100% done, depends on FtfdDestroyFace +- FtfdQueryFontFile: 50% + - implement QFF_DESCRIPTION, unimportant +- FtfdQueryFontCaps: 100% done +- FtfdQueryTrueTypeTable: unimplemented +- FtfdGetTrueTypeFile: unimplemented + +- FtfdQueryFontData: 10%, depends on FtfdLoadGlyph + - QFD_MAXEXTENTS: dependes on FtfdQueryMaxExtents + - QFD_GLYPHANDBITMAP: depends on FtfdQueryGlyphData, FtfdQueryGlyphBits + - QFD_GLYPHANDOUTLINE: depends on FtfdQueryGlyphData, FtfdQueryGlyphOutline + - provide an outline (not neccessary) + - QFD_TT_GRAY1_BITMAP +- FtfdQueryGlyphAttrs: unimplemented, later +- FtfdQueryAdvanceWidths: 90% done + - check possibility of FT_ADVANCE_FLAG_FAST_ONLY +- FtfdQueryTrueTypeOutline: unimplemented +- FtfdFontManagement: unimplemented, unneccessary +- FtfdDestroyFont: unimplemented, later + +internal interface +------------------- +- FtfdInitIfiMetrics: 70% done + - handle other font types then TTF/OTF + - fix fwdLowestPPEm, fwdMacLineGap, ptlBaseline, ptlAspect, ptlCaret + - cKerningPairs, ulPanoseCulture + - check fwdMacAscender, fwdMacDescender + +- FtfdInitGlyphSet: 100% done +- FtfdInitKerningPairs: unimplemented, later +- FtfdDestroyFace: 100% done + +- FtfdCreateFontInstance: 80% + - handle XFORM (create a matrix and set freetype xform) +- FtfdGetFontInstance: 100% done +- FtfdQueryMaxExtents: 10% done + +- FtfdLoadGlyph: 80% done + - hande accelerator flags for bitmap / outline +- FtfdQueryGlyphData: 50% done + - handle vertical layout + - handle fxInkTop, fxInkBottom, ptqD + +- FtfdQueryGlyphBits: 5% +- FtfdQueryGlyphOutline: unimplemented Propchange: branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/todo.txt ------------------------------------------------------------------------------ svn:eol-style = native
13 years, 6 months
1
0
0
0
[pschweitzer] 51578: [DESK] Fix & complete French translation
by pschweitzer@svn.reactos.org
Author: pschweitzer Date: Wed May 4 17:33:08 2011 New Revision: 51578 URL:
http://svn.reactos.org/svn/reactos?rev=51578&view=rev
Log: [DESK] Fix & complete French translation Modified: trunk/reactos/dll/cpl/desk/lang/fr-FR.rc Modified: trunk/reactos/dll/cpl/desk/lang/fr-FR.rc URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/desk/lang/fr-FR.rc…
============================================================================== --- trunk/reactos/dll/cpl/desk/lang/fr-FR.rc [iso-8859-1] (original) +++ trunk/reactos/dll/cpl/desk/lang/fr-FR.rc [iso-8859-1] Wed May 4 17:33:08 2011 @@ -56,7 +56,7 @@ WS_VISIBLE | WS_BORDER, 7, 7, 232, 120 LTEXT "Modèle de couleurs", IDC_STATIC, 7, 140, 64, 7 COMBOBOX IDC_APPEARANCE_UI_ITEM, 7, 169, 120, 54, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - PUSHBUTTON "&Effects...", IDC_APPEARANCE_EFFECTS, 182, 150, 56, 15 + PUSHBUTTON "&Effets...", IDC_APPEARANCE_EFFECTS, 182, 150, 56, 15 PUSHBUTTON "Avancé", IDC_APPEARANCE_ADVANCED, 182, 170, 56, 15 END @@ -101,22 +101,22 @@ IDD_EFFAPPEARANCE DIALOGEX DISCARDABLE 0, 0, 340, 185 STYLE DS_SHELLFONT | DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU EXSTYLE WS_EX_DLGMODALFRAME | WS_EX_WINDOWEDGE -CAPTION "Effects" -FONT 8, "MS Shell Dlg" -BEGIN - CONTROL "&Utilisez l'effet de transition suivant pour les menus et les bulles d'aides:",IDC_EFFAPPEARANCE_ANIMATION,"button", +CAPTION "Effets" +FONT 8, "MS Shell Dlg" +BEGIN + CONTROL "&Utiliser l'effet de transition suivant pour les menus et les bulles d'aides :",IDC_EFFAPPEARANCE_ANIMATION,"button", BS_AUTOCHECKBOX | WS_TABSTOP, 10, 5, 330, 19 COMBOBOX IDC_EFFAPPEARANCE_ANIMATIONTYPE, 20, 25, 80, 19 , CBS_DROPDOWNLIST | CBS_HASSTRINGS | WS_CHILD | WS_VSCROLL | WS_TABSTOP - CONTROL "U&tilisez la méthode suivante pour aplanir les bords des polices d'écran:",IDC_EFFAPPEARANCE_SMOOTHING,"button", + CONTROL "U&tiliser la méthode suivante pour lisser les bords des polices d'écran :",IDC_EFFAPPEARANCE_SMOOTHING,"button", BS_AUTOCHECKBOX | WS_TABSTOP | WS_DISABLED, 10, 42, 330, 19 COMBOBOX IDC_EFFAPPEARANCE_SMOOTHINGTYPE, 20, 62, 80, 19 , CBS_DROPDOWNLIST | CBS_HASSTRINGS | CBS_SORT | WS_VSCROLL | WS_TABSTOP | WS_DISABLED CONTROL "Uti&liser de grandes icones",IDC_EFFAPPEARANCE_LARGEICONS,"button", BS_AUTOCHECKBOX | WS_TABSTOP | WS_DISABLED, 10, 80, 330, 19 - CONTROL "&Montrer ombrage sous les menus",IDC_EFFAPPEARANCE_SETDROPSHADOW,"button", + CONTROL "&Montrer les ombres sous les menus",IDC_EFFAPPEARANCE_SETDROPSHADOW,"button", BS_AUTOCHECKBOX | WS_TABSTOP | WS_DISABLED, 10, 95, 330, 19 - CONTROL "Montrer contenu des fenêtres lorsqu'elles sont bougés",IDC_EFFAPPEARANCE_DRAGFULLWINDOWS,"button", + CONTROL "Montrer le contenu des fenêtres lorsqu'elles sont bougées",IDC_EFFAPPEARANCE_DRAGFULLWINDOWS,"button", BS_AUTOCHECKBOX | WS_TABSTOP, 10, 110, 330, 19 - CONTROL "&Cacher les lettres soulignées pour la navigation du clavier jusqu'à ce que j'appuie sur la touche Alt",IDC_EFFAPPEARANCE_KEYBOARDCUES,"button", + CONTROL "&Cacher les lettres soulignées pour la navigation au clavier jusqu'à ce que j'appuie sur la touche Alt",IDC_EFFAPPEARANCE_KEYBOARDCUES,"button", BS_AUTOCHECKBOX | WS_TABSTOP, 10, 125, 330, 19 PUSHBUTTON "Annuler", IDCANCEL, 281, 165, 50, 14 DEFPUSHBUTTON "Accepter", IDOK, 227, 165, 50, 14 @@ -181,8 +181,8 @@ STRINGTABLE DISCARDABLE BEGIN - IDS_SLIDEEFFECT "Slide effect" - IDS_FADEEFFECT "Fade effect" + IDS_SLIDEEFFECT "Effet de glissement" + IDS_FADEEFFECT "Effet de fondu" END STRINGTABLE DISCARDABLE @@ -263,6 +263,6 @@ STRINGTABLE DISCARDABLE BEGIN IDS_DISPLAY_SETTINGS "Paramètres d'affichage" - IDS_APPLY_FAILED "Echec lors de l'application des nouveaux paramètres..." + IDS_APPLY_FAILED "Échec lors de l'application des nouveaux paramètres..." IDS_APPLY_NEEDS_RESTART "Vous devez redémarrer votre ordinateur pour appliquer les modifications." END
13 years, 6 months
1
0
0
0
[ilardig] 51577: [LIBXML2] - Update to version 2.7.8. Patch by Carlo Bramini. - Installed and booted successfully to the desktop. Tested abiword 2.6.4 and FF 2.0.0.20. See issue #4988 for more deta...
by ilardig@svn.reactos.org
Author: ilardig Date: Wed May 4 15:48:34 2011 New Revision: 51577 URL:
http://svn.reactos.org/svn/reactos?rev=51577&view=rev
Log: [LIBXML2] - Update to version 2.7.8. Patch by Carlo Bramini. - Installed and booted successfully to the desktop. Tested abiword 2.6.4 and FF 2.0.0.20. See issue #4988 for more details. Modified: trunk/reactos/include/reactos/libs/libxml/HTMLparser.h trunk/reactos/include/reactos/libs/libxml/Makefile.am trunk/reactos/include/reactos/libs/libxml/Makefile.in trunk/reactos/include/reactos/libs/libxml/encoding.h trunk/reactos/include/reactos/libs/libxml/nanoftp.h trunk/reactos/include/reactos/libs/libxml/parser.h trunk/reactos/include/reactos/libs/libxml/xmlsave.h trunk/reactos/include/reactos/libs/libxml/xmlversion.h trunk/reactos/include/reactos/libs/libxml/xmlversion.h.in trunk/reactos/lib/3rdparty/libxml2/HTMLparser.c trunk/reactos/lib/3rdparty/libxml2/Makefile.am trunk/reactos/lib/3rdparty/libxml2/Makefile.in trunk/reactos/lib/3rdparty/libxml2/SAX2.c trunk/reactos/lib/3rdparty/libxml2/catalog.c trunk/reactos/lib/3rdparty/libxml2/config.h.in trunk/reactos/lib/3rdparty/libxml2/configure trunk/reactos/lib/3rdparty/libxml2/configure.in trunk/reactos/lib/3rdparty/libxml2/debugXML.c trunk/reactos/lib/3rdparty/libxml2/encoding.c trunk/reactos/lib/3rdparty/libxml2/include/Makefile.in trunk/reactos/lib/3rdparty/libxml2/libxml2.spec trunk/reactos/lib/3rdparty/libxml2/ltmain.sh trunk/reactos/lib/3rdparty/libxml2/nanoftp.c trunk/reactos/lib/3rdparty/libxml2/nanohttp.c trunk/reactos/lib/3rdparty/libxml2/parser.c trunk/reactos/lib/3rdparty/libxml2/testapi.c trunk/reactos/lib/3rdparty/libxml2/threads.c trunk/reactos/lib/3rdparty/libxml2/tree.c trunk/reactos/lib/3rdparty/libxml2/uri.c trunk/reactos/lib/3rdparty/libxml2/xmllint.c trunk/reactos/lib/3rdparty/libxml2/xmlreader.c trunk/reactos/lib/3rdparty/libxml2/xmlsave.c trunk/reactos/lib/3rdparty/libxml2/xmlschemas.c trunk/reactos/lib/3rdparty/libxml2/xmlschemastypes.c trunk/reactos/lib/3rdparty/libxml2/xpath.c [This mail would be too long, it was shortened to contain the URLs only.] Modified: trunk/reactos/include/reactos/libs/libxml/HTMLparser.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/libxm…
Modified: trunk/reactos/include/reactos/libs/libxml/Makefile.am URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/libxm…
Modified: trunk/reactos/include/reactos/libs/libxml/Makefile.in URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/libxm…
Modified: trunk/reactos/include/reactos/libs/libxml/encoding.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/libxm…
Modified: trunk/reactos/include/reactos/libs/libxml/nanoftp.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/libxm…
Modified: trunk/reactos/include/reactos/libs/libxml/parser.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/libxm…
Modified: trunk/reactos/include/reactos/libs/libxml/xmlsave.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/libxm…
Modified: trunk/reactos/include/reactos/libs/libxml/xmlversion.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/libxm…
Modified: trunk/reactos/include/reactos/libs/libxml/xmlversion.h.in URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/libxm…
Modified: trunk/reactos/lib/3rdparty/libxml2/HTMLparser.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/3rdparty/libxml2/HTMLp…
Modified: trunk/reactos/lib/3rdparty/libxml2/Makefile.am URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/3rdparty/libxml2/Makef…
Modified: trunk/reactos/lib/3rdparty/libxml2/Makefile.in URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/3rdparty/libxml2/Makef…
Modified: trunk/reactos/lib/3rdparty/libxml2/SAX2.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/3rdparty/libxml2/SAX2.…
Modified: trunk/reactos/lib/3rdparty/libxml2/catalog.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/3rdparty/libxml2/catal…
Modified: trunk/reactos/lib/3rdparty/libxml2/config.h.in URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/3rdparty/libxml2/confi…
Modified: trunk/reactos/lib/3rdparty/libxml2/configure URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/3rdparty/libxml2/confi…
Modified: trunk/reactos/lib/3rdparty/libxml2/configure.in URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/3rdparty/libxml2/confi…
Modified: trunk/reactos/lib/3rdparty/libxml2/debugXML.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/3rdparty/libxml2/debug…
Modified: trunk/reactos/lib/3rdparty/libxml2/encoding.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/3rdparty/libxml2/encod…
Modified: trunk/reactos/lib/3rdparty/libxml2/include/Makefile.in URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/3rdparty/libxml2/inclu…
Modified: trunk/reactos/lib/3rdparty/libxml2/libxml2.spec URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/3rdparty/libxml2/libxm…
Modified: trunk/reactos/lib/3rdparty/libxml2/ltmain.sh URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/3rdparty/libxml2/ltmai…
Modified: trunk/reactos/lib/3rdparty/libxml2/nanoftp.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/3rdparty/libxml2/nanof…
Modified: trunk/reactos/lib/3rdparty/libxml2/nanohttp.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/3rdparty/libxml2/nanoh…
Modified: trunk/reactos/lib/3rdparty/libxml2/parser.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/3rdparty/libxml2/parse…
Modified: trunk/reactos/lib/3rdparty/libxml2/testapi.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/3rdparty/libxml2/testa…
Modified: trunk/reactos/lib/3rdparty/libxml2/threads.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/3rdparty/libxml2/threa…
Modified: trunk/reactos/lib/3rdparty/libxml2/tree.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/3rdparty/libxml2/tree.…
Modified: trunk/reactos/lib/3rdparty/libxml2/uri.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/3rdparty/libxml2/uri.c…
Modified: trunk/reactos/lib/3rdparty/libxml2/xmllint.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/3rdparty/libxml2/xmlli…
Modified: trunk/reactos/lib/3rdparty/libxml2/xmlreader.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/3rdparty/libxml2/xmlre…
Modified: trunk/reactos/lib/3rdparty/libxml2/xmlsave.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/3rdparty/libxml2/xmlsa…
Modified: trunk/reactos/lib/3rdparty/libxml2/xmlschemas.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/3rdparty/libxml2/xmlsc…
Modified: trunk/reactos/lib/3rdparty/libxml2/xmlschemastypes.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/3rdparty/libxml2/xmlsc…
Modified: trunk/reactos/lib/3rdparty/libxml2/xpath.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/3rdparty/libxml2/xpath…
13 years, 6 months
1
0
0
0
[mjmartin] 51576: [USBHUB_NEW] - Change parameter name for DeviceObject in functions to clearify which device object is to received IRPs. - Fix a typo in GetPortStatusAndChange that caused the func...
by mjmartin@svn.reactos.org
Author: mjmartin Date: Wed May 4 12:58:42 2011 New Revision: 51576 URL:
http://svn.reactos.org/svn/reactos?rev=51576&view=rev
Log: [USBHUB_NEW] - Change parameter name for DeviceObject in functions to clearify which device object is to received IRPs. - Fix a typo in GetPortStatusAndChange that caused the function to return nothing for status and change. - Call QueryStatusChangeEndpoint to send the first SCE request in Query Bus Releations. - Complete implementation of StatusChangeEndpointCompletion. Queue a work item for DeviceStatusChangeThread, which will be used to initialize the usb device and create related device objects. Modified: branches/usb-bringup/drivers/usb/usbhub_new/fdo.c branches/usb-bringup/drivers/usb/usbhub_new/usbhub.h Modified: branches/usb-bringup/drivers/usb/usbhub_new/fdo.c URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/usb/usbhub_…
============================================================================== --- branches/usb-bringup/drivers/usb/usbhub_new/fdo.c [iso-8859-1] (original) +++ branches/usb-bringup/drivers/usb/usbhub_new/fdo.c [iso-8859-1] Wed May 4 12:58:42 2011 @@ -1,4 +1,4 @@ -/* +/* * PROJECT: ReactOS Universal Serial Bus Hub Driver * LICENSE: GPL - See COPYING in the top level directory * FILE: drivers/usb/usbhub/fdo.c @@ -14,8 +14,12 @@ #include "usbhub.h" NTSTATUS +QueryStatusChangeEndpoint( + IN PDEVICE_OBJECT DeviceObject); + +NTSTATUS SubmitRequestToRootHub( - IN PDEVICE_OBJECT DeviceObject, + IN PDEVICE_OBJECT RootHubDeviceObject, IN ULONG IoControlCode, OUT PVOID OutParameter1, OUT PVOID OutParameter2) @@ -32,7 +36,7 @@ // Build Control Request // Irp = IoBuildDeviceIoControlRequest(IoControlCode, - DeviceObject, + RootHubDeviceObject, NULL, 0, NULL, 0, TRUE, @@ -61,7 +65,7 @@ // // Call RootHub // - Status = IoCallDriver(DeviceObject, Irp); + Status = IoCallDriver(RootHubDeviceObject, Irp); if (Status == STATUS_PENDING) { @@ -73,172 +77,12 @@ return Status; } -NTSTATUS -StatusChangeEndpointCompletion( - PDEVICE_OBJECT DeviceObject, - PIRP Irp, - PVOID Context) -{ - PHUB_DEVICE_EXTENSION HubDeviceExtension; - LONG i; - - HubDeviceExtension = (PHUB_DEVICE_EXTENSION)((PDEVICE_OBJECT)Context)->DeviceExtension; - - // - // Determine which port has changed - // - for (i=0; i < HubDeviceExtension->UsbExtHubInfo.NumberOfPorts; i++) - { - DPRINT1("Port %x HubDeviceExtension->PortStatus %x\n",i+1, HubDeviceExtension->PortStatusChange[i].Status); - DPRINT1("Port %x HubDeviceExtension->PortChange %x\n",i+1, HubDeviceExtension->PortStatusChange[i].Change); - // - // FIXME: Call function to check port before creating device object for it - // - } - - // - // Free the Irp and return more processing required so the IO Manger doesnât try to free it - // - IoFreeIrp(Irp); - - return STATUS_MORE_PROCESSING_REQUIRED; -} - -NTSTATUS -QueryStatusChangeEndpoint( - PDEVICE_OBJECT DeviceObject) -{ - NTSTATUS Status; - PIO_STACK_LOCATION Stack; - PHUB_DEVICE_EXTENSION HubDeviceExtension; - - HubDeviceExtension = (PHUB_DEVICE_EXTENSION)DeviceObject->DeviceExtension; - - HubDeviceExtension->PendingSCEUrb; - RtlZeroMemory(&HubDeviceExtension->PendingSCEUrb, - sizeof(URB)); - - // - // Create URB for Status Change Endpoint request - // - UsbBuildInterruptOrBulkTransferRequest(&HubDeviceExtension->PendingSCEUrb, - sizeof(struct _URB_BULK_OR_INTERRUPT_TRANSFER), - HubDeviceExtension->PipeHandle, - HubDeviceExtension->PortStatusChange, - NULL, - sizeof(USHORT) * 2 * HubDeviceExtension->UsbExtHubInfo.NumberOfPorts, - USBD_TRANSFER_DIRECTION_IN | USBD_SHORT_TRANSFER_OK, - NULL); - - // - // Set the device handle to null for roothub - // - HubDeviceExtension->PendingSCEUrb.UrbHeader.UsbdDeviceHandle = NULL; - - // - // Allocate an Irp - // - HubDeviceExtension->PendingSCEIrp = IoAllocateIrp(HubDeviceExtension->RootHubPhysicalDeviceObject->StackSize, - FALSE); - - if (!HubDeviceExtension->PendingSCEIrp) - { - DPRINT1("USBHUB: Failed to allocate IRP for SCE request!\n"); - return STATUS_INSUFFICIENT_RESOURCES; - } - - // - // Initialize the IRP - // - HubDeviceExtension->PendingSCEIrp->IoStatus.Status = STATUS_NOT_SUPPORTED; - HubDeviceExtension->PendingSCEIrp->IoStatus.Information = 0; - HubDeviceExtension->PendingSCEIrp->Flags = 0; - HubDeviceExtension->PendingSCEIrp->UserBuffer = NULL; - - // - // Get the Next Stack Location and Initialize it - // - Stack = IoGetNextIrpStackLocation(HubDeviceExtension->PendingSCEIrp); - Stack->DeviceObject = HubDeviceExtension->RootHubPhysicalDeviceObject; - Stack->Parameters.Others.Argument1 = &HubDeviceExtension->PendingSCEUrb; - Stack->Parameters.Others.Argument2 = NULL; - Stack->MajorFunction = IRP_MJ_INTERNAL_DEVICE_CONTROL; - Stack->Parameters.DeviceIoControl.IoControlCode = IOCTL_INTERNAL_USB_SUBMIT_URB; - - // - // Set the completion routine for when device is connected to root hub - // - IoSetCompletionRoutine(HubDeviceExtension->PendingSCEIrp, - (PIO_COMPLETION_ROUTINE) StatusChangeEndpointCompletion, - DeviceObject, - TRUE, - TRUE, - TRUE); - - Status = IoCallDriver(HubDeviceExtension->RootHubPhysicalDeviceObject, HubDeviceExtension->PendingSCEIrp); - DPRINT1("SCE request status %x\n", Status); - - return STATUS_PENDING; -} - -NTSTATUS -QueryInterface( - IN PDEVICE_OBJECT DeviceObject, - IN CONST GUID InterfaceType, - IN LONG Size, - IN LONG Version, - OUT PVOID Interface) -{ - KEVENT Event; - PIRP Irp; - IO_STATUS_BLOCK IoStatus; - NTSTATUS Status; - PIO_STACK_LOCATION Stack = NULL; - - // - // Initialize the Event used to wait for Irp completion - // - KeInitializeEvent(&Event, NotificationEvent, FALSE); - - // - // Build Control Request - // - Irp = IoBuildSynchronousFsdRequest(IRP_MJ_PNP, - DeviceObject, - NULL, - 0, - NULL, - &Event, - &IoStatus); - - // - // Get Next Stack Location and Initialize it. - // - Stack = IoGetNextIrpStackLocation(Irp); - Stack->MinorFunction = IRP_MN_QUERY_INTERFACE; - Stack->Parameters.QueryInterface.InterfaceType= &InterfaceType;//USB_BUS_INTERFACE_HUB_GUID; - Stack->Parameters.QueryInterface.Size = Size; - Stack->Parameters.QueryInterface.Version = Version; - Stack->Parameters.QueryInterface.Interface = Interface; - Stack->Parameters.QueryInterface.InterfaceSpecificData = NULL; - - Status = IoCallDriver(DeviceObject, Irp); - - if (Status == STATUS_PENDING) - { - DPRINT("Operation pending\n"); - KeWaitForSingleObject(&Event, Suspended, KernelMode, FALSE, NULL); - Status = IoStatus.Status; - } - - return Status; -} - -NTSTATUS + +NTSTATUS GetPortStatusAndChange( - IN PDEVICE_OBJECT DeviceObject, + IN PDEVICE_OBJECT RootHubDeviceObject, IN ULONG PortId, - OUT PORT_STATUS_CHANGE *StatusChange) + OUT PPORT_STATUS_CHANGE StatusChange) { NTSTATUS Status; PURB Urb; @@ -269,7 +113,7 @@ USB_REQUEST_GET_STATUS, 0, PortId, - &StatusChange, + StatusChange, 0, sizeof(PORT_STATUS_CHANGE), 0); @@ -277,7 +121,7 @@ // // Query the Root Hub // - Status = SubmitRequestToRootHub(DeviceObject, IOCTL_INTERNAL_USB_SUBMIT_URB, Urb, NULL); + Status = SubmitRequestToRootHub(RootHubDeviceObject, IOCTL_INTERNAL_USB_SUBMIT_URB, Urb, NULL); // // Free URB @@ -289,9 +133,9 @@ NTSTATUS SetPortFeature( - PDEVICE_OBJECT DeviceObject, - ULONG PortId, - ULONG Feature) + IN PDEVICE_OBJECT RootHubDeviceObject, + IN ULONG PortId, + IN ULONG Feature) { NTSTATUS Status; PURB Urb; @@ -329,7 +173,7 @@ // // Query the Root Hub // - Status = SubmitRequestToRootHub(DeviceObject, IOCTL_INTERNAL_USB_SUBMIT_URB, Urb, NULL); + Status = SubmitRequestToRootHub(RootHubDeviceObject, IOCTL_INTERNAL_USB_SUBMIT_URB, Urb, NULL); // // Free URB @@ -341,9 +185,9 @@ NTSTATUS ClearPortFeature( - PDEVICE_OBJECT DeviceObject, - ULONG PortId, - ULONG Feature) + IN PDEVICE_OBJECT RootHubDeviceObject, + IN ULONG PortId, + IN ULONG Feature) { NTSTATUS Status; PURB Urb; @@ -381,7 +225,7 @@ // // Query the Root Hub // - Status = SubmitRequestToRootHub(DeviceObject, IOCTL_INTERNAL_USB_SUBMIT_URB, Urb, NULL); + Status = SubmitRequestToRootHub(RootHubDeviceObject, IOCTL_INTERNAL_USB_SUBMIT_URB, Urb, NULL); // // Free URB @@ -391,14 +235,273 @@ return Status; } +VOID NTAPI +DeviceStatusChangeThread( + IN PVOID Context) +{ + NTSTATUS Status; + PDEVICE_OBJECT DeviceObject; + PHUB_DEVICE_EXTENSION HubDeviceExtension; + PWORK_ITEM_DATA WorkItemData; + PORT_STATUS_CHANGE PortStatus; + LONG PortId, i; + + WorkItemData = (PWORK_ITEM_DATA)Context; + DeviceObject = (PDEVICE_OBJECT)WorkItemData->Context; + HubDeviceExtension = (PHUB_DEVICE_EXTENSION)DeviceObject->DeviceExtension; + + // + // Itterate all ports + // + for (PortId = 1; PortId <= HubDeviceExtension->UsbExtHubInfo.NumberOfPorts; PortId++) + { + PortStatus.Change = 0; + PortStatus.Status = 0; + // + // Get Port Status + // + Status = GetPortStatusAndChange(HubDeviceExtension->RootHubPhysicalDeviceObject, PortId, &PortStatus); + if (!NT_SUCCESS(Status)) + { + DPRINT1("Failed to get port status for port %d, Status %x\n", PortId, Status); + // FIXME: Do we really want to halt further SCE requests? + return; + } + + // + // Check for new device connection + // + if (PortStatus.Change == USB_PORT_STATUS_CONNECT) + { + // + // Clear Connection Status + // + Status = ClearPortFeature(HubDeviceExtension->RootHubPhysicalDeviceObject, PortId, C_PORT_CONNECTION); + if (!NT_SUCCESS(Status)) + { + DPRINT1("Failed to clear connection change for port %d\n", PortId); + // FIXME: Do we really want to halt further SCE requests? + return; + } + + // + // Get Port Status and ensure it updated + // + Status = GetPortStatusAndChange(HubDeviceExtension->RootHubPhysicalDeviceObject, PortId, &PortStatus); + if (!NT_SUCCESS(Status)) + { + DPRINT1("Failed to get port status for port %d, Status %x\n", PortId, Status); + // FIXME: Do we really want to halt further SCE requests? + return; + } + + if (PortStatus.Change != 0) + { + DPRINT1("Port %d did not clear Connection Change!\n"); + // FIXME: Do we really want to halt further SCE requests? + return; + } + + // + // FIXME: Create the device object and enable the port + // + //CreateUsbChildDeviceObject + } + } + + // + // Send another SCE Request + // + QueryStatusChangeEndpoint(DeviceObject); + + ExFreePool(WorkItemData); +} + +NTSTATUS +StatusChangeEndpointCompletion( + IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp, + IN PVOID Context) +{ + PDEVICE_OBJECT RealDeviceObject; + PHUB_DEVICE_EXTENSION HubDeviceExtension; + PWORK_ITEM_DATA WorkItemData; + LONG i; + + RealDeviceObject = (PDEVICE_OBJECT)Context; + HubDeviceExtension = (PHUB_DEVICE_EXTENSION)RealDeviceObject->DeviceExtension; + + // + // Determine which port has changed + // + for (i=0; i < HubDeviceExtension->UsbExtHubInfo.NumberOfPorts; i++) + { + DPRINT1("Port %x HubDeviceExtension->PortStatus %x\n",i+1, HubDeviceExtension->PortStatusChange[i].Status); + DPRINT1("Port %x HubDeviceExtension->PortChange %x\n",i+1, HubDeviceExtension->PortStatusChange[i].Change); + } + + // + // Free the Irp and return more processing required so the IO Manger doesnât try to free it + // + IoFreeIrp(Irp); + + // + // Create and initialize work item data + // + WorkItemData = ExAllocatePoolWithTag(NonPagedPool, sizeof(WORK_ITEM_DATA), USB_HUB_TAG); + if (!WorkItemData) + { + DPRINT1("Failed to allocate memory!n"); + return STATUS_INSUFFICIENT_RESOURCES; + } + + WorkItemData->Context = RealDeviceObject; + ExInitializeWorkItem(&WorkItemData->WorkItem, (PWORKER_THREAD_ROUTINE)DeviceStatusChangeThread, (PVOID)WorkItemData); + + // + // Queue the work item to handle initializing the device + // + ExQueueWorkItem(&WorkItemData->WorkItem, DelayedWorkQueue); + + return STATUS_MORE_PROCESSING_REQUIRED; +} + +NTSTATUS +QueryStatusChangeEndpoint( + IN PDEVICE_OBJECT DeviceObject) +{ + NTSTATUS Status; + PIO_STACK_LOCATION Stack; + PHUB_DEVICE_EXTENSION HubDeviceExtension; + + HubDeviceExtension = (PHUB_DEVICE_EXTENSION)DeviceObject->DeviceExtension; + + // + // Initialize URB for Status Change Endpoint request + // + UsbBuildInterruptOrBulkTransferRequest(&HubDeviceExtension->PendingSCEUrb, + sizeof(struct _URB_BULK_OR_INTERRUPT_TRANSFER), + HubDeviceExtension->PipeHandle, + HubDeviceExtension->PortStatusChange, + NULL, + sizeof(USHORT) * 2 * HubDeviceExtension->UsbExtHubInfo.NumberOfPorts, + USBD_TRANSFER_DIRECTION_IN | USBD_SHORT_TRANSFER_OK, + NULL); + + // + // Set the device handle to null for roothub + // + HubDeviceExtension->PendingSCEUrb.UrbHeader.UsbdDeviceHandle = NULL; + + // + // Allocate an Irp + // + HubDeviceExtension->PendingSCEIrp = IoAllocateIrp(HubDeviceExtension->RootHubPhysicalDeviceObject->StackSize, + FALSE); + + if (!HubDeviceExtension->PendingSCEIrp) + { + DPRINT1("USBHUB: Failed to allocate IRP for SCE request!\n"); + return STATUS_INSUFFICIENT_RESOURCES; + } + + // + // Initialize the IRP + // + HubDeviceExtension->PendingSCEIrp->IoStatus.Status = STATUS_NOT_SUPPORTED; + HubDeviceExtension->PendingSCEIrp->IoStatus.Information = 0; + HubDeviceExtension->PendingSCEIrp->Flags = 0; + HubDeviceExtension->PendingSCEIrp->UserBuffer = NULL; + + // + // Get the Next Stack Location and Initialize it + // + Stack = IoGetNextIrpStackLocation(HubDeviceExtension->PendingSCEIrp); + Stack->DeviceObject = HubDeviceExtension->RootHubPhysicalDeviceObject; + Stack->Parameters.Others.Argument1 = &HubDeviceExtension->PendingSCEUrb; + Stack->Parameters.Others.Argument2 = NULL; + Stack->MajorFunction = IRP_MJ_INTERNAL_DEVICE_CONTROL; + Stack->Parameters.DeviceIoControl.IoControlCode = IOCTL_INTERNAL_USB_SUBMIT_URB; + + // + // Set the completion routine for when device is connected to root hub + // + IoSetCompletionRoutine(HubDeviceExtension->PendingSCEIrp, + (PIO_COMPLETION_ROUTINE) StatusChangeEndpointCompletion, + DeviceObject, + TRUE, + TRUE, + TRUE); + + // + // Send to RootHub + // + Status = IoCallDriver(HubDeviceExtension->RootHubPhysicalDeviceObject, HubDeviceExtension->PendingSCEIrp); + + return STATUS_PENDING; +} + +NTSTATUS +QueryInterface( + IN PDEVICE_OBJECT DeviceObject, + IN CONST GUID InterfaceType, + IN LONG Size, + IN LONG Version, + OUT PVOID Interface) +{ + KEVENT Event; + PIRP Irp; + IO_STATUS_BLOCK IoStatus; + NTSTATUS Status; + PIO_STACK_LOCATION Stack = NULL; + + // + // Initialize the Event used to wait for Irp completion + // + KeInitializeEvent(&Event, NotificationEvent, FALSE); + + // + // Build Control Request + // + Irp = IoBuildSynchronousFsdRequest(IRP_MJ_PNP, + DeviceObject, + NULL, + 0, + NULL, + &Event, + &IoStatus); + + // + // Get Next Stack Location and Initialize it. + // + Stack = IoGetNextIrpStackLocation(Irp); + Stack->MinorFunction = IRP_MN_QUERY_INTERFACE; + Stack->Parameters.QueryInterface.InterfaceType= &InterfaceType;//USB_BUS_INTERFACE_HUB_GUID; + Stack->Parameters.QueryInterface.Size = Size; + Stack->Parameters.QueryInterface.Version = Version; + Stack->Parameters.QueryInterface.Interface = Interface; + Stack->Parameters.QueryInterface.InterfaceSpecificData = NULL; + + Status = IoCallDriver(DeviceObject, Irp); + + if (Status == STATUS_PENDING) + { + DPRINT("Operation pending\n"); + KeWaitForSingleObject(&Event, Suspended, KernelMode, FALSE, NULL); + Status = IoStatus.Status; + } + + return Status; +} + NTSTATUS GetUsbDeviceDescriptor( - PDEVICE_OBJECT ChildDeviceObject, - UCHAR DescriptorType, - UCHAR Index, - USHORT LangId, - PVOID TransferBuffer, - ULONG TransferBufferLength) + IN PDEVICE_OBJECT ChildDeviceObject, + IN UCHAR DescriptorType, + IN UCHAR Index, + IN USHORT LangId, + OUT PVOID TransferBuffer, + IN ULONG TransferBufferLength) { NTSTATUS Status; PURB Urb; @@ -508,7 +611,6 @@ ULONG NeededSize; HubDeviceExtension = (PHUB_DEVICE_EXTENSION)DeviceObject->DeviceExtension; - DPRINT1("Query Bus Relations\n"); // // Count the number of children @@ -554,8 +656,9 @@ *pDeviceRelations = DeviceRelations; // - // FIXME: Send the first SCE Request - // + // Send the first SCE Request + // + QueryStatusChangeEndpoint(DeviceObject); return STATUS_SUCCESS; } @@ -582,7 +685,6 @@ ULONG Result = 0; PUSB_INTERFACE_DESCRIPTOR Pid; ULONG PortId; - USBD_INTERFACE_LIST_ENTRY InterfaceList[2] = {{NULL, NULL}, {NULL, NULL}}; PURB ConfigUrb = NULL; @@ -629,7 +731,7 @@ // // Get the Hub Interface // - Status = QueryInterface(HubDeviceExtension->RootHubPhysicalDeviceObject, + Status = QueryInterface(HubDeviceExtension->RootHubPhysicalDeviceObject, USB_BUS_INTERFACE_HUB_GUID, sizeof(USB_BUS_INTERFACE_HUB_V5), 5, @@ -678,7 +780,6 @@ &HubDeviceExtension->DeviceInformation, sizeof(USB_DEVICE_INFORMATION_0), &Result); - DPRINT1("Status %x, Result 0x%08lx\n", Status, Result); DPRINT1("InformationLevel %x\n", HubDeviceExtension->DeviceInformation.InformationLevel); @@ -687,7 +788,6 @@ DPRINT1("DeviceDescriptor %x\n", HubDeviceExtension->DeviceInformation.DeviceDescriptor); DPRINT1("HubAddress %x\n", HubDeviceExtension->DeviceInformation.HubAddress); DPRINT1("NumberofPipes %x\n", HubDeviceExtension->DeviceInformation.NumberOfOpenPipes); - // // Get Root Hubs Device Descriptor @@ -746,10 +846,10 @@ DumpConfigurationDescriptor(&HubDeviceExtension->HubConfigDescriptor); Status = HubDeviceExtension->HubInterface.GetExtendedHubInformation(HubDeviceExtension->RootHubPhysicalDeviceObject, - HubDeviceExtension->RootHubPhysicalDeviceObject, - &HubDeviceExtension->UsbExtHubInfo, - sizeof(USB_EXTHUB_INFORMATION_0), - &Result); + HubDeviceExtension->RootHubPhysicalDeviceObject, + &HubDeviceExtension->UsbExtHubInfo, + sizeof(USB_EXTHUB_INFORMATION_0), + &Result); if (!NT_SUCCESS(Status)) { DPRINT1("Failed to extended hub information. Unable to determine the number of ports!\n"); @@ -764,7 +864,7 @@ UsbBuildVendorRequest(Urb, URB_FUNCTION_CLASS_DEVICE, sizeof(Urb->UrbControlVendorClassRequest), - USBD_TRANSFER_DIRECTION_IN, + USBD_TRANSFER_DIRECTION_IN | USBD_SHORT_TRANSFER_OK, 0, USB_DEVICE_CLASS_RESERVED, 0, @@ -781,6 +881,9 @@ Urb, NULL); + // + // FIXME: This is returning nothing. + // DPRINT1("bDescriptorType %x\n", HubDeviceExtension->HubDescriptor.bDescriptorType); if (!NT_SUCCESS(Status)) @@ -794,16 +897,25 @@ // Allocate memory for PortStatusChange to hold 2 USHORTs for each port on hub // HubDeviceExtension->PortStatusChange = ExAllocatePoolWithTag(NonPagedPool, - sizeof(ULONG) * HubDeviceExtension->HubDescriptor.bNumberOfPorts, + sizeof(ULONG) * HubDeviceExtension->UsbExtHubInfo.NumberOfPorts, USB_HUB_TAG); + + // + // Initialize the Hub + // + Status = HubDeviceExtension->HubInterface.Initialize20Hub(HubDeviceExtension->RootHubPhysicalDeviceObject, + HubDeviceExtension->RootHubHandle, 1); + DPRINT1("Status %x\n", Status); // // Get the first Configuration Descriptor // Pid = USBD_ParseConfigurationDescriptorEx(&HubDeviceExtension->HubConfigDescriptor, &HubDeviceExtension->HubConfigDescriptor, - -1, -1, -1, -1, -1); + -1, -1, -1, -1, -1); + ASSERT(Pid != NULL); + InterfaceList[0].InterfaceDescriptor = Pid; ConfigUrb = USBD_CreateConfigurationRequestEx(&HubDeviceExtension->HubConfigDescriptor, (PUSBD_INTERFACE_LIST_ENTRY)&InterfaceList); @@ -821,19 +933,15 @@ ExFreePool(ConfigUrb); // - // Initialize the Hub - // - Status = HubDeviceExtension->HubInterface.Initialize20Hub(HubDeviceExtension->RootHubPhysicalDeviceObject, - HubDeviceExtension->RootHubHandle, 1); - DPRINT1("Status %x\n", Status); - - // // Enable power on all ports // - for (PortId = 0; PortId < HubDeviceExtension->HubDescriptor.bNumberOfPorts; PortId++) - { - SetPortFeature(HubDeviceExtension->RootHubPhysicalDeviceObject, PortId, PORT_POWER); - } + for (PortId = 1; PortId <= HubDeviceExtension->HubDescriptor.bNumberOfPorts; PortId++) + { + Status = SetPortFeature(HubDeviceExtension->RootHubPhysicalDeviceObject, PortId, PORT_POWER); + if (!NT_SUCCESS(Status)) + DPRINT1("Failed to power on port %d\n", PortId); + } + ExFreePool(Urb); break; } @@ -859,7 +967,7 @@ } default: DPRINT1("IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_RELATIONS / Unknown type 0x%lx\n", - Stack->Parameters.QueryDeviceRelations.Type); + Stack->Parameters.QueryDeviceRelations.Type); return ForwardIrpAndForget(DeviceObject, Irp); } break; @@ -885,6 +993,7 @@ return ForwardIrpAndForget(DeviceObject, Irp); } } + Irp->IoStatus.Information = Information; Irp->IoStatus.Status = Status; IoCompleteRequest(Irp, IO_NO_INCREMENT); @@ -893,8 +1002,8 @@ NTSTATUS USBHUB_FdoHandleDeviceControl( - PDEVICE_OBJECT DeviceObject, - PIRP Irp) + IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp) { DPRINT1("FdoHandleDeviceControl\n"); UNIMPLEMENTED Modified: branches/usb-bringup/drivers/usb/usbhub_new/usbhub.h URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/usb/usbhub_…
============================================================================== --- branches/usb-bringup/drivers/usb/usbhub_new/usbhub.h [iso-8859-1] (original) +++ branches/usb-bringup/drivers/usb/usbhub_new/usbhub.h [iso-8859-1] Wed May 4 12:58:42 2011 @@ -36,6 +36,12 @@ USHORT Status; USHORT Change; } PORT_STATUS_CHANGE, *PPORT_STATUS_CHANGE; + +typedef struct _WORK_ITEM_DATA +{ + WORK_QUEUE_ITEM WorkItem; + PVOID Context; +} WORK_ITEM_DATA, *PWORK_ITEM_DATA; typedef struct {
13 years, 6 months
1
0
0
0
← Newer
1
...
42
43
44
45
46
47
48
...
52
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
Results per page:
10
25
50
100
200