ReactOS.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
List overview
Download
Ros-diffs
February 2012
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
ros-diffs@reactos.org
22 participants
577 discussions
Start a n
N
ew thread
[janderwald] 55918: [USBOHCI] - Fix msvc build
by janderwald@svn.reactos.org
Author: janderwald Date: Wed Feb 29 11:06:57 2012 New Revision: 55918 URL:
http://svn.reactos.org/svn/reactos?rev=55918&view=rev
Log: [USBOHCI] - Fix msvc build Modified: trunk/reactos/drivers/usb/usbohci/usb_request.cpp Modified: trunk/reactos/drivers/usb/usbohci/usb_request.cpp URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/usb/usbohci/usb_re…
============================================================================== --- trunk/reactos/drivers/usb/usbohci/usb_request.cpp [iso-8859-1] (original) +++ trunk/reactos/drivers/usb/usbohci/usb_request.cpp [iso-8859-1] Wed Feb 29 11:06:57 2012 @@ -42,7 +42,7 @@ // local functions ULONG InternalGetTransferType(); UCHAR InternalGetPidDirection(); - UCHAR GetDeviceAddress(); + UCHAR STDMETHODCALLTYPE GetDeviceAddress(); NTSTATUS BuildSetupPacket(); NTSTATUS BuildSetupPacketFromURB(); NTSTATUS BuildControlTransferDescriptor(POHCI_ENDPOINT_DESCRIPTOR * OutEndpointDescriptor);
12 years, 10 months
1
0
0
0
[janderwald] 55917: [USBEHCI] - Fix stack corruption found by msvc - Fix msvc build
by janderwald@svn.reactos.org
Author: janderwald Date: Wed Feb 29 10:59:48 2012 New Revision: 55917 URL:
http://svn.reactos.org/svn/reactos?rev=55917&view=rev
Log: [USBEHCI] - Fix stack corruption found by msvc - Fix msvc build Modified: trunk/reactos/drivers/usb/usbehci/usb_request.cpp Modified: trunk/reactos/drivers/usb/usbehci/usb_request.cpp URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/usb/usbehci/usb_re…
============================================================================== --- trunk/reactos/drivers/usb/usbehci/usb_request.cpp [iso-8859-1] (original) +++ trunk/reactos/drivers/usb/usbehci/usb_request.cpp [iso-8859-1] Wed Feb 29 10:59:48 2012 @@ -45,14 +45,14 @@ UCHAR InternalGetPidDirection(); NTSTATUS BuildControlTransferQueueHead(PQUEUE_HEAD * OutHead); NTSTATUS BuildBulkTransferQueueHead(PQUEUE_HEAD * OutHead); - NTSTATUS CreateDescriptor(PQUEUE_TRANSFER_DESCRIPTOR *OutDescriptor); + NTSTATUS STDMETHODCALLTYPE CreateDescriptor(PQUEUE_TRANSFER_DESCRIPTOR *OutDescriptor); NTSTATUS CreateQueueHead(PQUEUE_HEAD *OutQueueHead); - UCHAR GetDeviceAddress(); + UCHAR STDMETHODCALLTYPE GetDeviceAddress(); NTSTATUS BuildSetupPacket(); NTSTATUS BuildSetupPacketFromURB(); ULONG InternalCalculateTransferLength(); - NTSTATUS BuildTransferDescriptorChain(IN PQUEUE_HEAD QueueHead, IN PVOID TransferBuffer, IN ULONG TransferBufferLength, IN UCHAR PidCode, IN UCHAR InitialDataToggle, IN PQUEUE_TRANSFER_DESCRIPTOR AlternativeDescriptor, OUT PQUEUE_TRANSFER_DESCRIPTOR * OutFirstDescriptor, OUT PQUEUE_TRANSFER_DESCRIPTOR * OutLastDescriptor, OUT PUCHAR OutDataToggle, OUT PULONG OutTransferBufferOffset); - VOID InitDescriptor(IN PQUEUE_TRANSFER_DESCRIPTOR CurrentDescriptor, IN PVOID TransferBuffer, IN ULONG TransferBufferLength, IN UCHAR PidCode, IN UCHAR DataToggle, OUT PULONG OutDescriptorLength); + NTSTATUS STDMETHODCALLTYPE BuildTransferDescriptorChain(IN PQUEUE_HEAD QueueHead, IN PVOID TransferBuffer, IN ULONG TransferBufferLength, IN UCHAR PidCode, IN UCHAR InitialDataToggle, OUT PQUEUE_TRANSFER_DESCRIPTOR * OutFirstDescriptor, OUT PQUEUE_TRANSFER_DESCRIPTOR * OutLastDescriptor, OUT PUCHAR OutDataToggle, OUT PULONG OutTransferBufferOffset); + VOID STDMETHODCALLTYPE InitDescriptor(IN PQUEUE_TRANSFER_DESCRIPTOR CurrentDescriptor, IN PVOID TransferBuffer, IN ULONG TransferBufferLength, IN UCHAR PidCode, IN UCHAR DataToggle, OUT PULONG OutDescriptorLength); VOID DumpQueueHead(IN PQUEUE_HEAD QueueHead); // constructor / destructor @@ -565,6 +565,7 @@ } VOID +STDMETHODCALLTYPE CUSBRequest::InitDescriptor( IN PQUEUE_TRANSFER_DESCRIPTOR CurrentDescriptor, IN PVOID TransferBuffer, @@ -673,13 +674,13 @@ } NTSTATUS +STDMETHODCALLTYPE CUSBRequest::BuildTransferDescriptorChain( IN PQUEUE_HEAD QueueHead, IN PVOID TransferBuffer, IN ULONG TransferBufferLength, IN UCHAR PidCode, IN UCHAR InitialDataToggle, - IN PQUEUE_TRANSFER_DESCRIPTOR AlternativeDescriptor, OUT PQUEUE_TRANSFER_DESCRIPTOR * OutFirstDescriptor, OUT PQUEUE_TRANSFER_DESCRIPTOR * OutLastDescriptor, OUT PUCHAR OutDataToggle, @@ -757,15 +758,6 @@ // LastDescriptor->NextPointer = CurrentDescriptor->PhysicalAddr; LastDescriptor = CurrentDescriptor; - - if (AlternativeDescriptor) - { - // - // link to alternative next pointer - // - LastDescriptor->AlternateNextPointer = AlternativeDescriptor->PhysicalAddr; - } - } else { @@ -929,7 +921,6 @@ m_TransferBufferLength, InternalGetPidDirection(), TRUE, - NULL, &FirstDescriptor, &LastDescriptor, NULL, @@ -939,7 +930,12 @@ // FIXME handle errors // ASSERT(Status == STATUS_SUCCESS); - ASSERT(DescriptorChainLength == m_TransferBufferLength); + if (m_TransferBufferLength != DescriptorChainLength) + { + DPRINT1("DescriptorChainLength %x\n", DescriptorChainLength); + DPRINT1("m_TransferBufferLength %x\n", m_TransferBufferLength); + ASSERT(FALSE); + } // // now link the descriptors @@ -1125,7 +1121,6 @@ MaxTransferLength, InternalGetPidDirection(), m_EndpointDescriptor->DataToggle, - NULL, &FirstDescriptor, &LastDescriptor, &m_EndpointDescriptor->DataToggle, @@ -1176,6 +1171,7 @@ //---------------------------------------------------------------------------------------- NTSTATUS +STDMETHODCALLTYPE CUSBRequest::CreateDescriptor( PQUEUE_TRANSFER_DESCRIPTOR *OutDescriptor) { @@ -1430,7 +1426,7 @@ m_DescriptorPacket->wValue.LowByte = Urb->UrbControlDescriptorRequest.Index; m_DescriptorPacket->wValue.HiByte = Urb->UrbControlDescriptorRequest.DescriptorType; m_DescriptorPacket->wIndex.W = Urb->UrbControlDescriptorRequest.LanguageId; - m_DescriptorPacket->wLength = Urb->UrbControlDescriptorRequest.TransferBufferLength; + m_DescriptorPacket->wLength = (USHORT)Urb->UrbControlDescriptorRequest.TransferBufferLength; m_DescriptorPacket->bmRequestType.B = 0x80; break;
12 years, 10 months
1
0
0
0
[janderwald] 55916: [USBEHCI] - Fix regressions caused by libusb
by janderwald@svn.reactos.org
Author: janderwald Date: Wed Feb 29 09:41:34 2012 New Revision: 55916 URL:
http://svn.reactos.org/svn/reactos?rev=55916&view=rev
Log: [USBEHCI] - Fix regressions caused by libusb Modified: trunk/reactos/drivers/usb/usbehci/hardware.cpp trunk/reactos/drivers/usb/usbehci/usb_queue.cpp trunk/reactos/drivers/usb/usbehci/usb_request.cpp trunk/reactos/drivers/usb/usbehci/usbehci.h Modified: trunk/reactos/drivers/usb/usbehci/hardware.cpp URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/usb/usbehci/hardwa…
============================================================================== --- trunk/reactos/drivers/usb/usbehci/hardware.cpp [iso-8859-1] (original) +++ trunk/reactos/drivers/usb/usbehci/hardware.cpp [iso-8859-1] Wed Feb 29 09:41:34 2012 @@ -32,7 +32,7 @@ NTAPI StatusChangeWorkItemRoutine(PVOID Context); -class CUSBHardwareDevice : public IUSBHardwareDevice +class CUSBHardwareDevice : public IEHCIHardwareDevice { public: STDMETHODIMP QueryInterface( REFIID InterfaceId, PVOID* Interface); @@ -127,6 +127,7 @@ } NTSTATUS +STDMETHODCALLTYPE CUSBHardwareDevice::Initialize( PDRIVER_OBJECT DriverObject, PDEVICE_OBJECT FunctionalDeviceObject, @@ -206,6 +207,7 @@ } VOID +STDMETHODCALLTYPE CUSBHardwareDevice::SetCommandRegister(PEHCI_USBCMD_CONTENT UsbCmd) { PULONG Register; @@ -214,6 +216,7 @@ } VOID +STDMETHODCALLTYPE CUSBHardwareDevice::GetCommandRegister(PEHCI_USBCMD_CONTENT UsbCmd) { PULONG Register; @@ -277,6 +280,7 @@ } NTSTATUS +STDMETHODCALLTYPE CUSBHardwareDevice::PnpStart( PCM_RESOURCE_LIST RawResources, PCM_RESOURCE_LIST TranslatedResources) @@ -483,6 +487,7 @@ } NTSTATUS +STDMETHODCALLTYPE CUSBHardwareDevice::PnpStop(void) { UNIMPLEMENTED @@ -490,6 +495,7 @@ } NTSTATUS +STDMETHODCALLTYPE CUSBHardwareDevice::GetDeviceDetails( OUT OPTIONAL PUSHORT VendorId, OUT OPTIONAL PUSHORT DeviceId, @@ -508,7 +514,9 @@ return STATUS_SUCCESS; } -NTSTATUS CUSBHardwareDevice::GetDMA( +NTSTATUS +STDMETHODCALLTYPE +CUSBHardwareDevice::GetDMA( OUT struct IDMAMemoryManager **OutDMAMemoryManager) { if (!m_MemoryManager) @@ -518,6 +526,7 @@ } NTSTATUS +STDMETHODCALLTYPE CUSBHardwareDevice::GetUSBQueue( OUT struct IUSBQueue **OutUsbQueue) { @@ -872,6 +881,7 @@ } NTSTATUS +STDMETHODCALLTYPE CUSBHardwareDevice::ResetPort( IN ULONG PortIndex) { @@ -913,6 +923,7 @@ } NTSTATUS +STDMETHODCALLTYPE CUSBHardwareDevice::GetPortStatus( ULONG PortId, OUT USHORT *PortStatus, @@ -987,6 +998,7 @@ } NTSTATUS +STDMETHODCALLTYPE CUSBHardwareDevice::ClearPortStatus( ULONG PortId, ULONG Status) @@ -1096,6 +1108,7 @@ NTSTATUS +STDMETHODCALLTYPE CUSBHardwareDevice::SetPortFeature( ULONG PortId, ULONG Feature) @@ -1170,6 +1183,7 @@ } VOID +STDMETHODCALLTYPE CUSBHardwareDevice::SetAsyncListRegister( ULONG PhysicalAddress) { @@ -1177,6 +1191,7 @@ } VOID +STDMETHODCALLTYPE CUSBHardwareDevice::SetPeriodicListRegister( ULONG PhysicalAddress) { @@ -1187,18 +1202,23 @@ } struct _QUEUE_HEAD * +STDMETHODCALLTYPE CUSBHardwareDevice::GetAsyncListQueueHead() { return AsyncQueueHead; } -ULONG CUSBHardwareDevice::GetPeriodicListRegister() +ULONG +STDMETHODCALLTYPE +CUSBHardwareDevice::GetPeriodicListRegister() { UNIMPLEMENTED return NULL; } -VOID CUSBHardwareDevice::SetStatusChangeEndpointCallBack( +VOID +STDMETHODCALLTYPE +CUSBHardwareDevice::SetStatusChangeEndpointCallBack( PVOID CallBack, PVOID Context) { @@ -1437,6 +1457,7 @@ } NTSTATUS +NTAPI CreateUSBHardware( PUSBHARDWAREDEVICE *OutHardware) { Modified: trunk/reactos/drivers/usb/usbehci/usb_queue.cpp URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/usb/usbehci/usb_qu…
============================================================================== --- trunk/reactos/drivers/usb/usbehci/usb_queue.cpp [iso-8859-1] (original) +++ trunk/reactos/drivers/usb/usbehci/usb_queue.cpp [iso-8859-1] Wed Feb 29 09:41:34 2012 @@ -96,6 +96,7 @@ } NTSTATUS +STDMETHODCALLTYPE CUSBQueue::Initialize( IN PUSBHARDWAREDEVICE Hardware, IN PDMA_ADAPTER AdapterObject, @@ -276,6 +277,7 @@ } NTSTATUS +STDMETHODCALLTYPE CUSBQueue::AddUSBRequest( IUSBRequest * Req) { @@ -367,6 +369,7 @@ } NTSTATUS +STDMETHODCALLTYPE CUSBQueue::CreateUSBRequest( IUSBRequest **OutRequest) { @@ -657,6 +660,7 @@ VOID +STDMETHODCALLTYPE CUSBQueue::InterruptCallback( IN NTSTATUS Status, OUT PULONG ShouldRingDoorBell) @@ -826,6 +830,7 @@ } VOID +STDMETHODCALLTYPE CUSBQueue::CompleteAsyncRequests() { KIRQL OldLevel; @@ -900,6 +905,7 @@ } NTSTATUS +STDMETHODCALLTYPE CUSBQueue::AbortDevicePipe( IN UCHAR DeviceAddress, IN PUSB_ENDPOINT_DESCRIPTOR EndpointDescriptor) @@ -984,6 +990,7 @@ NTSTATUS +NTAPI CreateUSBQueue( PUSBQUEUE *OutUsbQueue) { Modified: trunk/reactos/drivers/usb/usbehci/usb_request.cpp URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/usb/usbehci/usb_re…
============================================================================== --- trunk/reactos/drivers/usb/usbehci/usb_request.cpp [iso-8859-1] (original) +++ trunk/reactos/drivers/usb/usbehci/usb_request.cpp [iso-8859-1] Wed Feb 29 09:41:34 2012 @@ -145,6 +145,7 @@ //---------------------------------------------------------------------------------------- NTSTATUS +STDMETHODCALLTYPE CUSBRequest::InitializeWithSetupPacket( IN PDMAMEMORYMANAGER DmaManager, IN PUSB_DEFAULT_PIPE_SETUP_PACKET SetupPacket, @@ -199,6 +200,7 @@ } //---------------------------------------------------------------------------------------- NTSTATUS +STDMETHODCALLTYPE CUSBRequest::InitializeWithIrp( IN PDMAMEMORYMANAGER DmaManager, IN PUSBDEVICE Device, @@ -330,6 +332,7 @@ //---------------------------------------------------------------------------------------- VOID +STDMETHODCALLTYPE CUSBRequest::CompletionCallback( IN NTSTATUS NtStatusCode, IN ULONG UrbStatusCode, @@ -419,6 +422,7 @@ //---------------------------------------------------------------------------------------- NTSTATUS +STDMETHODCALLTYPE CUSBRequest::GetQueueHead( struct _QUEUE_HEAD ** OutHead) { @@ -476,6 +480,7 @@ //---------------------------------------------------------------------------------------- BOOLEAN +STDMETHODCALLTYPE CUSBRequest::IsRequestComplete() { // @@ -497,6 +502,7 @@ } //---------------------------------------------------------------------------------------- ULONG +STDMETHODCALLTYPE CUSBRequest::GetTransferType() { // @@ -1283,6 +1289,7 @@ //---------------------------------------------------------------------------------------- UCHAR +STDMETHODCALLTYPE CUSBRequest::GetDeviceAddress() { PIO_STACK_LOCATION IoStack; @@ -1523,6 +1530,7 @@ //---------------------------------------------------------------------------------------- VOID +STDMETHODCALLTYPE CUSBRequest::GetResultStatus( OUT OPTIONAL NTSTATUS * NtStatusCode, OUT OPTIONAL PULONG UrbStatusCode) @@ -1557,6 +1565,7 @@ //----------------------------------------------------------------------------------------- BOOLEAN +STDMETHODCALLTYPE CUSBRequest::ShouldReleaseRequestAfterCompletion() { if (m_Irp) @@ -1577,6 +1586,7 @@ //----------------------------------------------------------------------------------------- VOID +STDMETHODCALLTYPE CUSBRequest::FreeQueueHead( IN struct _QUEUE_HEAD * QueueHead) { @@ -1639,6 +1649,7 @@ //----------------------------------------------------------------------------------------- BOOLEAN +STDMETHODCALLTYPE CUSBRequest::IsQueueHeadComplete( struct _QUEUE_HEAD * QueueHead) { @@ -1733,6 +1744,7 @@ //----------------------------------------------------------------------------------------- NTSTATUS +NTAPI InternalCreateUSBRequest( PUSBREQUEST *OutRequest) { Modified: trunk/reactos/drivers/usb/usbehci/usbehci.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/usb/usbehci/usbehc…
============================================================================== --- trunk/reactos/drivers/usb/usbehci/usbehci.h [iso-8859-1] (original) +++ trunk/reactos/drivers/usb/usbehci/usbehci.h [iso-8859-1] Wed Feb 29 09:41:34 2012 @@ -48,16 +48,16 @@ // // hardware.cpp // -NTSTATUS CreateUSBHardware(PUSBHARDWAREDEVICE *OutHardware); +NTSTATUS NTAPI CreateUSBHardware(PUSBHARDWAREDEVICE *OutHardware); // // usb_queue.cpp // -NTSTATUS CreateUSBQueue(PUSBQUEUE *OutUsbQueue); +NTSTATUS NTAPI CreateUSBQueue(PUSBQUEUE *OutUsbQueue); // // usb_request.cpp // -NTSTATUS InternalCreateUSBRequest(PUSBREQUEST *OutRequest); +NTSTATUS NTAPI InternalCreateUSBRequest(PUSBREQUEST *OutRequest); #endif
12 years, 10 months
1
0
0
0
[arty] 55915: [FSRTL] Import mostly-complete file locking implementation from arty-newcc.
by arty@svn.reactos.org
Author: arty Date: Wed Feb 29 09:18:57 2012 New Revision: 55915 URL:
http://svn.reactos.org/svn/reactos?rev=55915&view=rev
Log: [FSRTL] Import mostly-complete file locking implementation from arty-newcc. Modified: trunk/reactos/ntoskrnl/fsrtl/filelock.c Modified: trunk/reactos/ntoskrnl/fsrtl/filelock.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/fsrtl/filelock.c?…
============================================================================== --- trunk/reactos/ntoskrnl/fsrtl/filelock.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/fsrtl/filelock.c [iso-8859-1] Wed Feb 29 09:18:57 2012 @@ -12,11 +12,175 @@ #define NDEBUG #include <debug.h> +#define RESOURCE_OF_LOCK(L) ((PERESOURCE)&((L)->Unknown1)) + /* GLOBALS *******************************************************************/ PAGED_LOOKASIDE_LIST FsRtlFileLockLookasideList; +/* Note: this aligns the two types of lock entry structs so we can access the + FILE_LOCK_INFO part in common. Add elements after Shared if new stuff is needed. +*/ +typedef union _COMBINED_LOCK_ELEMENT +{ + struct + { + LIST_ENTRY dummy; + FILE_SHARED_LOCK_ENTRY Shared; + }; + FILE_EXCLUSIVE_LOCK_ENTRY Exclusive; +} +COMBINED_LOCK_ELEMENT, *PCOMBINED_LOCK_ELEMENT; + +typedef struct _LOCK_INFORMATION +{ + RTL_GENERIC_TABLE RangeTable; + IO_CSQ Csq; + KSPIN_LOCK CsqLock; + PFILE_LOCK BelongsTo; +} +LOCK_INFORMATION, *PLOCK_INFORMATION; + /* PRIVATE FUNCTIONS *********************************************************/ + +VOID +NTAPI +FsRtlCompleteLockIrpReal(IN PCOMPLETE_LOCK_IRP_ROUTINE CompleteRoutine, + IN PVOID Context, + IN PIRP Irp, + IN NTSTATUS Status, + OUT PNTSTATUS NewStatus, + IN PFILE_OBJECT FileObject OPTIONAL); + +/* Generic table methods */ + +static PVOID NTAPI LockAllocate(PRTL_GENERIC_TABLE Table, CLONG Bytes) +{ + PVOID Result; + Result = ExAllocatePoolWithTag(NonPagedPool, Bytes, 'FLCK'); + DPRINT("LockAllocate(%d) => %p\n", Bytes, Result); + return Result; +} + +static VOID NTAPI LockFree(PRTL_GENERIC_TABLE Table, PVOID Buffer) +{ + DPRINT("LockFree(%p)\n", Buffer); + ExFreePoolWithTag(Buffer, 'FLCK'); +} + +static RTL_GENERIC_COMPARE_RESULTS NTAPI LockCompare +(PRTL_GENERIC_TABLE Table, PVOID PtrA, PVOID PtrB) +{ + PCOMBINED_LOCK_ELEMENT A = PtrA, B = PtrB; + RTL_GENERIC_COMPARE_RESULTS Result; + DPRINT("Starting to compare element %x to element %x\n", PtrA, PtrB); + Result = + (A->Exclusive.FileLock.EndingByte.QuadPart < + B->Exclusive.FileLock.StartingByte.QuadPart) ? GenericLessThan : + (A->Exclusive.FileLock.StartingByte.QuadPart > + B->Exclusive.FileLock.EndingByte.QuadPart) ? GenericGreaterThan : + GenericEqual; + DPRINT("Compare(%x:%x) %x-%x to %x-%x => %d\n", + A,B, + A->Exclusive.FileLock.StartingByte.LowPart, + A->Exclusive.FileLock.EndingByte.LowPart, + B->Exclusive.FileLock.StartingByte.LowPart, + B->Exclusive.FileLock.EndingByte.LowPart, + Result); + return Result; +} + +/* CSQ methods */ + +static NTSTATUS NTAPI LockInsertIrpEx +(PIO_CSQ Csq, + PIRP Irp, + PVOID InsertContext) +{ + PCOMBINED_LOCK_ELEMENT LockElement = InsertContext; + InsertTailList(&LockElement->Exclusive.ListEntry, &Irp->Tail.Overlay.ListEntry); + return STATUS_SUCCESS; +} + +static VOID NTAPI LockRemoveIrp(PIO_CSQ Csq, PIRP Irp) +{ + RemoveEntryList(&Irp->Tail.Overlay.ListEntry); +} + +static PIRP NTAPI LockPeekNextIrp(PIO_CSQ Csq, PIRP Irp, PVOID PeekContext) +{ + // Context will be a COMBINED_LOCK_ELEMENT. We're looking for a + // lock that can be acquired, now that the lock matching PeekContext + // has been removed. + COMBINED_LOCK_ELEMENT LockElement; + PCOMBINED_LOCK_ELEMENT WhereUnlocked = PeekContext, Matching; + PLOCK_INFORMATION LockInfo = CONTAINING_RECORD(Csq, LOCK_INFORMATION, Csq); + PFILE_LOCK FileLock = LockInfo->BelongsTo; + if (!PeekContext) + return CONTAINING_RECORD + (Irp->Tail.Overlay.ListEntry.Flink, + IRP, + Tail.Overlay.ListEntry); + else + { + PLIST_ENTRY Following; + if (!FileLock->LockInformation) + { + return CONTAINING_RECORD + (Irp->Tail.Overlay.ListEntry.Flink, + IRP, + Tail.Overlay.ListEntry); + } + for (Following = Irp->Tail.Overlay.ListEntry.Flink; + Following != &WhereUnlocked->Exclusive.ListEntry; + Following = Following->Flink) + { + PIRP Irp = CONTAINING_RECORD(Following, IRP, Tail.Overlay.ListEntry); + PIO_STACK_LOCATION IoStack = IoGetCurrentIrpStackLocation(Irp); + LockElement.Exclusive.FileLock.StartingByte = + IoStack->Parameters.LockControl.ByteOffset; + LockElement.Exclusive.FileLock.EndingByte.QuadPart = + LockElement.Exclusive.FileLock.StartingByte.QuadPart + + IoStack->Parameters.LockControl.Length->QuadPart; + Matching = RtlLookupElementGenericTable + (FileLock->LockInformation, &LockElement); + if (!Matching) + { + // This IRP is fine... + return Irp; + } + } + return NULL; + } +} + +static VOID NTAPI +LockAcquireQueueLock(PIO_CSQ Csq, PKIRQL Irql) +{ + PLOCK_INFORMATION LockInfo = CONTAINING_RECORD(Csq, LOCK_INFORMATION, Csq); + KeAcquireSpinLock(&LockInfo->CsqLock, Irql); +} + +static VOID NTAPI +LockReleaseQueueLock(PIO_CSQ Csq, KIRQL Irql) +{ + PLOCK_INFORMATION LockInfo = CONTAINING_RECORD(Csq, LOCK_INFORMATION, Csq); + KeReleaseSpinLock(&LockInfo->CsqLock, Irql); +} + +static VOID NTAPI +LockCompleteCanceledIrp(PIO_CSQ Csq, PIRP Irp) +{ + NTSTATUS Status; + PLOCK_INFORMATION LockInfo = CONTAINING_RECORD(Csq, LOCK_INFORMATION, Csq); + FsRtlCompleteLockIrpReal + (LockInfo->BelongsTo->CompleteLockIrpRoutine, + NULL, + Irp, + STATUS_CANCELLED, + &Status, + NULL); +} VOID NTAPI @@ -55,8 +219,11 @@ FsRtlGetNextFileLock(IN PFILE_LOCK FileLock, IN BOOLEAN Restart) { - KeBugCheck(FILE_SYSTEM); - return NULL; + PCOMBINED_LOCK_ELEMENT Entry; + if (!FileLock->LockInformation) return NULL; + Entry = RtlEnumerateGenericTable(FileLock->LockInformation, Restart); + if (!Entry) return NULL; + else return &Entry->Exclusive.FileLock; } /* @@ -78,32 +245,137 @@ IN BOOLEAN AlreadySynchronized) { NTSTATUS Status; - - static BOOLEAN Warn; - if (!Warn++) DPRINT1("FsRtlPrivateLock() is stubplemented!\n"); + COMBINED_LOCK_ELEMENT ToInsert; + PCOMBINED_LOCK_ELEMENT Conflict; + PLOCK_INFORMATION LockInfo; + BOOLEAN InsertedNew; + + DPRINT1("FsRtlPrivateLock() is stubplemented!\n"); + ASSERT(AlreadySynchronized); /* Initialize the lock, if necessary */ if (!FileLock->LockInformation) { - DPRINT("LockInformation is uninitialized!\n"); + LockInfo = ExAllocatePool(PagedPool, sizeof(LOCK_INFORMATION)); + FileLock->LockInformation = LockInfo; + if (!FileLock) + return FALSE; + + LockInfo->BelongsTo = FileLock; + + RtlInitializeGenericTable + (&LockInfo->RangeTable, + LockCompare, + LockAllocate, + LockFree, + NULL); + + KeInitializeSpinLock(&LockInfo->CsqLock); + + IoCsqInitializeEx + (&LockInfo->Csq, + LockInsertIrpEx, + LockRemoveIrp, + LockPeekNextIrp, + LockAcquireQueueLock, + LockReleaseQueueLock, + LockCompleteCanceledIrp); } - /* Assume all is cool, and lock is set */ - IoStatus->Status = STATUS_SUCCESS; - - if (Irp) - { - /* Complete the request */ - FsRtlCompleteLockIrpReal(FileLock->CompleteLockIrpRoutine, - Context, - Irp, - IoStatus->Status, - &Status, - FileObject); - - /* Update the status */ - IoStatus->Status = Status; - } + LockInfo = FileLock->LockInformation; + ToInsert.Exclusive.FileLock.FileObject = FileObject; + ToInsert.Exclusive.FileLock.StartingByte = *FileOffset; + ToInsert.Exclusive.FileLock.EndingByte.QuadPart = FileOffset->QuadPart + Length->QuadPart; + ToInsert.Exclusive.FileLock.ProcessId = Process->UniqueProcessId; + ToInsert.Exclusive.FileLock.Key = Key; + ToInsert.Exclusive.FileLock.ExclusiveLock = ExclusiveLock; + + Conflict = RtlInsertElementGenericTable + (FileLock->LockInformation, + &ToInsert, + sizeof(ToInsert), + &InsertedNew); + + if (Conflict && !InsertedNew) + { + if (Conflict->Exclusive.FileLock.ExclusiveLock || ExclusiveLock) + { + if (FailImmediately) + { + IoStatus->Status = STATUS_FILE_LOCK_CONFLICT; + if (Irp) + { + FsRtlCompleteLockIrpReal + (FileLock->CompleteLockIrpRoutine, + Context, + Irp, + IoStatus->Status, + &Status, + FileObject); + } + return FALSE; + } + else + { + IoStatus->Status = STATUS_PENDING; + if (Irp) + { + IoMarkIrpPending(Irp); + IoCsqInsertIrpEx + (&LockInfo->Csq, + Irp, + NULL, + NULL); + } + } + return FALSE; + } + else + { + IoStatus->Status = STATUS_SUCCESS; + if (Irp) + { + FsRtlCompleteLockIrpReal + (FileLock->CompleteLockIrpRoutine, + Context, + Irp, + IoStatus->Status, + &Status, + FileObject); + } + return FALSE; + } + } + else if (!Conflict) + { + /* Conflict here is (or would be) the newly inserted element, but we ran + * out of space probably. */ + IoStatus->Status = STATUS_NO_MEMORY; + return FALSE; + } + else + { + /* Assume all is cool, and lock is set */ + IoStatus->Status = STATUS_SUCCESS; + + // Initialize our resource ... We'll use this to mediate access to the + // irp queue. + ExInitializeResourceLite(RESOURCE_OF_LOCK(&Conflict->Exclusive)); + + if (Irp) + { + /* Complete the request */ + FsRtlCompleteLockIrpReal(FileLock->CompleteLockIrpRoutine, + Context, + Irp, + IoStatus->Status, + &Status, + FileObject); + + /* Update the status */ + IoStatus->Status = Status; + } + } return TRUE; } @@ -116,8 +388,20 @@ FsRtlCheckLockForReadAccess(IN PFILE_LOCK FileLock, IN PIRP Irp) { - KeBugCheck(FILE_SYSTEM); - return FALSE; + PIO_STACK_LOCATION IoStack = IoGetCurrentIrpStackLocation(Irp); + COMBINED_LOCK_ELEMENT ToFind; + PCOMBINED_LOCK_ELEMENT Found; + if (!FileLock->LockInformation) return TRUE; + ToFind.Exclusive.FileLock.StartingByte = IoStack->Parameters.Read.ByteOffset; + ToFind.Exclusive.FileLock.EndingByte.QuadPart = + ToFind.Exclusive.FileLock.StartingByte.QuadPart + + IoStack->Parameters.Read.Length; + Found = RtlLookupElementGenericTable + (FileLock->LockInformation, + &ToFind); + if (!Found) return TRUE; + return !Found->Exclusive.FileLock.ExclusiveLock || + IoStack->Parameters.Read.Key == Found->Exclusive.FileLock.Key; } /* @@ -128,8 +412,20 @@ FsRtlCheckLockForWriteAccess(IN PFILE_LOCK FileLock, IN PIRP Irp) { - KeBugCheck(FILE_SYSTEM); - return FALSE; + PIO_STACK_LOCATION IoStack = IoGetCurrentIrpStackLocation(Irp); + COMBINED_LOCK_ELEMENT ToFind; + PCOMBINED_LOCK_ELEMENT Found; + PEPROCESS Process = Irp->Tail.Overlay.Thread->ThreadsProcess; + if (!FileLock->LockInformation) return TRUE; + ToFind.Exclusive.FileLock.StartingByte = IoStack->Parameters.Write.ByteOffset; + ToFind.Exclusive.FileLock.EndingByte.QuadPart = + ToFind.Exclusive.FileLock.StartingByte.QuadPart + + IoStack->Parameters.Write.Length; + Found = RtlLookupElementGenericTable + (FileLock->LockInformation, + &ToFind); + if (!Found) return TRUE; + return Process->UniqueProcessId == Found->Exclusive.FileLock.ProcessId; } /* @@ -144,8 +440,19 @@ IN PFILE_OBJECT FileObject, IN PVOID Process) { - KeBugCheck(FILE_SYSTEM); - return FALSE; + PEPROCESS EProcess = Process; + COMBINED_LOCK_ELEMENT ToFind; + PCOMBINED_LOCK_ELEMENT Found; + ToFind.Exclusive.FileLock.StartingByte = *FileOffset; + ToFind.Exclusive.FileLock.EndingByte.QuadPart = + FileOffset->QuadPart + Length->QuadPart; + if (!FileLock->LockInformation) return TRUE; + Found = RtlLookupElementGenericTable + (FileLock->LockInformation, + &ToFind); + if (!Found || !Found->Exclusive.FileLock.ExclusiveLock) return TRUE; + return Found->Exclusive.FileLock.Key == Key && + Found->Exclusive.FileLock.ProcessId == EProcess->UniqueProcessId; } /* @@ -160,8 +467,19 @@ IN PFILE_OBJECT FileObject, IN PVOID Process) { - KeBugCheck(FILE_SYSTEM); - return FALSE; + PEPROCESS EProcess = Process; + COMBINED_LOCK_ELEMENT ToFind; + PCOMBINED_LOCK_ELEMENT Found; + ToFind.Exclusive.FileLock.StartingByte = *FileOffset; + ToFind.Exclusive.FileLock.EndingByte.QuadPart = + FileOffset->QuadPart + Length->QuadPart; + if (!FileLock->LockInformation) return TRUE; + Found = RtlLookupElementGenericTable + (FileLock->LockInformation, + &ToFind); + if (!Found) return TRUE; + return Found->Exclusive.FileLock.Key == Key && + Found->Exclusive.FileLock.ProcessId == EProcess->UniqueProcessId; } /* @@ -178,10 +496,38 @@ IN PVOID Context OPTIONAL, IN BOOLEAN AlreadySynchronized) { - static BOOLEAN Warn; - if (!Warn++) DPRINT1("FsRtlFastUnlockSingle() is stubplemented!\n"); - - return STATUS_SUCCESS; + COMBINED_LOCK_ELEMENT Find; + PCOMBINED_LOCK_ELEMENT Entry; + PIRP NextMatchingLockIrp; + PLOCK_INFORMATION InternalInfo = FileLock->LockInformation; + // The region to unlock must correspond exactly to a previously locked region + // -- msdn + ASSERT(AlreadySynchronized); + Find.Exclusive.FileLock.StartingByte = *FileOffset; + Find.Exclusive.FileLock.EndingByte.QuadPart = + FileOffset->QuadPart + Length->QuadPart; + Entry = RtlLookupElementGenericTable(&InternalInfo->RangeTable, &Find); + if (!Entry) return STATUS_RANGE_NOT_LOCKED; + if (Entry->Exclusive.FileLock.Key != Key || + Entry->Exclusive.FileLock.ProcessId != Process->UniqueProcessId) + return STATUS_RANGE_NOT_LOCKED; + if (Entry->Exclusive.FileLock.StartingByte.QuadPart != FileOffset->QuadPart || + Entry->Exclusive.FileLock.EndingByte.QuadPart != + FileOffset->QuadPart + Length->QuadPart) + return STATUS_RANGE_NOT_LOCKED; + // this is definitely the thing we want + RtlCopyMemory(&Find, Entry, sizeof(Find)); + RtlDeleteElementGenericTable(&InternalInfo->RangeTable, Entry); + NextMatchingLockIrp = IoCsqRemoveNextIrp(&InternalInfo->Csq, &Find); + if (NextMatchingLockIrp) + { + // Got a new lock irp... try to do the new lock operation + // Note that we pick an operation that would succeed at the time + // we looked, but can't guarantee that it won't just be re-queued + // because somebody else snatched part of the range in a new thread. + FsRtlProcessFileLock(InternalInfo->BelongsTo, NextMatchingLockIrp, NULL); + } + return STATUS_SUCCESS; } /* @@ -194,8 +540,32 @@ IN PEPROCESS Process, IN PVOID Context OPTIONAL) { - KeBugCheck(FILE_SYSTEM); - return STATUS_UNSUCCESSFUL; + PCOMBINED_LOCK_ELEMENT Entry; + PRTL_GENERIC_TABLE InternalInfo = FileLock->LockInformation; + + // XXX Synchronize somehow + if (!FileLock->LockInformation) return STATUS_RANGE_NOT_LOCKED; // no locks + for (Entry = RtlEnumerateGenericTable(InternalInfo, TRUE); + Entry; + Entry = RtlEnumerateGenericTable(InternalInfo, FALSE)) + { + LARGE_INTEGER Length; + // We'll take the first one to be the list head, and free the others first... + Length.QuadPart = + Entry->Exclusive.FileLock.EndingByte.QuadPart - + Entry->Exclusive.FileLock.StartingByte.QuadPart; + FsRtlFastUnlockSingle + (FileLock, + Entry->Exclusive.FileLock.FileObject, + &Entry->Exclusive.FileLock.StartingByte, + &Length, + Entry->Exclusive.FileLock.ProcessId, + Entry->Exclusive.FileLock.Key, + Context, + TRUE); + } + + return STATUS_SUCCESS; } /* @@ -209,8 +579,36 @@ IN ULONG Key, IN PVOID Context OPTIONAL) { - KeBugCheck(FILE_SYSTEM); - return STATUS_UNSUCCESSFUL; + PCOMBINED_LOCK_ELEMENT Entry; + PRTL_GENERIC_TABLE InternalInfo = FileLock->LockInformation; + + // XXX Synchronize somehow + if (!FileLock->LockInformation) return STATUS_RANGE_NOT_LOCKED; // no locks + for (Entry = RtlEnumerateGenericTable(InternalInfo, TRUE); + Entry; + Entry = RtlEnumerateGenericTable(InternalInfo, FALSE)) + { + LARGE_INTEGER Length; + // We'll take the first one to be the list head, and free the others first... + Length.QuadPart = + Entry->Exclusive.FileLock.EndingByte.QuadPart - + Entry->Exclusive.FileLock.StartingByte.QuadPart; + if (Entry->Exclusive.FileLock.Key == Key && + Entry->Exclusive.FileLock.ProcessId == Process->UniqueProcessId) + { + FsRtlFastUnlockSingle + (FileLock, + Entry->Exclusive.FileLock.FileObject, + &Entry->Exclusive.FileLock.StartingByte, + &Length, + Entry->Exclusive.FileLock.ProcessId, + Entry->Exclusive.FileLock.Key, + Context, + TRUE); + } + } + + return STATUS_SUCCESS; } /* @@ -355,7 +753,12 @@ NTAPI FsRtlUninitializeFileLock(IN PFILE_LOCK FileLock) { - return; + if (FileLock->LockInformation) + { + ASSERT(!RtlNumberGenericTableElements(FileLock->LockInformation)); + ExFreePool(FileLock->LockInformation); + FileLock->LockInformation = NULL; + } } /* @@ -393,4 +796,3 @@ FsRtlUninitializeFileLock(FileLock); ExFreeToPagedLookasideList(&FsRtlFileLockLookasideList, FileLock); } -
12 years, 10 months
1
0
0
0
[arty] 55914: [FSRTL] Import code from Pierre Schweitzer's fsrtl branch. - Large MCB and MCB - Change notification
by arty@svn.reactos.org
Author: arty Date: Wed Feb 29 09:18:01 2012 New Revision: 55914 URL:
http://svn.reactos.org/svn/reactos?rev=55914&view=rev
Log: [FSRTL] Import code from Pierre Schweitzer's fsrtl branch. - Large MCB and MCB - Change notification Added: trunk/reactos/ntoskrnl/fsrtl/mcb.c (with props) Modified: trunk/reactos/ntoskrnl/CMakeLists.txt trunk/reactos/ntoskrnl/fsrtl/fsrtlpc.c trunk/reactos/ntoskrnl/fsrtl/largemcb.c trunk/reactos/ntoskrnl/fsrtl/notify.c trunk/reactos/ntoskrnl/include/internal/fsrtl.h Modified: trunk/reactos/ntoskrnl/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/CMakeLists.txt?re…
============================================================================== --- trunk/reactos/ntoskrnl/CMakeLists.txt [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/CMakeLists.txt [iso-8859-1] Wed Feb 29 09:18:01 2012 @@ -119,6 +119,7 @@ fsrtl/fsfilter.c fsrtl/fsrtlpc.c fsrtl/largemcb.c + fsrtl/mcb.c fsrtl/name.c fsrtl/notify.c fsrtl/oplock.c Modified: trunk/reactos/ntoskrnl/fsrtl/fsrtlpc.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/fsrtl/fsrtlpc.c?r…
============================================================================== --- trunk/reactos/ntoskrnl/fsrtl/fsrtlpc.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/fsrtl/fsrtlpc.c [iso-8859-1] Wed Feb 29 09:18:01 2012 @@ -169,6 +169,8 @@ IFS_POOL_TAG, 0); + FsRtlInitializeLargeMcbs(); + /* Allocate the Resource Buffer */ FsRtlPagingIoResources = FsRtlAllocatePoolWithTag(NonPagedPool, FSRTL_MAX_RESOURCES * Modified: trunk/reactos/ntoskrnl/fsrtl/largemcb.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/fsrtl/largemcb.c?…
============================================================================== --- trunk/reactos/ntoskrnl/fsrtl/largemcb.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/fsrtl/largemcb.c [iso-8859-1] Wed Feb 29 09:18:01 2012 @@ -2,20 +2,138 @@ * PROJECT: ReactOS Kernel * LICENSE: GPL - See COPYING in the top level directory * FILE: ntoskrnl/fsrtl/largemcb.c - * PURPOSE: Mapping Control Block (MCB) support for File System Drivers + * PURPOSE: Large Mapped Control Block (MCB) support for File System Drivers * PROGRAMMERS: Alex Ionescu (alex.ionescu(a)reactos.org) + * Pierre Schweitzer (heis_spiter(a)hotmail.com) + * Art Yerkes (art.yerkes(a)gmail.com) */ /* INCLUDES ******************************************************************/ #include <ntoskrnl.h> -#define NDEBUG +//#define NDEBUG #include <debug.h> +/* GLOBALS *******************************************************************/ + +#define GET_LIST_HEAD(x) ((PLIST_ENTRY)(&((PRTL_GENERIC_TABLE)x)[1])) + +PAGED_LOOKASIDE_LIST FsRtlFirstMappingLookasideList; +NPAGED_LOOKASIDE_LIST FsRtlFastMutexLookasideList; + +typedef struct _LARGE_MCB_MAPPING_ENTRY +{ + LARGE_INTEGER RunStartVbn; + LARGE_INTEGER SectorCount; + LARGE_INTEGER StartingLbn; + LIST_ENTRY Sequence; +} LARGE_MCB_MAPPING_ENTRY, *PLARGE_MCB_MAPPING_ENTRY; + +static PVOID NTAPI McbMappingAllocate(PRTL_GENERIC_TABLE Table, CLONG Bytes) +{ + PVOID Result; + PBASE_MCB Mcb = (PBASE_MCB)Table->TableContext; + Result = ExAllocatePoolWithTag(Mcb->PoolType, Bytes, 'LMCB'); + DPRINT("McbMappingAllocate(%d) => %p\n", Bytes, Result); + return Result; +} + +static VOID NTAPI McbMappingFree(PRTL_GENERIC_TABLE Table, PVOID Buffer) +{ + DPRINT("McbMappingFree(%p)\n", Buffer); + ExFreePoolWithTag(Buffer, 'LMCB'); +} + +static RTL_GENERIC_COMPARE_RESULTS NTAPI McbMappingCompare +(RTL_GENERIC_TABLE Table, PVOID PtrA, PVOID PtrB) +{ + PLARGE_MCB_MAPPING_ENTRY A = PtrA, B = PtrB; + return + (A->RunStartVbn.QuadPart + A->SectorCount.QuadPart < + B->RunStartVbn.QuadPart) ? GenericLessThan : + (A->RunStartVbn.QuadPart > + B->RunStartVbn.QuadPart + B->SectorCount.QuadPart) ? + GenericGreaterThan : GenericEqual; +} + /* PUBLIC FUNCTIONS **********************************************************/ /* - * @unimplemented + * @implemented + */ +BOOLEAN +NTAPI +FsRtlAddBaseMcbEntry(IN PBASE_MCB Mcb, + IN LONGLONG Vbn, + IN LONGLONG Lbn, + IN LONGLONG SectorCount) +{ + LARGE_MCB_MAPPING_ENTRY Node; + PLARGE_MCB_MAPPING_ENTRY Existing = NULL; + BOOLEAN NewElement = FALSE; + + Node.RunStartVbn.QuadPart = Vbn; + Node.StartingLbn.QuadPart = Lbn; + Node.SectorCount.QuadPart = SectorCount; + + while (!NewElement) + { + DPRINT("Inserting %x:%x\n", Node.RunStartVbn.LowPart, Node.SectorCount.LowPart); + Existing = RtlInsertElementGenericTable + (Mcb->Mapping, &Node, sizeof(Node), &NewElement); + DPRINT("Existing %x\n", Existing); + if (!Existing) break; + + DPRINT("NewElement %d\n", NewElement); + if (!NewElement) + { + // We merge the existing runs + LARGE_INTEGER StartVbn, FinalVbn; + DPRINT("Existing: %x:%x\n", + Existing->RunStartVbn.LowPart, Node.SectorCount.LowPart); + if (Existing->RunStartVbn.QuadPart < Node.RunStartVbn.QuadPart) + { + StartVbn = Existing->RunStartVbn; + Node.StartingLbn = Existing->StartingLbn; + } + else + { + StartVbn = Node.RunStartVbn; + } + DPRINT("StartVbn %x\n", StartVbn.LowPart); + if (Existing->RunStartVbn.QuadPart + Existing->SectorCount.QuadPart > + Node.RunStartVbn.QuadPart + Node.SectorCount.QuadPart) + { + FinalVbn.QuadPart = + Existing->RunStartVbn.QuadPart + Existing->SectorCount.QuadPart; + } + else + { + FinalVbn.QuadPart = + Node.RunStartVbn.QuadPart + Node.SectorCount.QuadPart; + } + DPRINT("FinalVbn %x\n", FinalVbn.LowPart); + Node.RunStartVbn.QuadPart = StartVbn.QuadPart; + Node.SectorCount.QuadPart = FinalVbn.QuadPart - StartVbn.QuadPart; + RemoveHeadList(&Existing->Sequence); + RtlDeleteElementGenericTable(Mcb->Mapping, Existing); + Mcb->PairCount--; + } + else + { + DPRINT("Mapping added %x\n", Existing); + Mcb->MaximumPairCount++; + Mcb->PairCount++; + InsertHeadList(GET_LIST_HEAD(Mcb->Mapping), &Existing->Sequence); + } + } + + DPRINT("!!Existing %d\n", !!Existing); + return !!Existing; +} + +/* + * @implemented */ BOOLEAN NTAPI @@ -24,30 +142,57 @@ IN LONGLONG Lbn, IN LONGLONG SectorCount) { - KeBugCheck(FILE_SYSTEM); - return FALSE; -} - -/* - * @implemented - */ -BOOLEAN -NTAPI -FsRtlAddMcbEntry(IN PMCB Mcb, - IN VBN Vbn, - IN LBN Lbn, - IN ULONG SectorCount) -{ - /* Call the newer function */ - return FsRtlAddLargeMcbEntry(&Mcb-> - DummyFieldThatSizesThisStructureCorrectly, - (LONGLONG)Vbn, - (LONGLONG)Lbn, - (LONGLONG)SectorCount); + BOOLEAN Result; + + DPRINT("Mcb %x Vbn %x Lbn %x SectorCount %x\n", Mcb, Vbn, Lbn, SectorCount); + + KeAcquireGuardedMutex(Mcb->GuardedMutex); + Result = FsRtlAddBaseMcbEntry(&(Mcb->BaseMcb), + Vbn, + Lbn, + SectorCount); + KeReleaseGuardedMutex(Mcb->GuardedMutex); + + DPRINT("Done %d\n", Result); + + return Result; } /* * @unimplemented + */ +BOOLEAN +NTAPI +FsRtlGetNextBaseMcbEntry(IN PBASE_MCB Mcb, + IN ULONG RunIndex, + OUT PLONGLONG Vbn, + OUT PLONGLONG Lbn, + OUT PLONGLONG SectorCount) +{ + ULONG i = 0; + BOOLEAN Result = FALSE; + PLARGE_MCB_MAPPING_ENTRY Entry; + for (Entry = (PLARGE_MCB_MAPPING_ENTRY) + RtlEnumerateGenericTable(Mcb->Mapping, TRUE); + Entry && i < RunIndex; + Entry = (PLARGE_MCB_MAPPING_ENTRY) + RtlEnumerateGenericTable(Mcb->Mapping, FALSE), i++); + if (Entry) + { + Result = TRUE; + if (Vbn) + *Vbn = Entry->RunStartVbn.QuadPart; + if (Lbn) + *Lbn = Entry->StartingLbn.QuadPart; + if (SectorCount) + *SectorCount = Entry->SectorCount.QuadPart; + } + + return Result; +} + +/* + * @implemented */ BOOLEAN NTAPI @@ -57,55 +202,78 @@ OUT PLONGLONG Lbn, OUT PLONGLONG SectorCount) { - KeBugCheck(FILE_SYSTEM); - *Vbn = 0; - *Lbn = 0; - *SectorCount= 0; - return FALSE; -} - -/* - * @implemented - */ -BOOLEAN -NTAPI -FsRtlGetNextMcbEntry(IN PMCB Mcb, - IN ULONG RunIndex, - OUT PVBN Vbn, - OUT PLBN Lbn, - OUT PULONG SectorCount) -{ - BOOLEAN Return = FALSE; - LONGLONG llVbn; - LONGLONG llLbn; - LONGLONG llSectorCount; - - /* Call the Large version */ - Return = FsRtlGetNextLargeMcbEntry( - &Mcb->DummyFieldThatSizesThisStructureCorrectly, - RunIndex, - &llVbn, - &llLbn, - &llSectorCount); - - /* Return the lower 32 bits */ - *Vbn = (ULONG)llVbn; - *Lbn = (ULONG)llLbn; - *SectorCount = (ULONG)llSectorCount; - - /* And return the original value */ - return Return; -} - -/* - * @unimplemented + BOOLEAN Result; + + DPRINT("FsRtlGetNextLargeMcbEntry Mcb %x RunIndex %x\n", Mcb, RunIndex); + + KeAcquireGuardedMutex(Mcb->GuardedMutex); + Result = FsRtlGetNextBaseMcbEntry(&(Mcb->BaseMcb), + RunIndex, + Vbn, + Lbn, + SectorCount); + KeReleaseGuardedMutex(Mcb->GuardedMutex); + + DPRINT("Done %d\n", Result); + + return Result; +} + +/* + * @implemented + */ +VOID +NTAPI +FsRtlInitializeBaseMcb(IN PBASE_MCB Mcb, + IN POOL_TYPE PoolType) +{ + Mcb->PairCount = 0; + + if (PoolType == PagedPool) + { + Mcb->Mapping = ExAllocateFromPagedLookasideList(&FsRtlFirstMappingLookasideList); + } + else + { + Mcb->Mapping = ExAllocatePoolWithTag(PoolType | POOL_RAISE_IF_ALLOCATION_FAILURE, + sizeof(RTL_GENERIC_TABLE) + sizeof(LIST_ENTRY), + 'FSBC'); + } + + Mcb->PoolType = PoolType; + Mcb->MaximumPairCount = MAXIMUM_PAIR_COUNT; + RtlInitializeGenericTable + (Mcb->Mapping, + (PRTL_GENERIC_COMPARE_ROUTINE)McbMappingCompare, + McbMappingAllocate, + McbMappingFree, + Mcb); + InitializeListHead(GET_LIST_HEAD(Mcb->Mapping)); +} + +/* + * @implemented */ VOID NTAPI FsRtlInitializeLargeMcb(IN PLARGE_MCB Mcb, IN POOL_TYPE PoolType) { - KeBugCheck(FILE_SYSTEM); + Mcb->GuardedMutex = ExAllocateFromNPagedLookasideList(&FsRtlFastMutexLookasideList); + + KeInitializeGuardedMutex(Mcb->GuardedMutex); + + _SEH2_TRY + { + FsRtlInitializeBaseMcb(&(Mcb->BaseMcb), PoolType); + } + _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) + { + ExFreeToNPagedLookasideList(&FsRtlFastMutexLookasideList, + Mcb->GuardedMutex); + Mcb->GuardedMutex = NULL; + } + _SEH2_END; } /* @@ -113,16 +281,80 @@ */ VOID NTAPI -FsRtlInitializeMcb(IN PMCB Mcb, - IN POOL_TYPE PoolType) -{ - /* Call the newer function */ - FsRtlInitializeLargeMcb(&Mcb->DummyFieldThatSizesThisStructureCorrectly, - PoolType); +FsRtlInitializeLargeMcbs(VOID) +{ + /* Initialize the list for the MCB */ + ExInitializePagedLookasideList(&FsRtlFirstMappingLookasideList, + NULL, + NULL, + POOL_RAISE_IF_ALLOCATION_FAILURE, + sizeof(RTL_GENERIC_TABLE) + sizeof(LIST_ENTRY), + IFS_POOL_TAG, + 0); /* FIXME: Should be 4 */ + + /* Initialize the list for the guarded mutex */ + ExInitializeNPagedLookasideList(&FsRtlFastMutexLookasideList, + NULL, + NULL, + POOL_RAISE_IF_ALLOCATION_FAILURE, + sizeof(KGUARDED_MUTEX), + IFS_POOL_TAG, + 0); /* FIXME: Should be 32 */ } /* * @unimplemented + */ +BOOLEAN +NTAPI +FsRtlLookupBaseMcbEntry(IN PBASE_MCB Mcb, + IN LONGLONG Vbn, + OUT PLONGLONG Lbn OPTIONAL, + OUT PLONGLONG SectorCountFromLbn OPTIONAL, + OUT PLONGLONG StartingLbn OPTIONAL, + OUT PLONGLONG SectorCountFromStartingLbn OPTIONAL, + OUT PULONG Index OPTIONAL) +{ + BOOLEAN Result = FALSE; + LARGE_MCB_MAPPING_ENTRY ToLookup; + PLARGE_MCB_MAPPING_ENTRY Entry; + + ToLookup.RunStartVbn.QuadPart = Vbn; + ToLookup.SectorCount.QuadPart = 1; + + Entry = RtlLookupElementGenericTable(Mcb->Mapping, &ToLookup); + if (!Entry) + { + // Find out if we have a following entry. The spec says we should return + // found with Lbn == -1 when we're beneath the largest map. + ToLookup.SectorCount.QuadPart = (1ull<<62) - ToLookup.RunStartVbn.QuadPart; + Entry = RtlLookupElementGenericTable(Mcb->Mapping, &ToLookup); + if (Entry) + { + Result = TRUE; + if (Lbn) *Lbn = ~0ull; + } + else + { + Result = FALSE; + } + } + else + { + LARGE_INTEGER Offset; + Offset.QuadPart = Vbn - Entry->RunStartVbn.QuadPart; + Result = TRUE; + if (Lbn) *Lbn = Entry->StartingLbn.QuadPart + Offset.QuadPart; + if (SectorCountFromLbn) *SectorCountFromLbn = Entry->SectorCount.QuadPart - Offset.QuadPart; + if (StartingLbn) *StartingLbn = Entry->StartingLbn.QuadPart; + if (SectorCountFromStartingLbn) *SectorCountFromStartingLbn = Entry->SectorCount.QuadPart; + } + + return Result; +} + +/* + * @implemented */ BOOLEAN NTAPI @@ -134,14 +366,61 @@ OUT PLONGLONG SectorCountFromStartingLbn OPTIONAL, OUT PULONG Index OPTIONAL) { - KeBugCheck(FILE_SYSTEM); - *Lbn = 0; - *SectorCountFromLbn = 0; - return FALSE; + BOOLEAN Result; + + DPRINT("FsRtlLookupLargeMcbEntry Mcb %x Vbn %x\n", Mcb, (ULONG)Vbn); + + KeAcquireGuardedMutex(Mcb->GuardedMutex); + Result = FsRtlLookupBaseMcbEntry(&(Mcb->BaseMcb), + Vbn, + Lbn, + SectorCountFromLbn, + StartingLbn, + SectorCountFromStartingLbn, + Index); + KeReleaseGuardedMutex(Mcb->GuardedMutex); + + DPRINT("Done %d\n", Result); + + return Result; } /* * @unimplemented + */ +BOOLEAN +NTAPI +FsRtlLookupLastBaseMcbEntryAndIndex(IN PBASE_MCB OpaqueMcb, + IN OUT PLONGLONG LargeVbn, + IN OUT PLONGLONG LargeLbn, + IN OUT PULONG Index) +{ + ULONG i = 0; + BOOLEAN Result = FALSE; + PLIST_ENTRY ListEntry; + PLARGE_MCB_MAPPING_ENTRY Entry; + PLARGE_MCB_MAPPING_ENTRY CountEntry; + + ListEntry = GET_LIST_HEAD(OpaqueMcb->Mapping); + if (!IsListEmpty(ListEntry)) + { + Entry = CONTAINING_RECORD(ListEntry->Flink, LARGE_MCB_MAPPING_ENTRY, Sequence); + Result = TRUE; + *LargeVbn = Entry->RunStartVbn.QuadPart; + *LargeLbn = Entry->StartingLbn.QuadPart; + + for (i = 0, CountEntry = RtlEnumerateGenericTable(OpaqueMcb->Mapping, TRUE); + CountEntry != Entry; + CountEntry = RtlEnumerateGenericTable(OpaqueMcb->Mapping, FALSE)); + + *Index = i; + } + + return Result; +} + +/* + * @implemented */ BOOLEAN NTAPI @@ -150,15 +429,49 @@ OUT PLONGLONG LargeLbn, OUT PULONG Index) { - KeBugCheck(FILE_SYSTEM); - *LargeVbn = 0; - *LargeLbn = 0; - *Index = 0; - return FALSE; + BOOLEAN Result; + + DPRINT("FsRtlLookupLastLargeMcbEntryAndIndex %x\n", OpaqueMcb); + + KeAcquireGuardedMutex(OpaqueMcb->GuardedMutex); + Result = FsRtlLookupLastBaseMcbEntryAndIndex(&(OpaqueMcb->BaseMcb), + LargeVbn, + LargeLbn, + Index); + KeReleaseGuardedMutex(OpaqueMcb->GuardedMutex); + + DPRINT("Done %d\n", Result); + + return Result; } /* * @unimplemented + */ +BOOLEAN +NTAPI +FsRtlLookupLastBaseMcbEntry(IN PBASE_MCB Mcb, + OUT PLONGLONG Vbn, + OUT PLONGLONG Lbn) +{ + BOOLEAN Result = FALSE; + PLIST_ENTRY ListEntry; + PLARGE_MCB_MAPPING_ENTRY Entry; + + ListEntry = GET_LIST_HEAD(Mcb->Mapping); + if (!IsListEmpty(ListEntry)) + { + Entry = CONTAINING_RECORD(ListEntry->Flink, LARGE_MCB_MAPPING_ENTRY, Sequence); + Result = TRUE; + *Vbn = Entry->RunStartVbn.QuadPart; + *Lbn = Entry->StartingLbn.QuadPart; + } + + return Result; +} + +/* + * @implemented */ BOOLEAN NTAPI @@ -166,68 +479,19 @@ OUT PLONGLONG Vbn, OUT PLONGLONG Lbn) { - KeBugCheck(FILE_SYSTEM); - return(FALSE); -} - -/* - * @implemented - */ -BOOLEAN -NTAPI -FsRtlLookupLastMcbEntry(IN PMCB Mcb, - OUT PVBN Vbn, - OUT PLBN Lbn) -{ - BOOLEAN Return = FALSE; - LONGLONG llVbn = 0; - LONGLONG llLbn = 0; - - /* Call the Large version */ - Return = FsRtlLookupLastLargeMcbEntry( - &Mcb->DummyFieldThatSizesThisStructureCorrectly, - &llVbn, - &llLbn); - - /* Return the lower 32-bits */ - *Vbn = (ULONG)llVbn; - *Lbn = (ULONG)llLbn; - - /* And return the original value */ - return Return; -} - -/* - * @implemented - */ -BOOLEAN -NTAPI -FsRtlLookupMcbEntry(IN PMCB Mcb, - IN VBN Vbn, - OUT PLBN Lbn, - OUT PULONG SectorCount OPTIONAL, - OUT PULONG Index) -{ - BOOLEAN Return = FALSE; - LONGLONG llLbn; - LONGLONG llSectorCount; - - /* Call the Large version */ - Return = FsRtlLookupLargeMcbEntry(&Mcb-> - DummyFieldThatSizesThisStructureCorrectly, - (LONGLONG)Vbn, - &llLbn, - &llSectorCount, - NULL, - NULL, - Index); - - /* Return the lower 32-bits */ - *Lbn = (ULONG)llLbn; - if (SectorCount) *SectorCount = (ULONG)llSectorCount; - - /* And return the original value */ - return Return; + BOOLEAN Result; + + DPRINT("FsRtlLookupLastLargeMcbEntry Mcb %x\n", Mcb); + + KeAcquireGuardedMutex(Mcb->GuardedMutex); + Result = FsRtlLookupLastBaseMcbEntry(&(Mcb->BaseMcb), + Vbn, + Lbn); + KeReleaseGuardedMutex(Mcb->GuardedMutex); + + DPRINT("Done %d\n", Result); + + return Result; } /* @@ -235,33 +499,131 @@ */ ULONG NTAPI +FsRtlNumberOfRunsInBaseMcb(IN PBASE_MCB Mcb) +{ + /* Return the count */ + return Mcb->PairCount; +} + +/* + * @implemented + */ +ULONG +NTAPI FsRtlNumberOfRunsInLargeMcb(IN PLARGE_MCB Mcb) { ULONG NumberOfRuns; + + DPRINT("FsRtlNumberOfRunsInLargeMcb Mcb %x\n", Mcb); /* Read the number of runs while holding the MCB lock */ KeAcquireGuardedMutex(Mcb->GuardedMutex); NumberOfRuns = Mcb->BaseMcb.PairCount; KeReleaseGuardedMutex(Mcb->GuardedMutex); + DPRINT("Done %d\n", NumberOfRuns); + /* Return the count */ return NumberOfRuns; } /* - * @implemented - */ -ULONG -NTAPI -FsRtlNumberOfRunsInMcb (IN PMCB Mcb) -{ - /* Call the newer function */ - return FsRtlNumberOfRunsInLargeMcb( - &Mcb->DummyFieldThatSizesThisStructureCorrectly); -} - -/* * @unimplemented + */ +BOOLEAN +NTAPI +FsRtlRemoveBaseMcbEntry(IN PBASE_MCB Mcb, + IN LONGLONG Vbn, + IN LONGLONG SectorCount) +{ + LARGE_MCB_MAPPING_ENTRY Node; + PLARGE_MCB_MAPPING_ENTRY Element; + + Node.RunStartVbn.QuadPart = Vbn; + Node.SectorCount.QuadPart = SectorCount; + + while ((Element = RtlLookupElementGenericTable(Mcb->Mapping, &Node))) + { + // Must split + if (Element->RunStartVbn.QuadPart < Node.RunStartVbn.QuadPart && + Element->SectorCount.QuadPart > Node.SectorCount.QuadPart) + { + LARGE_MCB_MAPPING_ENTRY Upper, Reinsert; + PLARGE_MCB_MAPPING_ENTRY Reinserted, Inserted; + LARGE_INTEGER StartHole = Node.RunStartVbn; + LARGE_INTEGER EndHole; + EndHole.QuadPart = Node.RunStartVbn.QuadPart + Node.SectorCount.QuadPart; + Upper.RunStartVbn.QuadPart = EndHole.QuadPart; + Upper.StartingLbn.QuadPart = + Element->StartingLbn.QuadPart + + EndHole.QuadPart - + Element->RunStartVbn.QuadPart; + Upper.SectorCount.QuadPart = + Element->SectorCount.QuadPart - + (EndHole.QuadPart - Element->RunStartVbn.QuadPart); + Reinsert = *Element; + Reinsert.SectorCount.QuadPart = + Element->RunStartVbn.QuadPart - StartHole.QuadPart; + RemoveEntryList(&Element->Sequence); + RtlDeleteElementGenericTable(Mcb->Mapping, Element); + Mcb->PairCount--; + + Reinserted = RtlInsertElementGenericTable + (Mcb->Mapping, &Reinsert, sizeof(Reinsert), NULL); + InsertHeadList(GET_LIST_HEAD(Mcb->Mapping), &Reinserted->Sequence); + Mcb->PairCount++; + + Inserted = RtlInsertElementGenericTable + (Mcb->Mapping, &Upper, sizeof(Upper), NULL); + InsertHeadList(GET_LIST_HEAD(Mcb->Mapping), &Inserted->Sequence); + Mcb->PairCount++; + } + else if (Element->RunStartVbn.QuadPart < Node.RunStartVbn.QuadPart) + { + LARGE_MCB_MAPPING_ENTRY NewElement; + PLARGE_MCB_MAPPING_ENTRY Reinserted; + LARGE_INTEGER StartHole = Node.RunStartVbn; + NewElement.RunStartVbn = Element->RunStartVbn; + NewElement.StartingLbn = Element->StartingLbn; + NewElement.SectorCount.QuadPart = StartHole.QuadPart - Element->StartingLbn.QuadPart; + + RemoveEntryList(&Element->Sequence); + RtlDeleteElementGenericTable(Mcb->Mapping, Element); + Mcb->PairCount--; + + Reinserted = RtlInsertElementGenericTable + (Mcb->Mapping, &NewElement, sizeof(NewElement), NULL); + InsertHeadList(GET_LIST_HEAD(Mcb->Mapping), &Reinserted->Sequence); + Mcb->PairCount++; + } + else + { + LARGE_MCB_MAPPING_ENTRY NewElement; + PLARGE_MCB_MAPPING_ENTRY Reinserted; + LARGE_INTEGER EndHole = Element->RunStartVbn; + LARGE_INTEGER EndRun; + EndRun.QuadPart = Element->RunStartVbn.QuadPart + Element->SectorCount.QuadPart; + NewElement.RunStartVbn = EndHole; + NewElement.StartingLbn.QuadPart = Element->StartingLbn.QuadPart + + (EndHole.QuadPart - Element->RunStartVbn.QuadPart); + NewElement.SectorCount.QuadPart = EndRun.QuadPart - EndHole.QuadPart; + + RemoveEntryList(&Element->Sequence); + RtlDeleteElementGenericTable(Mcb->Mapping, Element); + Mcb->PairCount--; + + Reinserted = RtlInsertElementGenericTable + (Mcb->Mapping, &NewElement, sizeof(NewElement), NULL); + InsertHeadList(GET_LIST_HEAD(Mcb->Mapping), &Reinserted->Sequence); + Mcb->PairCount++; + } + } + + return TRUE; +} + +/* + * @implemented */ VOID NTAPI @@ -269,7 +631,15 @@ IN LONGLONG Vbn, IN LONGLONG SectorCount) { - KeBugCheck(FILE_SYSTEM); + DPRINT("FsRtlRemoveLargeMcbEntry Mcb %x, Vbn %x, SectorCount %x\n", Mcb, (ULONG)Vbn, (ULONG)SectorCount); + + KeAcquireGuardedMutex(Mcb->GuardedMutex); + FsRtlRemoveBaseMcbEntry(&(Mcb->BaseMcb), + Vbn, + SectorCount); + KeReleaseGuardedMutex(Mcb->GuardedMutex); + + DPRINT("Done\n"); } /* @@ -277,29 +647,157 @@ */ VOID NTAPI -FsRtlRemoveMcbEntry(IN PMCB Mcb, - IN VBN Vbn, - IN ULONG SectorCount) -{ - /* Call the large function */ - FsRtlRemoveLargeMcbEntry(&Mcb->DummyFieldThatSizesThisStructureCorrectly, - (LONGLONG)Vbn, - (LONGLONG)SectorCount); -} - -/* - * @unimplemented +FsRtlResetBaseMcb(IN PBASE_MCB Mcb) +{ + PLARGE_MCB_MAPPING_ENTRY Element; + + while (RtlNumberGenericTableElements(Mcb->Mapping) && + (Element = (PLARGE_MCB_MAPPING_ENTRY)RtlGetElementGenericTable(Mcb->Mapping, 0))) + { + RtlDeleteElementGenericTable(Mcb->Mapping, Element); + } + + Mcb->PairCount = 0; + Mcb->MaximumPairCount = 0; +} + +/* + * @implemented */ VOID NTAPI FsRtlResetLargeMcb(IN PLARGE_MCB Mcb, IN BOOLEAN SelfSynchronized) { - KeBugCheck(FILE_SYSTEM); + if (!SelfSynchronized) + { + KeAcquireGuardedMutex(Mcb->GuardedMutex); + } + + FsRtlResetBaseMcb(&Mcb->BaseMcb); + + + if (!SelfSynchronized) + { + KeReleaseGuardedMutex(Mcb->GuardedMutex); + } +} + +#define MCB_BUMP_NO_MORE 0 +#define MCB_BUMP_AGAIN 1 + +static ULONG NTAPI McbBump(PBASE_MCB Mcb, PLARGE_MCB_MAPPING_ENTRY FixedPart) +{ + LARGE_MCB_MAPPING_ENTRY Reimagined; + PLARGE_MCB_MAPPING_ENTRY Found = NULL; + + DPRINT("McbBump %x (%x:%x)\n", Mcb, FixedPart->RunStartVbn.LowPart, FixedPart->SectorCount.LowPart); + + Reimagined = *FixedPart; + while ((Found = RtlLookupElementGenericTable(Mcb->Mapping, &Reimagined))) + { + Reimagined = *Found; + Reimagined.RunStartVbn.QuadPart = + FixedPart->RunStartVbn.QuadPart + FixedPart->SectorCount.QuadPart; + DPRINT("Reimagined %x\n", Reimagined.RunStartVbn.LowPart); + } + + DPRINT("Found %x\n", Found); + if (!Found) return MCB_BUMP_NO_MORE; + DPRINT1 + ("Moving %x-%x to %x because %x-%x overlaps\n", + Found->RunStartVbn.LowPart, + Found->RunStartVbn.LowPart + Found->SectorCount.QuadPart, + Reimagined.RunStartVbn.LowPart + Reimagined.SectorCount.LowPart, + Reimagined.RunStartVbn.LowPart, + Reimagined.RunStartVbn.LowPart + Reimagined.SectorCount.LowPart); + Found->RunStartVbn.QuadPart = Reimagined.RunStartVbn.QuadPart + Reimagined.SectorCount.QuadPart; + Found->StartingLbn.QuadPart = Reimagined.StartingLbn.QuadPart + Reimagined.SectorCount.QuadPart; + + DPRINT("Again\n"); + return MCB_BUMP_AGAIN; } /* * @unimplemented + */ +BOOLEAN +NTAPI +FsRtlSplitBaseMcb(IN PBASE_MCB Mcb, + IN LONGLONG Vbn, + IN LONGLONG Amount) +{ + ULONG Result; + LARGE_MCB_MAPPING_ENTRY Node; + PLARGE_MCB_MAPPING_ENTRY Existing = NULL; + + Node.RunStartVbn.QuadPart = Vbn; + Node.SectorCount.QuadPart = 0; + + Existing = RtlLookupElementGenericTable(Mcb->Mapping, &Node); + + if (Existing) + { + // We're in the middle of a run + LARGE_MCB_MAPPING_ENTRY UpperPart; + LARGE_MCB_MAPPING_ENTRY LowerPart; + PLARGE_MCB_MAPPING_ENTRY InsertedUpper; + + UpperPart.RunStartVbn.QuadPart = Node.RunStartVbn.QuadPart + Amount; + UpperPart.SectorCount.QuadPart = Existing->RunStartVbn.QuadPart + + (Existing->SectorCount.QuadPart - Node.RunStartVbn.QuadPart); + UpperPart.StartingLbn.QuadPart = Existing->StartingLbn.QuadPart + + (Node.RunStartVbn.QuadPart - Existing->RunStartVbn.QuadPart); + LowerPart.RunStartVbn.QuadPart = Existing->RunStartVbn.QuadPart; + LowerPart.SectorCount.QuadPart = Node.RunStartVbn.QuadPart - Existing->RunStartVbn.QuadPart; + LowerPart.StartingLbn.QuadPart = Existing->StartingLbn.QuadPart; + + Node = UpperPart; + + DPRINT("Loop: %x\n", Node.RunStartVbn.LowPart); + while ((Result = McbBump(Mcb, &Node)) == MCB_BUMP_AGAIN) + { + DPRINT("Node: %x\n", Node.RunStartVbn.LowPart); + } + DPRINT("Done\n"); + + if (Result == MCB_BUMP_NO_MORE) + { + Node = *Existing; + RemoveHeadList(&Existing->Sequence); + RtlDeleteElementGenericTable(Mcb->Mapping, Existing); + Mcb->PairCount--; + + // Adjust the element we found. + Existing->SectorCount = LowerPart.SectorCount; + + InsertedUpper = RtlInsertElementGenericTable + (Mcb->Mapping, &UpperPart, sizeof(UpperPart), NULL); + if (!InsertedUpper) + { + // Just make it like it was + Existing->SectorCount = Node.SectorCount; + return FALSE; + } + InsertHeadList(GET_LIST_HEAD(Mcb->Mapping), &InsertedUpper->Sequence); + Mcb->PairCount++; + } + else + { + Node.RunStartVbn.QuadPart = Vbn; + Node.SectorCount.QuadPart = Amount; + while ((Result = McbBump(Mcb, &Node)) == MCB_BUMP_AGAIN); + return Result == MCB_BUMP_NO_MORE; + } + } + + DPRINT("Done\n"); + + return TRUE; +} + +/* + * @implemented */ BOOLEAN NTAPI @@ -307,19 +805,62 @@ IN LONGLONG Vbn, IN LONGLONG Amount) { - KeBugCheck(FILE_SYSTEM); - return FALSE; + BOOLEAN Result; + + DPRINT("FsRtlSplitLargeMcb %x, Vbn %x, Amount %x\n", Mcb, (ULONG)Vbn, (ULONG)Amount); + + KeAcquireGuardedMutex(Mcb->GuardedMutex); + Result = FsRtlSplitBaseMcb(&(Mcb->BaseMcb), + Vbn, + Amount); + KeReleaseGuardedMutex(Mcb->GuardedMutex); + + DPRINT("Done %d\n", Result); + + return Result; } /* * @unimplemented + */ +VOID +NTAPI +FsRtlTruncateBaseMcb(IN PBASE_MCB Mcb, + IN LONGLONG Vbn) +{ + if (!Vbn) + { + FsRtlResetBaseMcb(Mcb); + } + else + { + LARGE_MCB_MAPPING_ENTRY Truncate; + PLARGE_MCB_MAPPING_ENTRY Found; + Truncate.RunStartVbn.QuadPart = Vbn; + Truncate.SectorCount.QuadPart = (1ull<<62) - Truncate.RunStartVbn.QuadPart; + while ((Found = RtlLookupElementGenericTable(Mcb->Mapping, &Truncate))) + { + RemoveEntryList(&Found->Sequence); + RtlDeleteElementGenericTable(Mcb->Mapping, Found); + Mcb->PairCount--; + } + } +} + +/* + * @implemented */ VOID NTAPI FsRtlTruncateLargeMcb(IN PLARGE_MCB Mcb, IN LONGLONG Vbn) { - KeBugCheck(FILE_SYSTEM); + DPRINT("FsRtlTruncateLargeMcb %x Vbn %x\n", Mcb, (ULONG)Vbn); + KeAcquireGuardedMutex(Mcb->GuardedMutex); + FsRtlTruncateBaseMcb(&(Mcb->BaseMcb), + Vbn); + KeReleaseGuardedMutex(Mcb->GuardedMutex); + DPRINT("Done\n"); } /* @@ -327,32 +868,33 @@ */ VOID NTAPI -FsRtlTruncateMcb (IN PMCB Mcb, - IN VBN Vbn) -{ - /* Call the newer function */ - FsRtlTruncateLargeMcb(&Mcb->DummyFieldThatSizesThisStructureCorrectly, - (LONGLONG)Vbn); -} - -/* - * @unimplemented +FsRtlUninitializeBaseMcb(IN PBASE_MCB Mcb) +{ + FsRtlResetBaseMcb(Mcb); + + if ((Mcb->PoolType == PagedPool) && (Mcb->MaximumPairCount == MAXIMUM_PAIR_COUNT)) + { + ExFreeToPagedLookasideList(&FsRtlFirstMappingLookasideList, + Mcb->Mapping); + } + else + { + ExFreePoolWithTag(Mcb->Mapping, 'FSBC'); + } +} + +/* + * @implemented */ VOID NTAPI FsRtlUninitializeLargeMcb(IN PLARGE_MCB Mcb) { - KeBugCheck(FILE_SYSTEM); -} - -/* - * @implemented - */ -VOID -NTAPI -FsRtlUninitializeMcb(IN PMCB Mcb) -{ - /* Call the newer function */ - FsRtlUninitializeLargeMcb(&Mcb->DummyFieldThatSizesThisStructureCorrectly); -} - + if (Mcb->GuardedMutex) + { + ExFreeToNPagedLookasideList(&FsRtlFastMutexLookasideList, + Mcb->GuardedMutex); + FsRtlUninitializeBaseMcb(&(Mcb->BaseMcb)); + } +} + Added: trunk/reactos/ntoskrnl/fsrtl/mcb.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/fsrtl/mcb.c?rev=5…
============================================================================== --- trunk/reactos/ntoskrnl/fsrtl/mcb.c (added) +++ trunk/reactos/ntoskrnl/fsrtl/mcb.c [iso-8859-1] Wed Feb 29 09:18:01 2012 @@ -1,0 +1,190 @@ +/* + * PROJECT: ReactOS Kernel + * LICENSE: GPL - See COPYING in the top level directory + * FILE: ntoskrnl/fsrtl/mcb.c + * PURPOSE: Mapped Control Block (MCB) support for File System Drivers + * PROGRAMMERS: Alex Ionescu (alex.ionescu(a)reactos.org) + */ + +/* INCLUDES ******************************************************************/ + +#include <ntoskrnl.h> +#define NDEBUG +#include <debug.h> + +/* PUBLIC FUNCTIONS **********************************************************/ + +/* + * @implemented + */ +BOOLEAN +NTAPI +FsRtlAddMcbEntry(IN PMCB Mcb, + IN VBN Vbn, + IN LBN Lbn, + IN ULONG SectorCount) +{ + /* Call the newer function */ + return FsRtlAddLargeMcbEntry(&Mcb-> + DummyFieldThatSizesThisStructureCorrectly, + (LONGLONG)Vbn, + (LONGLONG)Lbn, + (LONGLONG)SectorCount); +} + +/* + * @implemented + */ +BOOLEAN +NTAPI +FsRtlGetNextMcbEntry(IN PMCB Mcb, + IN ULONG RunIndex, + OUT PVBN Vbn, + OUT PLBN Lbn, + OUT PULONG SectorCount) +{ + BOOLEAN Return = FALSE; + LONGLONG llVbn; + LONGLONG llLbn; + LONGLONG llSectorCount; + + /* Call the Large version */ + Return = FsRtlGetNextLargeMcbEntry( + &Mcb->DummyFieldThatSizesThisStructureCorrectly, + RunIndex, + &llVbn, + &llLbn, + &llSectorCount); + + /* Return the lower 32 bits */ + *Vbn = (ULONG)llVbn; + *Lbn = (ULONG)llLbn; + *SectorCount = (ULONG)llSectorCount; + + /* And return the original value */ + return Return; +} + +/* + * @implemented + */ +VOID +NTAPI +FsRtlInitializeMcb(IN PMCB Mcb, + IN POOL_TYPE PoolType) +{ + /* Call the newer function */ + FsRtlInitializeLargeMcb(&Mcb->DummyFieldThatSizesThisStructureCorrectly, + PoolType); +} + +/* + * @implemented + */ +BOOLEAN +NTAPI +FsRtlLookupLastMcbEntry(IN PMCB Mcb, + OUT PVBN Vbn, + OUT PLBN Lbn) +{ + BOOLEAN Return = FALSE; + LONGLONG llVbn = 0; + LONGLONG llLbn = 0; + + /* Call the Large version */ + Return = FsRtlLookupLastLargeMcbEntry( + &Mcb->DummyFieldThatSizesThisStructureCorrectly, + &llVbn, + &llLbn); + + /* Return the lower 32-bits */ + *Vbn = (ULONG)llVbn; + *Lbn = (ULONG)llLbn; + + /* And return the original value */ + return Return; +} + +/* + * @implemented + */ +BOOLEAN +NTAPI +FsRtlLookupMcbEntry(IN PMCB Mcb, + IN VBN Vbn, + OUT PLBN Lbn, + OUT PULONG SectorCount OPTIONAL, + OUT PULONG Index) +{ + BOOLEAN Return = FALSE; + LONGLONG llLbn; + LONGLONG llSectorCount; + + /* Call the Large version */ + Return = FsRtlLookupLargeMcbEntry(&Mcb-> + DummyFieldThatSizesThisStructureCorrectly, + (LONGLONG)Vbn, + &llLbn, + &llSectorCount, + NULL, + NULL, + Index); + + /* Return the lower 32-bits */ + *Lbn = (ULONG)llLbn; + if (SectorCount) *SectorCount = (ULONG)llSectorCount; + + /* And return the original value */ + return Return; +} + +/* + * @implemented + */ +ULONG +NTAPI +FsRtlNumberOfRunsInMcb(IN PMCB Mcb) +{ + /* Call the newer function */ + return FsRtlNumberOfRunsInLargeMcb( + &Mcb->DummyFieldThatSizesThisStructureCorrectly); +} + +/* + * @implemented + */ +VOID +NTAPI +FsRtlRemoveMcbEntry(IN PMCB Mcb, + IN VBN Vbn, + IN ULONG SectorCount) +{ + /* Call the large function */ + FsRtlRemoveLargeMcbEntry(&Mcb->DummyFieldThatSizesThisStructureCorrectly, + (LONGLONG)Vbn, + (LONGLONG)SectorCount); +} + +/* + * @implemented + */ +VOID +NTAPI +FsRtlTruncateMcb(IN PMCB Mcb, + IN VBN Vbn) +{ + /* Call the newer function */ + FsRtlTruncateLargeMcb(&Mcb->DummyFieldThatSizesThisStructureCorrectly, + (LONGLONG)Vbn); +} + +/* + * @implemented + */ +VOID +NTAPI +FsRtlUninitializeMcb(IN PMCB Mcb) +{ + /* Call the newer function */ + FsRtlUninitializeLargeMcb(&Mcb->DummyFieldThatSizesThisStructureCorrectly); +} Propchange: trunk/reactos/ntoskrnl/fsrtl/mcb.c ------------------------------------------------------------------------------ svn:eol-style = native Modified: trunk/reactos/ntoskrnl/fsrtl/notify.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/fsrtl/notify.c?re…
============================================================================== --- trunk/reactos/ntoskrnl/fsrtl/notify.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/fsrtl/notify.c [iso-8859-1] Wed Feb 29 09:18:01 2012 @@ -12,6 +12,68 @@ #define NDEBUG #include <debug.h> +/* PRIVATE FUNCTIONS *********************************************************/ + +PNOTIFY_CHANGE +FsRtlIsNotifyOnList(IN PLIST_ENTRY NotifyList, + IN PVOID FsContext) +{ + PLIST_ENTRY NextEntry; + PNOTIFY_CHANGE NotifyChange; + + if (!IsListEmpty(NotifyList)) + { + /* Browse the notifications list to find the matching entry */ + for (NextEntry = NotifyList->Flink; + NextEntry != NotifyList; + NextEntry = NextEntry->Flink) + { + NotifyChange = CONTAINING_RECORD(NextEntry, NOTIFY_CHANGE, NotifyList); + /* If the current record matches with the given context, it's the good one */ + if (NotifyChange->FsContext == FsContext) + { + return NotifyChange; + } + } + } + return NULL; +} + +VOID +FORCEINLINE +FsRtlNotifyAcquireFastMutex(IN PREAL_NOTIFY_SYNC RealNotifySync) +{ + ULONG_PTR CurrentThread = (ULONG_PTR)KeGetCurrentThread(); + + /* Only acquire fast mutex if it's not already acquired by the current thread */ + if (RealNotifySync->OwningThread != CurrentThread) + { + ExAcquireFastMutexUnsafe(&(RealNotifySync->FastMutex)); + RealNotifySync->OwningThread = CurrentThread; + } + /* Whatever the case, keep trace of the attempt to acquire fast mutex */ + RealNotifySync->OwnerCount++; +} + +VOID +FsRtlNotifyCompleteIrpList(IN PNOTIFY_CHANGE NotifyChange, + IN NTSTATUS Status) +{ +} + +VOID +FORCEINLINE +FsRtlNotifyReleaseFastMutex(IN PREAL_NOTIFY_SYNC RealNotifySync) +{ + RealNotifySync->OwnerCount--; + /* Release the fast mutex only if no other instance needs it */ + if (!RealNotifySync->OwnerCount) + { + ExReleaseFastMutexUnsafe(&(RealNotifySync->FastMutex)); + RealNotifySync->OwningThread = (ULONG_PTR)0; + } +} + /* PUBLIC FUNCTIONS **********************************************************/ /*++ @@ -44,8 +106,7 @@ * * @return None * - * @remarks This function only redirects to FsRtlNotifyFullChangeDirectory. - * So, it's better to call the entire function. + * @remarks This function only redirects to FsRtlNotifyFilterChangeDirectory. * *--*/ VOID @@ -58,32 +119,33 @@ IN ULONG CompletionFilter, IN PIRP NotifyIrp) { - FsRtlNotifyFullChangeDirectory(NotifySync, - NotifyList, - FsContext, - FullDirectoryName, - WatchTree, - TRUE, - CompletionFilter, - NotifyIrp, - NULL, - NULL); + FsRtlNotifyFilterChangeDirectory(NotifySync, + NotifyList, + FsContext, + FullDirectoryName, + WatchTree, + TRUE, + CompletionFilter, + NotifyIrp, + NULL, + NULL, + NULL); } /*++ * @name FsRtlNotifyCleanup - * @unimplemented + * @implemented * * Called by FSD when all handles to FileObject (identified by FsContext) are closed * * @param NotifySync - * FILLME - * - * @param NotifyList - * FILLME + * Synchronization object pointer + * + * @param NotifyList + * Notify list pointer (to head) * * @param FsContext - * FILLME + * Used to identify the notify structure * * @return None * @@ -96,7 +158,67 @@ IN PLIST_ENTRY NotifyList, IN PVOID FsContext) { - KeBugCheck(FILE_SYSTEM); + PNOTIFY_CHANGE NotifyChange; + PREAL_NOTIFY_SYNC RealNotifySync; + PSECURITY_SUBJECT_CONTEXT SubjectContext = NULL; + + /* Get real structure hidden behind the opaque pointer */ + RealNotifySync = (PREAL_NOTIFY_SYNC)NotifySync; + + /* Acquire the fast mutex */ + FsRtlNotifyAcquireFastMutex(RealNotifySync); + + _SEH2_TRY + { + /* Find if there's a matching notification with the FsContext */ + NotifyChange = FsRtlIsNotifyOnList(NotifyList, FsContext); + if (NotifyChange) + { + /* Mark it as to know that cleanup is in process */ + NotifyChange->Flags |= CLEANUP_IN_PROCESS; + + /* If there are pending IRPs, complete them using the STATUS_NOTIFY_CLEANUP status */ + if (!IsListEmpty(NotifyChange->NotifyIrps)) + { + FsRtlNotifyCompleteIrpList(NotifyChange, STATUS_NOTIFY_CLEANUP); + } + /* Remove from the list */ + RemoveEntryList(NotifyChange->NotifyList); + + /* Downcrease reference number and if 0 is reached, it's time to do complete cleanup */ + if (!InterlockedDecrement((PLONG)&(NotifyChange->ReferenceCount))) + { + /* In case there was an allocated buffer, free it */ + if (NotifyChange->AllocatedBuffer) + { + PsReturnProcessPagedPoolQuota(NotifyChange->OwningProcess, NotifyChange->ThisBufferLength); + ExFreePool(NotifyChange->AllocatedBuffer); + } + + /* In case there the string was set, get the captured subject security context */ + if (NotifyChange->FullDirectoryName) + { + SubjectContext = NotifyChange->SubjectContext; + } + + /* Finally, free the notification, as it's not needed anymore */ + ExFreePool(NotifyChange); + } + } + } + _SEH2_FINALLY + { + /* Release fast mutex */ + FsRtlNotifyReleaseFastMutex(RealNotifySync); + + /* If the subject security context was captured, release and free it */ + if (SubjectContext) + { + SeReleaseSubjectContext(SubjectContext); + ExFreePool(SubjectContext); + } + } + _SEH2_END; } /*++ @@ -219,43 +341,46 @@ /*++ * @name FsRtlNotifyFullChangeDirectory - * @unimplemented - * - * FILLME - * - * @param NotifySync - * FILLME - * - * @param NotifyList - * FILLME + * @implemented + * + * Lets FSD know if changes occures in the specified directory. + * + * @param NotifySync + * Synchronization object pointer + * + * @param NotifyList + * Notify list pointer (to head) * * @param FsContext - * FILLME + * Used to identify the notify structure * * @param FullDirectoryName - * FILLME + * String (A or W) containing the full directory name * * @param WatchTree - * FILLME + * True to notify changes in subdirectories too * * @param IgnoreBuffer - * FILLME + * True to reenumerate directory. It's ignored it NotifyIrp is null * * @param CompletionFilter - * FILLME - * - * @param Irp - * FILLME + * Used to define types of changes to notify + * + * @param NotifyIrp + * IRP pointer to complete notify operation. It can be null * * @param TraverseCallback - * FILLME + * Pointer to a callback function. It's called each time a change is + * done in a subdirectory of the main directory. It's ignored it NotifyIrp + * is null * * @param SubjectContext - * FILLME - * - * @return None - * - * @remarks None + * Pointer to pass to SubjectContext member of TraverseCallback. + * It's freed after use. It's ignored it NotifyIrp is null + * + * @return None + * + * @remarks This function only redirects to FsRtlNotifyFilterChangeDirectory. * *--*/ VOID @@ -267,49 +392,60 @@ IN BOOLEAN WatchTree, IN BOOLEAN IgnoreBuffer, IN ULONG CompletionFilter, - IN PIRP Irp, + IN PIRP NotifyIrp, IN PCHECK_FOR_TRAVERSE_ACCESS TraverseCallback OPTIONAL, IN PSECURITY_SUBJECT_CONTEXT SubjectContext OPTIONAL) { - KeBugCheck(FILE_SYSTEM); + FsRtlNotifyFilterChangeDirectory(NotifySync, + NotifyList, + FsContext, + FullDirectoryName, + WatchTree, + IgnoreBuffer, + CompletionFilter, + NotifyIrp, + TraverseCallback, + SubjectContext, + NULL); } /*++ * @name FsRtlNotifyFullReportChange - * @unimplemented - * - * FILLME - * - * @param NotifySync - * FILLME - * - * @param NotifyList - * FILLME + * @implemented + * + * Complets the pending notify IRPs. + * + * @param NotifySync + * Synchronization object pointer + * + * @param NotifyList + * Notify list pointer (to head) * * @param FullTargetName - * FILLME + * String (A or W) containing the full directory name that changed * * @param TargetNameOffset - * FILLME + * Offset, in FullTargetName, of the final component that is in the changed directory * * @param StreamName - * FILLME + * String (A or W) containing a stream name * * @param NormalizedParentName - * FILLME + * String (A or W) containing the full directory name that changed with long names * * @param FilterMatch - * FILLME + * Flags that will be compared to the completion filter * * @param Action - * FILLME + * Action code to store in user's buffer * * @param TargetContext - * FILLME - * - * @return None - * - * @remarks None + * Pointer to a callback function. It's called each time a change is + * done in a subdirectory of the main directory. + * + * @return None + * + * @remarks This function only redirects to FsRtlNotifyFilterReportChange. * *--*/ VOID @@ -324,54 +460,73 @@ IN ULONG Action, IN PVOID TargetContext) { - KeBugCheck(FILE_SYSTEM); + FsRtlNotifyFilterReportChange(NotifySync, + NotifyList, + FullTargetName, + TargetNameOffset, + StreamName, + NormalizedParentName, + FilterMatch, + Action, + TargetContext, + NULL); } /*++ * @name FsRtlNotifyInitializeSync - * @unimplemented - * - * FILLME - * - * @param NotifySync - * FILLME - * - * @return None - * - * @remarks None + * @implemented + * + * Allocates the internal structure associated with notifications. + * + * @param NotifySync + * Opaque pointer. It will receive the address of the allocated internal structure. + * + * @return None + * + * @remarks This function raise an exception in case of a failure. * *--*/ VOID NTAPI FsRtlNotifyInitializeSync(IN PNOTIFY_SYNC *NotifySync) { - KeBugCheck(FILE_SYSTEM); + PREAL_NOTIFY_SYNC RealNotifySync; + + *NotifySync = NULL; + + RealNotifySync = ExAllocatePoolWithTag(NonPagedPool | POOL_RAISE_IF_ALLOCATION_FAILURE, + sizeof(REAL_NOTIFY_SYNC), TAG('F', 'S', 'N', 'S')); + ExInitializeFastMutex(&(RealNotifySync->FastMutex)); + RealNotifySync->OwningThread = 0; + RealNotifySync->OwnerCount = 0; + + *NotifySync = RealNotifySync; } /*++ * @name FsRtlNotifyReportChange - * @unimplemented - * - * FILLME - * - * @param NotifySync - * FILLME - * - * @param NotifyList - * FILLME + * @implemented + * + * Complets the pending notify IRPs. + * + * @param NotifySync + * Synchronization object pointer + * + * @param NotifyList + * Notify list pointer (to head) * * @param FullTargetName - * FILLME + * String (A or W) containing the full directory name that changed * * @param FileNamePartLength - * FILLME + * Length of the final component that is in the changed directory * * @param FilterMatch - * FILLME - * - * @return None - * - * @remarks None + * Flags that will be compared to the completion filter + * + * @return None + * + * @remarks This function only redirects to FsRtlNotifyFilterReportChange. * *--*/ VOID @@ -382,11 +537,20 @@ IN PUSHORT FileNamePartLength, IN ULONG FilterMatch) { - KeBugCheck(FILE_SYSTEM); -} - -/*++ - * @name FsRtlCurrentBatchOplock + FsRtlNotifyFilterReportChange(NotifySync, + NotifyList, + FullTargetName, + FullTargetName->Length - *FileNamePartLength, + NULL, + NULL, + FilterMatch, + 0, + NULL, + NULL); +} + +/*++ + * @name FsRtlNotifyUninitializeSync * @implemented * * Uninitialize a NOTIFY_SYNC object @@ -404,6 +568,10 @@ NTAPI FsRtlNotifyUninitializeSync(IN PNOTIFY_SYNC *NotifySync) { - KeBugCheck(FILE_SYSTEM); -} - + if (*NotifySync) + { + ExFreePoolWithTag(*NotifySync, TAG('F', 'S', 'N', 'S')); + *NotifySync = NULL; + } +} + Modified: trunk/reactos/ntoskrnl/include/internal/fsrtl.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
============================================================================== --- trunk/reactos/ntoskrnl/include/internal/fsrtl.h [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/include/internal/fsrtl.h [iso-8859-1] Wed Feb 29 09:18:01 2012 @@ -5,6 +5,10 @@ * PURPOSE: Internal header for the File System Runtime Library * PROGRAMMERS: Alex Ionescu (alex.ionescu(a)reactos.org) */ + +#ifndef TAG +#define TAG(w,x,y,z) (((w)<<24)|((x)<<16)|((y)<<8)|(z)) +#endif // // Define this if you want debugging support @@ -36,7 +40,7 @@ if (x & FsRtlpTraceLevel) DbgPrint(__VA_ARGS__) #endif #else -#define FSTRACE(x, fmt, ...) DPRINT(fmt, ##__VA_ARGS__) +#define FSTRACE(x, ...) DPRINT(__VA_ARGS__) #endif // @@ -45,11 +49,67 @@ #define FSRTL_MAX_RESOURCES 16 // +// Number of maximum pair count per MCB +// +#define MAXIMUM_PAIR_COUNT 15 + +// +// Notifications flags +// +#define CLEANUP_IN_PROCESS 4 + +// +// Internal structure for NOTIFY_SYNC +// +typedef struct _REAL_NOTIFY_SYNC +{ + FAST_MUTEX FastMutex; + ULONG_PTR OwningThread; + ULONG OwnerCount; +} REAL_NOTIFY_SYNC, * PREAL_NOTIFY_SYNC; + +// +// Internal structure for notifications +// +typedef struct _NOTIFY_CHANGE +{ + PREAL_NOTIFY_SYNC NotifySync; + PVOID FsContext; + PVOID StreamID; + PCHECK_FOR_TRAVERSE_ACCESS TraverseCallback; + PSECURITY_SUBJECT_CONTEXT SubjectContext; + PSTRING FullDirectoryName; + PLIST_ENTRY NotifyList; + PLIST_ENTRY NotifyIrps; + PFILTER_REPORT_CHANGE FilterCallback; + USHORT Flags; + UCHAR CharacterSize; + ULONG CompletionFilter; + PVOID AllocatedBuffer; + PVOID Buffer; + ULONG BufferLength; + ULONG ThisBufferLength; + ULONG DataLength; + ULONG LastEntry; + ULONG ReferenceCount; + PEPROCESS OwningProcess; +} NOTIFY_CHANGE, *PNOTIFY_CHANGE; + +// +// Internal structure for MCB Mapping pointer +// +typedef struct _INT_MAPPING +{ + VBN Vbn; + LBN Lbn; +} INT_MAPPING, *PINT_MAPPING; + +// // Initialization Routines // -BOOLEAN +VOID NTAPI -FsRtlInitSystem( +FsRtlInitializeLargeMcbs( VOID ); @@ -62,6 +122,12 @@ IN PFILE_OBJECT FileObject ); +BOOLEAN +NTAPI +FsRtlInitSystem( + VOID +); + // // Global data inside the File System Runtime Library //
12 years, 10 months
1
0
0
0
[janderwald] 55913: [USBOHCI] - Fix regressions introduced by libusb
by janderwald@svn.reactos.org
Author: janderwald Date: Wed Feb 29 09:15:42 2012 New Revision: 55913 URL:
http://svn.reactos.org/svn/reactos?rev=55913&view=rev
Log: [USBOHCI] - Fix regressions introduced by libusb Modified: trunk/reactos/drivers/usb/usbohci/hardware.cpp trunk/reactos/drivers/usb/usbohci/usb_queue.cpp trunk/reactos/drivers/usb/usbohci/usb_request.cpp trunk/reactos/drivers/usb/usbohci/usbohci.h trunk/reactos/lib/drivers/libusb/hcd_controller.cpp trunk/reactos/lib/drivers/libusb/hub_controller.cpp trunk/reactos/lib/drivers/libusb/libusb.cpp trunk/reactos/lib/drivers/libusb/libusb.h trunk/reactos/lib/drivers/libusb/memory_manager.cpp trunk/reactos/lib/drivers/libusb/usb_device.cpp Modified: trunk/reactos/drivers/usb/usbohci/hardware.cpp URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/usb/usbohci/hardwa…
============================================================================== --- trunk/reactos/drivers/usb/usbohci/hardware.cpp [iso-8859-1] (original) +++ trunk/reactos/drivers/usb/usbohci/hardware.cpp [iso-8859-1] Wed Feb 29 09:15:42 2012 @@ -32,7 +32,7 @@ NTAPI StatusChangeWorkItemRoutine(PVOID Context); -class CUSBHardwareDevice : public IUSBHardwareDevice +class CUSBHardwareDevice : public IOHCIHardwareDevice { public: STDMETHODIMP QueryInterface( REFIID InterfaceId, PVOID* Interface); @@ -125,6 +125,7 @@ } NTSTATUS +STDMETHODCALLTYPE CUSBHardwareDevice::Initialize( PDRIVER_OBJECT DriverObject, PDEVICE_OBJECT FunctionalDeviceObject, @@ -135,6 +136,7 @@ PCI_COMMON_CONFIG PciConfig; NTSTATUS Status; ULONG BytesRead; + PUSBQUEUE Queue; DPRINT("CUSBHardwareDevice::Initialize\n"); @@ -151,12 +153,18 @@ // // Create the UsbQueue class that will handle the Asynchronous and Periodic Schedules // - Status = CreateUSBQueue((PUSBQUEUE*)&m_UsbQueue); + Status = CreateUSBQueue(&Queue); if (!NT_SUCCESS(Status)) { DPRINT1("Failed to create UsbQueue!\n"); return Status; } + + // get ohci queue + m_UsbQueue = POHCIQUEUE(Queue); + + // sanity check + ASSERT(m_UsbQueue); // // store device objects @@ -205,6 +213,7 @@ } NTSTATUS +STDMETHODCALLTYPE CUSBHardwareDevice::PnpStart( PCM_RESOURCE_LIST RawResources, PCM_RESOURCE_LIST TranslatedResources) @@ -351,7 +360,7 @@ // // Initialize the UsbQueue now that we have an AdapterObject. // - Status = m_UsbQueue->Initialize(PUSBHARDWAREDEVICE(this), m_Adapter, m_MemoryManager, NULL); + Status = m_UsbQueue->Initialize(this, m_Adapter, m_MemoryManager, NULL); if (!NT_SUCCESS(Status)) { DPRINT1("Failed to Initialize the UsbQueue\n"); @@ -383,6 +392,7 @@ } NTSTATUS +STDMETHODCALLTYPE CUSBHardwareDevice::PnpStop(void) { UNIMPLEMENTED @@ -390,6 +400,7 @@ } NTSTATUS +STDMETHODCALLTYPE CUSBHardwareDevice::GetDeviceDetails( OUT OPTIONAL PUSHORT VendorId, OUT OPTIONAL PUSHORT DeviceId, @@ -431,7 +442,9 @@ return STATUS_SUCCESS; } -NTSTATUS CUSBHardwareDevice::GetDMA( +NTSTATUS +STDMETHODCALLTYPE +CUSBHardwareDevice::GetDMA( OUT struct IDMAMemoryManager **OutDMAMemoryManager) { if (!m_MemoryManager) @@ -441,6 +454,7 @@ } NTSTATUS +STDMETHODCALLTYPE CUSBHardwareDevice::GetUSBQueue( OUT struct IUSBQueue **OutUsbQueue) { @@ -636,6 +650,7 @@ } VOID +STDMETHODCALLTYPE CUSBHardwareDevice::GetBulkHeadEndpointDescriptor( struct _OHCI_ENDPOINT_DESCRIPTOR ** OutDescriptor) { @@ -643,6 +658,7 @@ } VOID +STDMETHODCALLTYPE CUSBHardwareDevice::GetInterruptEndpointDescriptors( struct _OHCI_ENDPOINT_DESCRIPTOR *** OutDescriptor) { @@ -650,6 +666,7 @@ } VOID +STDMETHODCALLTYPE CUSBHardwareDevice::GetIsochronousHeadEndpointDescriptor( struct _OHCI_ENDPOINT_DESCRIPTOR ** OutDescriptor) { @@ -657,6 +674,7 @@ } VOID +STDMETHODCALLTYPE CUSBHardwareDevice::HeadEndpointDescriptorModified( ULONG Type) { @@ -677,6 +695,7 @@ } VOID +STDMETHODCALLTYPE CUSBHardwareDevice::GetControlHeadEndpointDescriptor( struct _OHCI_ENDPOINT_DESCRIPTOR ** OutDescriptor) { @@ -1009,6 +1028,7 @@ } NTSTATUS +STDMETHODCALLTYPE CUSBHardwareDevice::ResetPort( IN ULONG PortIndex) { @@ -1018,6 +1038,7 @@ } NTSTATUS +STDMETHODCALLTYPE CUSBHardwareDevice::GetPortStatus( ULONG PortId, OUT USHORT *PortStatus, @@ -1080,6 +1101,7 @@ } NTSTATUS +STDMETHODCALLTYPE CUSBHardwareDevice::ClearPortStatus( ULONG PortId, ULONG Status) @@ -1154,6 +1176,7 @@ NTSTATUS +STDMETHODCALLTYPE CUSBHardwareDevice::SetPortFeature( ULONG PortId, ULONG Feature) @@ -1244,6 +1267,7 @@ VOID +STDMETHODCALLTYPE CUSBHardwareDevice::SetStatusChangeEndpointCallBack( PVOID CallBack, PVOID Context) @@ -1253,6 +1277,7 @@ } VOID +STDMETHODCALLTYPE CUSBHardwareDevice::GetCurrentFrameNumber( PULONG FrameNumber) { @@ -1548,6 +1573,7 @@ } NTSTATUS +NTAPI CreateUSBHardware( PUSBHARDWAREDEVICE *OutHardware) { Modified: trunk/reactos/drivers/usb/usbohci/usb_queue.cpp URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/usb/usbohci/usb_qu…
============================================================================== --- trunk/reactos/drivers/usb/usbohci/usb_queue.cpp [iso-8859-1] (original) +++ trunk/reactos/drivers/usb/usbohci/usb_queue.cpp [iso-8859-1] Wed Feb 29 09:15:42 2012 @@ -11,7 +11,7 @@ #include "usbohci.h" #include "hardware.h" -class CUSBQueue : public IUSBQueue +class CUSBQueue : public IOHCIQueue { public: STDMETHODIMP QueryInterface( REFIID InterfaceId, PVOID* Interface); @@ -86,17 +86,25 @@ } NTSTATUS +STDMETHODCALLTYPE CUSBQueue::Initialize( IN PUSBHARDWAREDEVICE Hardware, IN PDMA_ADAPTER AdapterObject, IN PDMAMEMORYMANAGER MemManager, IN OPTIONAL PKSPIN_LOCK Lock) { + if (!Hardware) + { + // WTF + DPRINT1("[USBOHCI] Failed to initialize queue\n"); + return STATUS_UNSUCCESSFUL; + } + // // store hardware // m_Hardware = POHCIHARDWAREDEVICE(Hardware); - + ASSERT(m_Hardware); // // get bulk endpoint descriptor @@ -288,6 +296,7 @@ NTSTATUS +STDMETHODCALLTYPE CUSBQueue::AddUSBRequest( IUSBRequest * Req) { @@ -337,6 +346,7 @@ } NTSTATUS +STDMETHODCALLTYPE CUSBQueue::CreateUSBRequest( IUSBRequest **OutRequest) { @@ -696,6 +706,7 @@ } VOID +STDMETHODCALLTYPE CUSBQueue::TransferDescriptorCompletionCallback( ULONG TransferDescriptorLogicalAddress) { @@ -860,6 +871,7 @@ } NTSTATUS +STDMETHODCALLTYPE CUSBQueue::AbortDevicePipe( IN UCHAR DeviceAddress, IN PUSB_ENDPOINT_DESCRIPTOR EndpointDescriptor) @@ -973,6 +985,7 @@ NTSTATUS +NTAPI CreateUSBQueue( PUSBQUEUE *OutUsbQueue) { Modified: trunk/reactos/drivers/usb/usbohci/usb_request.cpp URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/usb/usbohci/usb_re…
============================================================================== --- trunk/reactos/drivers/usb/usbohci/usb_request.cpp [iso-8859-1] (original) +++ trunk/reactos/drivers/usb/usbohci/usb_request.cpp [iso-8859-1] Wed Feb 29 09:15:42 2012 @@ -13,7 +13,7 @@ #include "usbohci.h" #include "hardware.h" -class CUSBRequest : public IUSBRequest +class CUSBRequest : public IOHCIRequest { public: STDMETHODIMP QueryInterface( REFIID InterfaceId, PVOID* Interface); @@ -157,6 +157,7 @@ //---------------------------------------------------------------------------------------- NTSTATUS +STDMETHODCALLTYPE CUSBRequest::InitializeWithSetupPacket( IN PDMAMEMORYMANAGER DmaManager, IN PUSB_DEFAULT_PIPE_SETUP_PACKET SetupPacket, @@ -212,6 +213,7 @@ } //---------------------------------------------------------------------------------------- NTSTATUS +STDMETHODCALLTYPE CUSBRequest::InitializeWithIrp( IN PDMAMEMORYMANAGER DmaManager, IN struct IUSBDevice* Device, @@ -422,6 +424,7 @@ //---------------------------------------------------------------------------------------- BOOLEAN +STDMETHODCALLTYPE CUSBRequest::IsRequestComplete() { // @@ -443,6 +446,7 @@ } //---------------------------------------------------------------------------------------- ULONG +STDMETHODCALLTYPE CUSBRequest::GetTransferType() { // @@ -483,6 +487,7 @@ } UCHAR +STDMETHODCALLTYPE CUSBRequest::GetInterval() { ASSERT(m_EndpointDescriptor); @@ -568,6 +573,7 @@ //---------------------------------------------------------------------------------------- UCHAR +STDMETHODCALLTYPE CUSBRequest::GetDeviceAddress() { PIO_STACK_LOCATION IoStack; @@ -1560,11 +1566,13 @@ //---------------------------------------------------------------------------------------- NTSTATUS +STDMETHODCALLTYPE CUSBRequest::GetEndpointDescriptor( struct _OHCI_ENDPOINT_DESCRIPTOR ** OutDescriptor) { ULONG TransferType; NTSTATUS Status; + // // get transfer type @@ -1592,6 +1600,8 @@ break; } + + if (NT_SUCCESS(Status)) { // @@ -1613,6 +1623,7 @@ //---------------------------------------------------------------------------------------- VOID +STDMETHODCALLTYPE CUSBRequest::GetResultStatus( OUT OPTIONAL NTSTATUS * NtStatusCode, OUT OPTIONAL PULONG UrbStatusCode) @@ -1646,6 +1657,7 @@ } VOID +STDMETHODCALLTYPE CUSBRequest::FreeEndpointDescriptor( struct _OHCI_ENDPOINT_DESCRIPTOR * OutDescriptor) { @@ -1878,12 +1890,10 @@ TransferDescriptor = (POHCI_GENERAL_TD)TransferDescriptor->NextLogicalDescriptor; } } - - - } VOID +STDMETHODCALLTYPE CUSBRequest::CompletionCallback() { PIO_STACK_LOCATION IoStack; @@ -1943,20 +1953,9 @@ } } -#if 0 -//----------------------------------------------------------------------------------------- -BOOLEAN -CUSBRequest::IsQueueHeadComplete( - struct _QUEUE_HEAD * QueueHead) -{ - UNIMPLEMENTED - return TRUE; -} -#endif - - //----------------------------------------------------------------------------------------- NTSTATUS +NTAPI InternalCreateUSBRequest( PUSBREQUEST *OutRequest) { Modified: trunk/reactos/drivers/usb/usbohci/usbohci.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/usb/usbohci/usbohc…
============================================================================== --- trunk/reactos/drivers/usb/usbohci/usbohci.h [iso-8859-1] (original) +++ trunk/reactos/drivers/usb/usbohci/usbohci.h [iso-8859-1] Wed Feb 29 09:15:42 2012 @@ -59,20 +59,23 @@ (VOID)((!(exp)) ? \ RtlAssert((PVOID) #exp, (PVOID)__FILE__, __LINE__, NULL ), FALSE : TRUE) +extern "C" +{ + // // hardware.cpp // -NTSTATUS CreateUSBHardware(PUSBHARDWAREDEVICE *OutHardware); +NTSTATUS NTAPI CreateUSBHardware(PUSBHARDWAREDEVICE *OutHardware); // // usb_queue.cpp // -NTSTATUS CreateUSBQueue(PUSBQUEUE *OutUsbQueue); +NTSTATUS NTAPI CreateUSBQueue(PUSBQUEUE *OutUsbQueue); // // usb_request.cpp // -NTSTATUS InternalCreateUSBRequest(PUSBREQUEST *OutRequest); - +NTSTATUS NTAPI InternalCreateUSBRequest(PUSBREQUEST *OutRequest); +} #endif Modified: trunk/reactos/lib/drivers/libusb/hcd_controller.cpp URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/libusb/hcd_con…
============================================================================== --- trunk/reactos/lib/drivers/libusb/hcd_controller.cpp [iso-8859-1] (original) +++ trunk/reactos/lib/drivers/libusb/hcd_controller.cpp [iso-8859-1] Wed Feb 29 09:15:42 2012 @@ -747,6 +747,7 @@ } NTSTATUS +NTAPI CreateHCDController( PHCDCONTROLLER *OutHcdController) { Modified: trunk/reactos/lib/drivers/libusb/hub_controller.cpp URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/libusb/hub_con…
============================================================================== --- trunk/reactos/lib/drivers/libusb/hub_controller.cpp [iso-8859-1] (original) +++ trunk/reactos/lib/drivers/libusb/hub_controller.cpp [iso-8859-1] Wed Feb 29 09:15:42 2012 @@ -3718,6 +3718,7 @@ NTSTATUS +NTAPI CreateHubController( PHUBCONTROLLER *OutHcdController) { Modified: trunk/reactos/lib/drivers/libusb/libusb.cpp URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/libusb/libusb.…
============================================================================== --- trunk/reactos/lib/drivers/libusb/libusb.cpp [iso-8859-1] (original) +++ trunk/reactos/lib/drivers/libusb/libusb.cpp [iso-8859-1] Wed Feb 29 09:15:42 2012 @@ -16,6 +16,9 @@ // DRIVER_ADD_DEVICE USBLIB_AddDevice; +extern +"C" +{ NTSTATUS NTAPI USBLIB_AddDevice( @@ -54,7 +57,11 @@ return Status; } +} +extern +"C" +{ NTSTATUS NTAPI USBLIB_Dispatch( @@ -121,3 +128,4 @@ return Status; } +} Modified: trunk/reactos/lib/drivers/libusb/libusb.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/libusb/libusb.…
============================================================================== --- trunk/reactos/lib/drivers/libusb/libusb.h [iso-8859-1] (original) +++ trunk/reactos/lib/drivers/libusb/libusb.h [iso-8859-1] Wed Feb 29 09:15:42 2012 @@ -66,35 +66,31 @@ RtlAssert((PVOID) #exp, (PVOID)__FILE__, __LINE__, NULL ), FALSE : TRUE) // hcd_controller.cpp -NTSTATUS CreateHCDController(PHCDCONTROLLER *HcdController); +extern "C" +{ +NTSTATUS NTAPI CreateHCDController(PHCDCONTROLLER *HcdController); // hardware.cpp -NTSTATUS CreateUSBHardware(PUSBHARDWAREDEVICE *OutHardware); +NTSTATUS NTAPI CreateUSBHardware(PUSBHARDWAREDEVICE *OutHardware); // misc.cpp NTSTATUS NTAPI SyncForwardIrp(PDEVICE_OBJECT DeviceObject, PIRP Irp); NTSTATUS NTAPI GetBusInterface(PDEVICE_OBJECT DeviceObject, PBUS_INTERFACE_STANDARD busInterface); // root_hub_controller.cpp -NTSTATUS CreateHubController(PHUBCONTROLLER * OutHubController); +NTSTATUS NTAPI CreateHubController(PHUBCONTROLLER * OutHubController); // memory_manager.cpp -NTSTATUS CreateDMAMemoryManager(PDMAMEMORYMANAGER *OutMemoryManager); - +NTSTATUS NTAPI CreateDMAMemoryManager(PDMAMEMORYMANAGER *OutMemoryManager); // usb_device.cpp -NTSTATUS CreateUSBDevice(PUSBDEVICE *OutDevice); - -// usb_queue.cpp -NTSTATUS CreateUSBQueue(PUSBQUEUE *OutUsbQueue); - -// usb_request.cpp -NTSTATUS InternalCreateUSBRequest(PUSBREQUEST *OutRequest); +NTSTATUS NTAPI CreateUSBDevice(PUSBDEVICE *OutDevice); // libusb.cpp NTSTATUS NTAPI USBLIB_AddDevice(PDRIVER_OBJECT DriverObject, PDEVICE_OBJECT PhysicalDeviceObject); NTSTATUS NTAPI USBLIB_Dispatch(PDEVICE_OBJECT DeviceObject, PIRP Irp); +} #endif Modified: trunk/reactos/lib/drivers/libusb/memory_manager.cpp URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/libusb/memory_…
============================================================================== --- trunk/reactos/lib/drivers/libusb/memory_manager.cpp [iso-8859-1] (original) +++ trunk/reactos/lib/drivers/libusb/memory_manager.cpp [iso-8859-1] Wed Feb 29 09:15:42 2012 @@ -335,6 +335,7 @@ } NTSTATUS +NTAPI CreateDMAMemoryManager( PDMAMEMORYMANAGER *OutMemoryManager) { Modified: trunk/reactos/lib/drivers/libusb/usb_device.cpp URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/libusb/usb_dev…
============================================================================== --- trunk/reactos/lib/drivers/libusb/usb_device.cpp [iso-8859-1] (original) +++ trunk/reactos/lib/drivers/libusb/usb_device.cpp [iso-8859-1] Wed Feb 29 09:15:42 2012 @@ -1183,6 +1183,7 @@ //---------------------------------------------------------------------------------------- NTSTATUS +NTAPI CreateUSBDevice( PUSBDEVICE *OutDevice) {
12 years, 10 months
1
0
0
0
[cgutman] 55912: [NTOSKRNL] - Fix linking of device children to respect the enumeration order instead of linking in reverse enumeration order - PCI cards (and other devices) now enumerate in the co...
by cgutman@svn.reactos.org
Author: cgutman Date: Wed Feb 29 06:08:15 2012 New Revision: 55912 URL:
http://svn.reactos.org/svn/reactos?rev=55912&view=rev
Log: [NTOSKRNL] - Fix linking of device children to respect the enumeration order instead of linking in reverse enumeration order - PCI cards (and other devices) now enumerate in the correct order Modified: trunk/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c Modified: trunk/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/io/pnpmgr/pnpmgr.…
============================================================================== --- trunk/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c [iso-8859-1] Wed Feb 29 06:08:15 2012 @@ -1128,10 +1128,17 @@ { KeAcquireSpinLock(&IopDeviceTreeLock, &OldIrql); Node->Parent = ParentNode; - Node->Sibling = ParentNode->Child; - ParentNode->Child = Node; + Node->Sibling = NULL; if (ParentNode->LastChild == NULL) + { + ParentNode->Child = Node; ParentNode->LastChild = Node; + } + else + { + ParentNode->LastChild->Sibling = Node; + ParentNode->LastChild = Node; + } KeReleaseSpinLock(&IopDeviceTreeLock, OldIrql); Node->Level = ParentNode->Level + 1; }
12 years, 10 months
1
0
0
0
[cgutman] 55911: - Missed this bit
by cgutman@svn.reactos.org
Author: cgutman Date: Wed Feb 29 05:01:31 2012 New Revision: 55911 URL:
http://svn.reactos.org/svn/reactos?rev=55911&view=rev
Log: - Missed this bit Modified: trunk/reactos/drivers/usb/usbehci/hardware.cpp Modified: trunk/reactos/drivers/usb/usbehci/hardware.cpp URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/usb/usbehci/hardwa…
============================================================================== --- trunk/reactos/drivers/usb/usbehci/hardware.cpp [iso-8859-1] (original) +++ trunk/reactos/drivers/usb/usbehci/hardware.cpp [iso-8859-1] Wed Feb 29 05:01:31 2012 @@ -202,39 +202,6 @@ m_VendorID = PciConfig.VendorID; m_DeviceID = PciConfig.DeviceID; - - if (PciConfig.Command & PCI_ENABLE_BUS_MASTER) - { - // - // master is enabled - // - return STATUS_SUCCESS; - } - - DPRINT1("PCI Configuration shows this as a non Bus Mastering device! Enabling...\n"); - - PciConfig.Command |= PCI_ENABLE_BUS_MASTER; - m_BusInterface.SetBusData(m_BusInterface.Context, PCI_WHICHSPACE_CONFIG, &PciConfig, 0, PCI_COMMON_HDR_LENGTH); - - BytesRead = (*m_BusInterface.GetBusData)(m_BusInterface.Context, - PCI_WHICHSPACE_CONFIG, - &PciConfig, - 0, - PCI_COMMON_HDR_LENGTH); - - if (BytesRead != PCI_COMMON_HDR_LENGTH) - { - DPRINT1("Failed to get pci config information!\n"); - ASSERT(FALSE); - return STATUS_SUCCESS; - } - - if (!(PciConfig.Command & PCI_ENABLE_BUS_MASTER)) - { - PciConfig.Command |= PCI_ENABLE_BUS_MASTER; - DPRINT1("Failed to enable master\n"); - return STATUS_UNSUCCESSFUL; - } return STATUS_SUCCESS; }
12 years, 10 months
1
0
0
0
[cgutman] 55910: [USBUHCI][USBOHCI][USBEHCI] - Don't modify PCI configuration in AddDevice function [USBEHCI] - Don't halt the controller while the BIOS still has control of it
by cgutman@svn.reactos.org
Author: cgutman Date: Wed Feb 29 04:58:27 2012 New Revision: 55910 URL:
http://svn.reactos.org/svn/reactos?rev=55910&view=rev
Log: [USBUHCI][USBOHCI][USBEHCI] - Don't modify PCI configuration in AddDevice function [USBEHCI] - Don't halt the controller while the BIOS still has control of it Modified: trunk/reactos/drivers/usb/usbehci/hardware.cpp trunk/reactos/drivers/usb/usbohci/hardware.cpp trunk/reactos/drivers/usb/usbuhci/hardware.cpp Modified: trunk/reactos/drivers/usb/usbehci/hardware.cpp URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/usb/usbehci/hardwa…
============================================================================== --- trunk/reactos/drivers/usb/usbehci/hardware.cpp [iso-8859-1] (original) +++ trunk/reactos/drivers/usb/usbehci/hardware.cpp [iso-8859-1] Wed Feb 29 04:58:27 2012 @@ -467,13 +467,6 @@ } // - // Stop the controller before modifying schedules - // - Status = StopController(); - if (!NT_SUCCESS(Status)) - return Status; - - // // Initialize the DMAMemoryManager // Status = m_MemoryManager->Initialize(this, &m_Lock, PAGE_SIZE * 4, VirtualBase, PhysicalAddress, 32); Modified: trunk/reactos/drivers/usb/usbohci/hardware.cpp URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/usb/usbohci/hardwa…
============================================================================== --- trunk/reactos/drivers/usb/usbohci/hardware.cpp [iso-8859-1] (original) +++ trunk/reactos/drivers/usb/usbohci/hardware.cpp [iso-8859-1] Wed Feb 29 04:58:27 2012 @@ -201,38 +201,6 @@ m_VendorID = PciConfig.VendorID; m_DeviceID = PciConfig.DeviceID; - if (PciConfig.Command & PCI_ENABLE_BUS_MASTER) - { - // - // master is enabled - // - return STATUS_SUCCESS; - } - - DPRINT1("PCI Configuration shows this as a non Bus Mastering device! Enabling...\n"); - - PciConfig.Command |= PCI_ENABLE_BUS_MASTER; - BusInterface.SetBusData(BusInterface.Context, PCI_WHICHSPACE_CONFIG, &PciConfig, 0, PCI_COMMON_HDR_LENGTH); - - BytesRead = (*BusInterface.GetBusData)(BusInterface.Context, - PCI_WHICHSPACE_CONFIG, - &PciConfig, - 0, - PCI_COMMON_HDR_LENGTH); - - if (BytesRead != PCI_COMMON_HDR_LENGTH) - { - DPRINT1("Failed to get pci config information!\n"); - ASSERT(FALSE); - return STATUS_SUCCESS; - } - - if (!(PciConfig.Command & PCI_ENABLE_BUS_MASTER)) - { - DPRINT1("Failed to enable master\n"); - return STATUS_UNSUCCESSFUL; - } - return STATUS_SUCCESS; } Modified: trunk/reactos/drivers/usb/usbuhci/hardware.cpp URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/usb/usbuhci/hardwa…
============================================================================== --- trunk/reactos/drivers/usb/usbuhci/hardware.cpp [iso-8859-1] (original) +++ trunk/reactos/drivers/usb/usbuhci/hardware.cpp [iso-8859-1] Wed Feb 29 04:58:27 2012 @@ -227,11 +227,6 @@ return STATUS_SUCCESS; } - if (!(PciConfig.Command & PCI_ENABLE_BUS_MASTER)) - { - DPRINT1("PCI Configuration shows this as a non Bus Mastering device!\n"); - } - m_VendorID = PciConfig.VendorID; m_DeviceID = PciConfig.DeviceID;
12 years, 10 months
1
0
0
0
[janderwald] 55909: [USBOHCI] - Remove duplicated code [USBUHCI] - Use libusb
by janderwald@svn.reactos.org
Author: janderwald Date: Tue Feb 28 22:09:57 2012 New Revision: 55909 URL:
http://svn.reactos.org/svn/reactos?rev=55909&view=rev
Log: [USBOHCI] - Remove duplicated code [USBUHCI] - Use libusb Removed: trunk/reactos/drivers/usb/usbuhci/hcd_controller.cpp trunk/reactos/drivers/usb/usbuhci/hub_controller.cpp trunk/reactos/drivers/usb/usbuhci/memory_manager.cpp trunk/reactos/drivers/usb/usbuhci/misc.cpp trunk/reactos/drivers/usb/usbuhci/purecall.cpp trunk/reactos/drivers/usb/usbuhci/usb_device.cpp Modified: trunk/reactos/drivers/usb/usbohci/usbohci.cpp trunk/reactos/drivers/usb/usbuhci/CMakeLists.txt trunk/reactos/drivers/usb/usbuhci/hardware.cpp trunk/reactos/drivers/usb/usbuhci/interfaces.h trunk/reactos/drivers/usb/usbuhci/usb_queue.cpp trunk/reactos/drivers/usb/usbuhci/usb_request.cpp trunk/reactos/drivers/usb/usbuhci/usbuhci.cpp trunk/reactos/drivers/usb/usbuhci/usbuhci.h [This mail would be too long, it was shortened to contain the URLs only.] Modified: trunk/reactos/drivers/usb/usbohci/usbohci.cpp URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/usb/usbohci/usbohc…
Modified: trunk/reactos/drivers/usb/usbuhci/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/usb/usbuhci/CMakeL…
Modified: trunk/reactos/drivers/usb/usbuhci/hardware.cpp URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/usb/usbuhci/hardwa…
Removed: trunk/reactos/drivers/usb/usbuhci/hcd_controller.cpp URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/usb/usbuhci/hcd_co…
Removed: trunk/reactos/drivers/usb/usbuhci/hub_controller.cpp URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/usb/usbuhci/hub_co…
Modified: trunk/reactos/drivers/usb/usbuhci/interfaces.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/usb/usbuhci/interf…
Removed: trunk/reactos/drivers/usb/usbuhci/memory_manager.cpp URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/usb/usbuhci/memory…
Removed: trunk/reactos/drivers/usb/usbuhci/misc.cpp URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/usb/usbuhci/misc.c…
Removed: trunk/reactos/drivers/usb/usbuhci/purecall.cpp URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/usb/usbuhci/pureca…
Removed: trunk/reactos/drivers/usb/usbuhci/usb_device.cpp URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/usb/usbuhci/usb_de…
Modified: trunk/reactos/drivers/usb/usbuhci/usb_queue.cpp URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/usb/usbuhci/usb_qu…
Modified: trunk/reactos/drivers/usb/usbuhci/usb_request.cpp URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/usb/usbuhci/usb_re…
Modified: trunk/reactos/drivers/usb/usbuhci/usbuhci.cpp URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/usb/usbuhci/usbuhc…
Modified: trunk/reactos/drivers/usb/usbuhci/usbuhci.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/usb/usbuhci/usbuhc…
12 years, 10 months
1
0
0
0
← Newer
1
2
3
4
5
6
...
58
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
53
54
55
56
57
58
Results per page:
10
25
50
100
200