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
March 2007
----- 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
20 participants
287 discussions
Start a n
N
ew thread
[greatlrd] 26203: fixing newdev.h compatible with DDK version 3790.1830 it did not have #include <pshpack1.h> and #include <poppack.h>
by greatlrd@svn.reactos.org
Author: greatlrd Date: Fri Mar 30 12:47:54 2007 New Revision: 26203 URL:
http://svn.reactos.org/svn/reactos?rev=26203&view=rev
Log: fixing newdev.h compatible with DDK version 3790.1830 it did not have #include <pshpack1.h> and #include <poppack.h> Modified: trunk/reactos/include/ddk/newdev.h Modified: trunk/reactos/include/ddk/newdev.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/ddk/newdev.h?rev=2…
============================================================================== --- trunk/reactos/include/ddk/newdev.h (original) +++ trunk/reactos/include/ddk/newdev.h Fri Mar 30 12:47:54 2007 @@ -20,13 +20,10 @@ * */ -#ifndef __NEWDEV_H -#define __NEWDEV_H +#ifndef _INC_NEWDEV +#define _INC_NEWDEV -#if __GNUC__ >=3 -#pragma GCC system_header -#endif - +#include <pshpack1.h> #ifdef __cplusplus extern "C" { #endif @@ -44,6 +41,8 @@ LPCSTR FullInfPath, DWORD InstallFlags, PBOOL bRebootRequired OPTIONAL); + + BOOL WINAPI UpdateDriverForPlugAndPlayDevicesW( @@ -63,4 +62,6 @@ } #endif +#include <poppack.h> + #endif /* __NEWDEV_H */
17 years, 8 months
1
0
0
0
[greatlrd] 26202: adding ieverp.h compatible with DDK version 3790.1830
by greatlrd@svn.reactos.org
Author: greatlrd Date: Fri Mar 30 12:41:21 2007 New Revision: 26202 URL:
http://svn.reactos.org/svn/reactos?rev=26202&view=rev
Log: adding ieverp.h compatible with DDK version 3790.1830 Added: trunk/reactos/include/ddk/ieverp.h (with props) Added: trunk/reactos/include/ddk/ieverp.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/ddk/ieverp.h?rev=2…
============================================================================== --- trunk/reactos/include/ddk/ieverp.h (added) +++ trunk/reactos/include/ddk/ieverp.h Fri Mar 30 12:41:21 2007 @@ -1,0 +1,12 @@ + +#define VER_MAJOR_PRODUCTVER 6 +#define VER_MINOR_PRODUCTVER 0 + +#undef VER_PRODUCTBUILD +#define VER_PRODUCTBUILD 2900 +#define VER_PRODUCTVERSION VER_MAJOR_PRODUCTVER,VER_MINOR_PRODUCTVER,VER_PRODUCTBUILD,VER_PRODUCTBUILD_QFE +#define VER_PRODUCTVERSION_W (0x0600) +#define VER_PRODUCTVERSION_DW (0x06000000 | VER_PRODUCTBUILD) +#define VER_PRODUCTBETA_STR "" +#define VER_PRODUCTVERSION_STRING "6.00" + Propchange: trunk/reactos/include/ddk/ieverp.h ------------------------------------------------------------------------------ svn:eol-style = native
17 years, 8 months
1
0
0
0
[greatlrd] 26201: fixing ddrawint.h compatible with DDK version 3790.1830 adding polarity.h compatible with DDK version 3790.1830
by greatlrd@svn.reactos.org
Author: greatlrd Date: Fri Mar 30 12:34:20 2007 New Revision: 26201 URL:
http://svn.reactos.org/svn/reactos?rev=26201&view=rev
Log: fixing ddrawint.h compatible with DDK version 3790.1830 adding polarity.h compatible with DDK version 3790.1830 Added: trunk/reactos/include/ddk/polarity.h (with props) Modified: trunk/reactos/include/ddk/ddrawint.h Modified: trunk/reactos/include/ddk/ddrawint.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/ddk/ddrawint.h?rev…
============================================================================== --- trunk/reactos/include/ddk/ddrawint.h (original) +++ trunk/reactos/include/ddk/ddrawint.h Fri Mar 30 12:34:20 2007 @@ -4,35 +4,16 @@ #ifndef __DD_INCLUDED__ #define __DD_INCLUDED__ - -#ifndef _NO_DDRAWINT_NO_COM -#ifndef _NO_COM -#define _NO_COM -#include <ddraw.h> -#include <ddrawi.h> /* FIXME: We shouldn't include this header. */ -#undef _NO_COM -#else -#include <ddraw.h> -#include <ddrawi.h> /* FIXME: We shouldn't include this header. */ -#endif -#else -#include <ddraw.h> -#include <ddrawi.h> /* FIXME: We shouldn't include this header. */ -#endif - -#ifdef __cplusplus -extern "C" { -#endif DEFINE_GUID( GUID_MiscellaneousCallbacks, 0xEFD60CC0, 0x49e7, 0x11d0, 0x88, 0x9d, 0x0, 0xaa, 0x0, 0xbb, 0xb7, 0x6a); DEFINE_GUID( GUID_Miscellaneous2Callbacks, 0x406B2F00, 0x3E5A, 0x11D1, 0xB6, 0x40, 0x00, 0xAA, 0x00, 0xA1, 0xF9, 0x6A); DEFINE_GUID( GUID_VideoPortCallbacks, 0xefd60cc1, 0x49e7, 0x11d0, 0x88, 0x9d, 0x0, 0xaa, 0x0, 0xbb, 0xb7, 0x6a); DEFINE_GUID( GUID_ColorControlCallbacks, 0xefd60cc2, 0x49e7, 0x11d0, 0x88, 0x9d, 0x0, 0xaa, 0x0, 0xbb, 0xb7, 0x6a); -DEFINE_GUID( GUID_MotionCompCallbacks, 0xb1122b40, 0x5dA5, 0x11d1, 0x8f, 0xcF, 0x00, 0xc0, 0x4f, 0xc2, 0x9b, 0x4e); +DEFINE_GUID( GUID_MotionCompCallbacks, 0xb1122b40, 0x5dA5, 0x11d1, 0x8f, 0xcF, 0x00, 0xc0, 0x4f, 0xc2, 0x9b, 0x4e); DEFINE_GUID( GUID_VideoPortCaps, 0xefd60cc3, 0x49e7, 0x11d0, 0x88, 0x9d, 0x0, 0xaa, 0x0, 0xbb, 0xb7, 0x6a); DEFINE_GUID( GUID_D3DCaps, 0x7bf06991, 0x8794, 0x11d0, 0x91, 0x39, 0x08, 0x00, 0x36, 0xd2, 0xef, 0x02); -DEFINE_GUID( GUID_D3DExtendedCaps, 0x7de41f80, 0x9d93, 0x11d0, 0x89, 0xab, 0x00, 0xa0, 0xc9, 0x05, 0x41, 0x29); +DEFINE_GUID( GUID_D3DExtendedCaps, 0x7de41f80, 0x9d93, 0x11d0, 0x89, 0xab, 0x00, 0xa0, 0xc9, 0x05, 0x41, 0x29); DEFINE_GUID( GUID_D3DCallbacks, 0x7bf06990, 0x8794, 0x11d0, 0x91, 0x39, 0x08, 0x00, 0x36, 0xd2, 0xef, 0x02); DEFINE_GUID( GUID_D3DCallbacks2, 0xba584e1, 0x70b6, 0x11d0, 0x88, 0x9d, 0x0, 0xaa, 0x0, 0xbb, 0xb7, 0x6a); DEFINE_GUID( GUID_D3DCallbacks3, 0xddf41230, 0xec0a, 0x11d0, 0xa9, 0xb6, 0x00, 0xaa, 0x00, 0xc0, 0x99, 0x3e); @@ -51,6 +32,32 @@ DEFINE_GUID( GUID_VPE2Callbacks, 0x52882147, 0x2d47, 0x469a, 0xa0, 0xd1, 0x3, 0x45, 0x58, 0x90, 0xf6, 0xc8); +#ifndef GUID_DEFS_ONLY + +#ifndef _NO_DDRAWINT_NO_COM +#ifndef _NO_COM +#define _NO_COM +#include <ddraw.h> +#include <dvp.h> +#undef _NO_COM +#else +#include <ddraw.h> +#include <dvp.h> +#endif +#else +#include <ddraw.h> +#include <dvp.h> +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef MAKE_HRESULT // fixme this if statment should not be here, but MAKE_HRESULT should be here +#define MAKE_HRESULT(sev,fac,code) ((HRESULT) (((unsigned long)(sev)<<31) | ((unsigned long)(fac)<<16) | ((unsigned long)(code))) ) +#endif + +typedef ULONG_PTR FLATPTR; typedef struct _DD_VIDEOPORT_LOCAL *PDD_VIDEOPORT_LOCAL; @@ -64,103 +71,93 @@ /* Video memory info structures */ /************************************************************************/ - -typedef ULONG_PTR FLATPTR; - typedef struct _VIDEOMEMORY { - DWORD dwFlags; - FLATPTR fpStart; - union - { - FLATPTR fpEnd; - DWORD dwWidth; - }; - DDSCAPS ddsCaps; - DDSCAPS ddsCapsAlt; - union - { - LPVMEMHEAP lpHeap; - DWORD dwHeight; - }; + DWORD dwFlags; + FLATPTR fpStart; + union + { + FLATPTR fpEnd; + DWORD dwWidth; + }; + DDSCAPS ddsCaps; + DDSCAPS ddsCapsAlt; + union + { + struct _VMEMHEAP *lpHeap; + DWORD dwHeight; + }; } VIDEOMEMORY, *PVIDEOMEMORY; typedef struct _VIDEOMEMORYINFO { - FLATPTR fpPrimary; - DWORD dwFlags; - DWORD dwDisplayWidth; - DWORD dwDisplayHeight; - LONG lDisplayPitch; - DDPIXELFORMAT ddpfDisplay; - DWORD dwOffscreenAlign; - DWORD dwOverlayAlign; - DWORD dwTextureAlign; - DWORD dwZBufferAlign; - DWORD dwAlphaAlign; - PVOID pvPrimary; + FLATPTR fpPrimary; + DWORD dwFlags; + DWORD dwDisplayWidth; + DWORD dwDisplayHeight; + LONG lDisplayPitch; + DDPIXELFORMAT ddpfDisplay; + DWORD dwOffscreenAlign; + DWORD dwOverlayAlign; + DWORD dwTextureAlign; + DWORD dwZBufferAlign; + DWORD dwAlphaAlign; + PVOID pvPrimary; } VIDEOMEMORYINFO; typedef VIDEOMEMORYINFO *LPVIDEOMEMORYINFO; -/************************************************************************/ -/* DDI representation of the DirectDraw object */ -/************************************************************************/ - typedef struct _DD_DIRECTDRAW_GLOBAL { - PVOID dhpdev; - ULONG_PTR dwReserved1; - ULONG_PTR dwReserved2; - LPDDVIDEOPORTCAPS lpDDVideoPortCaps; + PVOID dhpdev; + ULONG_PTR dwReserved1; + ULONG_PTR dwReserved2; + LPDDVIDEOPORTCAPS lpDDVideoPortCaps; } DD_DIRECTDRAW_GLOBAL, *PDD_DIRECTDRAW_GLOBAL; typedef struct _DD_DIRECTDRAW_LOCAL { - PDD_DIRECTDRAW_GLOBAL lpGbl; + PDD_DIRECTDRAW_GLOBAL lpGbl; } DD_DIRECTDRAW_LOCAL, *PDD_DIRECTDRAW_LOCAL; -/************************************************************************/ -/* DDI representation of the DirectDrawSurface object */ -/************************************************************************/ typedef struct _DD_SURFACE_GLOBAL { - union - { - DWORD dwBlockSizeY; - LONG lSlicePitch; - }; - - union - { - PVIDEOMEMORY lpVidMemHeap; - DWORD dwBlockSizeX; - DWORD dwUserMemSize; - }; - - FLATPTR fpVidMem; - union - { - LONG lPitch; - DWORD dwLinearSize; - }; - LONG yHint; - LONG xHint; - DWORD wHeight; - DWORD wWidth; - ULONG_PTR dwReserved1; - DDPIXELFORMAT ddpfSurface; - FLATPTR fpHeapOffset; - HANDLE hCreatorProcess; + union + { + DWORD dwBlockSizeY; + LONG lSlicePitch; + }; + + union + { + PVIDEOMEMORY lpVidMemHeap; + DWORD dwBlockSizeX; + DWORD dwUserMemSize; + }; + + FLATPTR fpVidMem; + union + { + LONG lPitch; + DWORD dwLinearSize; + }; + LONG yHint; + LONG xHint; + DWORD wHeight; + DWORD wWidth; + ULONG_PTR dwReserved1; + DDPIXELFORMAT ddpfSurface; + FLATPTR fpHeapOffset; + HANDLE hCreatorProcess; } DD_SURFACE_GLOBAL, *PDD_SURFACE_GLOBAL; typedef struct _DD_SURFACE_MORE { - DWORD dwMipMapCount; - PDD_VIDEOPORT_LOCAL lpVideoPort; - DWORD dwOverlayFlags; - DDSCAPSEX ddsCapsEx; - DWORD dwSurfaceHandle; + DWORD dwMipMapCount; + PDD_VIDEOPORT_LOCAL lpVideoPort; + DWORD dwOverlayFlags; + DDSCAPSEX ddsCapsEx; + DWORD dwSurfaceHandle; } DD_SURFACE_MORE, *PDD_SURFACE_MORE; typedef struct _DD_ATTACHLIST *PDD_ATTACHLIST; @@ -1361,8 +1358,6 @@ PDD_KERNELCB_SYNCSURFACE SyncSurfaceData; PDD_KERNELCB_SYNCVIDEOPORT SyncVideoPortData; } DD_KERNELCALLBACKS, *PDD_KERNELCALLBACKS; -typedef DWORD (STDCALL *PDD_KERNELCB_SYNCVIDEOPORT)(PDD_SYNCVIDEOPORTDATA); - #define MAX_AUTOFLIP_BUFFERS 10 @@ -1391,11 +1386,11 @@ #define D3DFORMAT_OP_SRGBWRITE 0x00100000L #define D3DFORMAT_OP_NOALPHABLEND 0x00200000L #define D3DFORMAT_OP_AUTOGENMIPMAP 0x00400000L -#define D3DFORMAT_OP_VERTEXTEXTURE 0x00800000L +#define D3DFORMAT_OP_VERTEXTEXTURE 0x00800000L #define D3DFORMAT_OP_NOTEXCOORDWRAPNORMIP 0x01000000L - #define DDHAL_PLEASEALLOC_BLOCKSIZE 0x00000002l #define DDHAL_PLEASEALLOC_USERMEM 0x00000004l + #define VIDMEM_ISLINEAR 0x00000001l #define VIDMEM_ISRECTANGULAR 0x00000002l @@ -1458,4 +1453,6 @@ } /* extern "C" */ #endif +#endif /* GUID_DEFS_ONLY */ + #endif /* __DD_INCLUDED__ */ Added: trunk/reactos/include/ddk/polarity.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/ddk/polarity.h?rev…
============================================================================== --- trunk/reactos/include/ddk/polarity.h (added) +++ trunk/reactos/include/ddk/polarity.h Fri Mar 30 12:34:20 2007 @@ -1,0 +1,23 @@ +/* $Id$ + * + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS kernel + * FILE: + * PURPOSE: + * PROGRAMMER: Magnus Olsen (greatlrd) + * + */ + +#ifndef POLARITY_HEADERFILE_IS_INCLUDED + #define POLARITY_HEADERFILE_IS_INCLUDED + + #ifdef USE_POLARITY + #ifdef BUILDING_DLL + #define POLARITY __declspec( dllexport ) + #else + #define POLARITY __declspec( dllimport ) + #endif + #else + #define POLARITY + #endif +#endif Propchange: trunk/reactos/include/ddk/polarity.h ------------------------------------------------------------------------------ svn:eol-style = native
17 years, 8 months
1
0
0
0
[fireball] 26200: - Implement a simple error handling branch, however it gets hit due to an error somewhere else.
by fireball@svn.reactos.org
Author: fireball Date: Fri Mar 30 01:18:28 2007 New Revision: 26200 URL:
http://svn.reactos.org/svn/reactos?rev=26200&view=rev
Log: - Implement a simple error handling branch, however it gets hit due to an error somewhere else. Modified: trunk/reactos/drivers/storage/scsiport-new/scsiport.c Modified: trunk/reactos/drivers/storage/scsiport-new/scsiport.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/storage/scsiport-n…
============================================================================== --- trunk/reactos/drivers/storage/scsiport-new/scsiport.c (original) +++ trunk/reactos/drivers/storage/scsiport-new/scsiport.c Fri Mar 30 01:18:28 2007 @@ -2012,6 +2012,7 @@ IO_STATUS_BLOCK IoStatusBlock; PIO_STACK_LOCATION IrpStack; KEVENT Event; + KIRQL Irql; PIRP Irp; NTSTATUS Status; PINQUIRYDATA InquiryBuffer; @@ -2020,8 +2021,12 @@ ULONG RetryCount = 0; SCSI_REQUEST_BLOCK Srb; PCDB Cdb; + PSCSI_PORT_LUN_EXTENSION LunExtension; + PSCSI_PORT_DEVICE_EXTENSION DeviceExtension; DPRINT ("SpiSendInquiry() called\n"); + + DeviceExtension = (PSCSI_PORT_DEVICE_EXTENSION)DeviceObject->DeviceExtension; InquiryBuffer = ExAllocatePool (NonPagedPool, INQUIRYDATABUFFERSIZE); if (InquiryBuffer == NULL) @@ -2114,9 +2119,27 @@ /* Check if the queue is frozen */ if (Srb.SrbStatus & SRB_STATUS_QUEUE_FROZEN) { - /* Something weird happeend */ + /* Something weird happened, deal with it (unfreeze the queue) */ KeepTrying = FALSE; - ASSERT(FALSE); + + DPRINT("SpiSendInquiry(): the queue is frozen at TargetId %d\n", Srb.TargetId); + + LunExtension = SpiGetLunExtension(DeviceExtension, + LunInfo->PathId, + LunInfo->TargetId, + LunInfo->Lun); + + /* Clear frozen flag */ + LunExtension->Flags &= ~LUNEX_FROZEN_QUEUE; + + /* Acquire the spinlock */ + KeAcquireSpinLock(&DeviceExtension->SpinLock, &Irql); + + /* Process the request */ + SpiGetNextRequestFromLun(DeviceObject->DeviceExtension, LunExtension); + + /* Lower irql back */ + KeLowerIrql(Irql); } /* Check if data overrun happened */
17 years, 8 months
1
0
0
0
[fireball] 26199: - Massive changes due to a rewrite of the core logic related to ISR, DPC, IRP completion and commands delivery. Fixes a lot of race conditions which existed in hbirr-scsiport. - Add some helper functions, and fields inside device extension structures. - Reorganize flags a little, dividing them into flags for scsi port device extension and logical unit device extension. (however some of the flags are still messed up) - This gets us further, but still not enough / bugs may exist.
by fireball@svn.reactos.org
Author: fireball Date: Fri Mar 30 01:05:41 2007 New Revision: 26199 URL:
http://svn.reactos.org/svn/reactos?rev=26199&view=rev
Log: - Massive changes due to a rewrite of the core logic related to ISR, DPC, IRP completion and commands delivery. Fixes a lot of race conditions which existed in hbirr-scsiport. - Add some helper functions, and fields inside device extension structures. - Reorganize flags a little, dividing them into flags for scsi port device extension and logical unit device extension. (however some of the flags are still messed up) - This gets us further, but still not enough / bugs may exist. Modified: trunk/reactos/drivers/storage/scsiport-new/scsiport.c trunk/reactos/drivers/storage/scsiport-new/scsiport_int.h Modified: trunk/reactos/drivers/storage/scsiport-new/scsiport.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/storage/scsiport-n…
============================================================================== --- trunk/reactos/drivers/storage/scsiport-new/scsiport.c (original) +++ trunk/reactos/drivers/storage/scsiport-new/scsiport.c Fri Mar 30 01:05:41 2007 @@ -117,16 +117,41 @@ ScsiPortIoTimer(PDEVICE_OBJECT DeviceObject, PVOID Context); +#if 0 static PSCSI_REQUEST_BLOCK ScsiPortInitSenseRequestSrb(PSCSI_PORT_DEVICE_EXTENSION DeviceExtension, PSCSI_REQUEST_BLOCK OriginalSrb); static VOID ScsiPortFreeSenseRequestSrb(PSCSI_PORT_DEVICE_EXTENSION DeviceExtension); +#endif static NTSTATUS SpiBuildDeviceMap (PSCSI_PORT_DEVICE_EXTENSION DeviceExtension, PUNICODE_STRING RegistryPath); + +static NTSTATUS +SpiStatusSrbToNt(UCHAR SrbStatus); + +static VOID +SpiSendRequestSense(IN PSCSI_PORT_DEVICE_EXTENSION DeviceExtension, + IN PSCSI_REQUEST_BLOCK Srb); + +NTSTATUS STDCALL +SpiCompletionRoutine(PDEVICE_OBJECT DeviceObject, + PIRP Irp, + PVOID Context); + +static VOID +STDCALL +SpiProcessCompletedRequest(IN PSCSI_PORT_DEVICE_EXTENSION DeviceExtension, + IN PSCSI_REQUEST_BLOCK_INFO SrbInfo, + OUT PBOOLEAN NeedToCallStartIo); + +VOID +STDCALL +SpiGetNextRequestFromLun(IN PSCSI_PORT_DEVICE_EXTENSION DeviceExtension, + IN PSCSI_PORT_LUN_EXTENSION LunExtension); /* FUNCTIONS *****************************************************************/ @@ -2086,7 +2111,7 @@ } else { - /* Check if queue is frozen */ + /* Check if the queue is frozen */ if (Srb.SrbStatus & SRB_STATUS_QUEUE_FROZEN) { /* Something weird happeend */ @@ -2512,6 +2537,480 @@ } } +static VOID +SpiSendRequestSense(IN PSCSI_PORT_DEVICE_EXTENSION DeviceExtension, + IN PSCSI_REQUEST_BLOCK InitialSrb) +{ + PSCSI_REQUEST_BLOCK Srb; + PCDB Cdb; + PIRP Irp; + PIO_STACK_LOCATION IrpStack; + LARGE_INTEGER LargeInt; + PVOID *Ptr; + + DPRINT("SpiSendRequestSense() entered\n"); + + /* Allocate Srb */ + Srb = ExAllocatePool(NonPagedPool, sizeof(SCSI_REQUEST_BLOCK) + sizeof(PVOID)); + RtlZeroMemory(Srb, sizeof(SCSI_REQUEST_BLOCK)); + + /* Allocate IRP */ + LargeInt.QuadPart = (LONGLONG) 1; + Irp = IoBuildAsynchronousFsdRequest(IRP_MJ_READ, + DeviceExtension->DeviceObject, + InitialSrb->SenseInfoBuffer, + InitialSrb->SenseInfoBufferLength, + &LargeInt, + NULL); + + IoSetCompletionRoutine(Irp, + (PIO_COMPLETION_ROUTINE)SpiCompletionRoutine, + Srb, + TRUE, + TRUE, + TRUE); + + IrpStack = IoGetNextIrpStackLocation(Irp); + IrpStack->MajorFunction = IRP_MJ_SCSI; + + /* Put Srb address into Irp... */ + IrpStack->Parameters.Others.Argument1 = (PVOID)Srb; + + /* ...and vice versa */ + Srb->OriginalRequest = Irp; + + /* Save Srb */ + Ptr = (PVOID *)(Srb+1); + *Ptr = Srb; + + /* Build CDB for REQUEST SENSE */ + Srb->CdbLength = 6; + Cdb = (PCDB)Srb->Cdb; + + Cdb->CDB6INQUIRY.OperationCode = SCSIOP_REQUEST_SENSE; + Cdb->CDB6INQUIRY.LogicalUnitNumber = 0; + Cdb->CDB6INQUIRY.Reserved1 = 0; + Cdb->CDB6INQUIRY.PageCode = 0; + Cdb->CDB6INQUIRY.IReserved = 0; + Cdb->CDB6INQUIRY.AllocationLength = (UCHAR)InitialSrb->SenseInfoBufferLength; + Cdb->CDB6INQUIRY.Control = 0; + + /* Set address */ + Srb->TargetId = InitialSrb->TargetId; + Srb->Lun = InitialSrb->Lun; + Srb->PathId = InitialSrb->PathId; + + Srb->Function = SRB_FUNCTION_EXECUTE_SCSI; + Srb->Length = sizeof(SCSI_REQUEST_BLOCK); + + /* Timeout will be 2 seconds */ + Srb->TimeOutValue = 2; + + /* No auto request sense */ + Srb->SenseInfoBufferLength = 0; + Srb->SenseInfoBuffer = NULL; + + /* Set necessary flags */ + Srb->SrbFlags = SRB_FLAGS_DATA_IN | SRB_FLAGS_BYPASS_FROZEN_QUEUE | + SRB_FLAGS_DISABLE_DISCONNECT; + + /* Transfer disable synch transfer flag */ + if (InitialSrb->SrbFlags & SRB_FLAGS_DISABLE_SYNCH_TRANSFER) + Srb->SrbFlags |= SRB_FLAGS_DISABLE_SYNCH_TRANSFER; + + Srb->DataBuffer = InitialSrb->SenseInfoBuffer; + + /* Fill the transfer length */ + Srb->DataTransferLength = InitialSrb->SenseInfoBufferLength; + + /* Clear statuses */ + Srb->ScsiStatus = Srb->SrbStatus = 0; + Srb->NextSrb = 0; + + /* Call the driver */ + (VOID)IoCallDriver(DeviceExtension->DeviceObject, Irp); + + DPRINT("SpiSendRequestSense() done\n"); +} + + +static +VOID +STDCALL +SpiProcessCompletedRequest(IN PSCSI_PORT_DEVICE_EXTENSION DeviceExtension, + IN PSCSI_REQUEST_BLOCK_INFO SrbInfo, + OUT PBOOLEAN NeedToCallStartIo) +{ + PSCSI_REQUEST_BLOCK Srb; + PSCSI_PORT_LUN_EXTENSION LunExtension; + LONG Result; + PIRP Irp; + ULONG SequenceNumber; + + Srb = SrbInfo->Srb; + Irp = Srb->OriginalRequest; + + /* Get Lun extension */ + LunExtension = SpiGetLunExtension(DeviceExtension, + Srb->PathId, + Srb->TargetId, + Srb->Lun); + + if (Srb->SrbFlags & SRB_FLAGS_UNSPECIFIED_DIRECTION && + DeviceExtension->MapBuffers && + Irp->MdlAddress) + { + /* MDL is shared if transfer is broken into smaller parts */ + Srb->DataBuffer = (PCCHAR)MmGetMdlVirtualAddress(Irp->MdlAddress) + + ((PCCHAR)Srb->DataBuffer - SrbInfo->DataOffset); + + /* In case of data going in, flush the buffers */ + if (Srb->SrbFlags & SRB_FLAGS_DATA_IN) + { + KeFlushIoBuffers(Irp->MdlAddress, + TRUE, + FALSE); + } + } + + + /* Flush adapter if needed */ + if (SrbInfo->BaseOfMapRegister) + { + /* TODO: Implement */ + ASSERT(FALSE); + } + + /* Clear the request */ + SrbInfo->Srb = NULL; + + /* If disconnect is disabled... */ + if (Srb->SrbFlags & SRB_FLAGS_DISABLE_DISCONNECT) + { + /* Acquire the spinlock since we mess with flags */ + KeAcquireSpinLockAtDpcLevel(&DeviceExtension->SpinLock); + + /* Set corresponding flag */ + DeviceExtension->Flags |= SCSI_PORT_DISCONNECT_ALLOWED; + + /* Clear the timer if needed */ + if (!(DeviceExtension->InterruptData.Flags & SCSI_PORT_RESET)) + DeviceExtension->TimerCount = -1; + + /* Spinlock is not needed anymore */ + KeReleaseSpinLockFromDpcLevel(&DeviceExtension->SpinLock); + + if (!(DeviceExtension->Flags & SCSI_PORT_REQUEST_PENDING) && + !(DeviceExtension->Flags & SCSI_PORT_DEVICE_BUSY) && + !(*NeedToCallStartIo)) + { + /* We're not busy, but we have a request pending */ + IoStartNextPacket(DeviceExtension->DeviceObject, FALSE); + } + } + + /* Scatter/gather */ + if (Srb->SrbFlags & SRB_FLAGS_SGLIST_FROM_POOL) + { + /* TODO: Implement */ + ASSERT(FALSE); + } + + /* Acquire spinlock (we're freeing SrbExtension) */ + KeAcquireSpinLockAtDpcLevel(&DeviceExtension->SpinLock); + + /* Free it (if needed) */ + if (Srb->SrbExtension) + { + if (Srb->SenseInfoBuffer != NULL && DeviceExtension->SupportsAutoSense) + { + ASSERT(Srb->SenseInfoBuffer == NULL || SrbInfo->SaveSenseRequest != NULL); + + if (Srb->SrbStatus & SRB_STATUS_AUTOSENSE_VALID) + { + /* Copy sense data to the buffer */ + RtlCopyMemory(SrbInfo->SaveSenseRequest, + Srb->SenseInfoBuffer, + Srb->SenseInfoBufferLength); + } + + /* And restore the pointer */ + Srb->SenseInfoBuffer = SrbInfo->SaveSenseRequest; + } + + /* Put it into the free srb extensions list */ + *((PVOID *)Srb->SrbExtension) = DeviceExtension->FreeSrbExtensions; + DeviceExtension->FreeSrbExtensions = Srb->SrbExtension; + } + + /* Save transfer length in the IRP */ + Irp->IoStatus.Information = Srb->DataTransferLength; + + SequenceNumber = SrbInfo->SequenceNumber; + SrbInfo->SequenceNumber = 0; + + /* Decrement the queue count */ + LunExtension->QueueCount--; + + /* Free Srb, if needed*/ + if (Srb->QueueTag != SP_UNTAGGED) + { + /* Put it into the free list */ + SrbInfo->Requests.Blink = NULL; + SrbInfo->Requests.Flink = (PLIST_ENTRY)DeviceExtension->FreeSrbInfo; + DeviceExtension->FreeSrbInfo = SrbInfo; + } + + /* SrbInfo is not used anymore */ + SrbInfo = NULL; + + if (DeviceExtension->Flags & SCSI_PORT_REQUEST_PENDING) + { + /* Clear the flag */ + DeviceExtension->Flags &= ~SCSI_PORT_REQUEST_PENDING; + + /* Note the caller about StartIo */ + *NeedToCallStartIo = TRUE; + } + + if (SRB_STATUS(Srb->SrbStatus) == SRB_STATUS_SUCCESS) + { + /* Start the packet */ + Irp->IoStatus.Status = STATUS_SUCCESS; + + if (!(Srb->SrbFlags & SRB_FLAGS_BYPASS_FROZEN_QUEUE) && + LunExtension->RequestTimeout == -1) + { + /* Start the next packet */ + SpiGetNextRequestFromLun(DeviceExtension, LunExtension); + } + else + { + /* Release the spinlock */ + KeReleaseSpinLockFromDpcLevel(&DeviceExtension->SpinLock); + } + + DPRINT("IoCompleting request IRP 0x%08X", Irp); + + IoCompleteRequest(Irp, IO_DISK_INCREMENT); + + /* Decrement number of active requests, and analyze the result */ + Result = InterlockedDecrement(&DeviceExtension->ActiveRequestCounter); + + if (Result < 0 && + !DeviceExtension->MapRegisters && + DeviceExtension->AdapterObject != NULL) + { + /* Nullify map registers */ + DeviceExtension->MapRegisterBase = NULL; + IoFreeAdapterChannel(DeviceExtension->AdapterObject); + } + + /* Exit, we're done */ + return; + } + + /* Decrement number of active requests, and analyze the result */ + Result = InterlockedDecrement(&DeviceExtension->ActiveRequestCounter); + + if (Result < 0 && + !DeviceExtension->MapRegisters && + DeviceExtension->AdapterObject != NULL) + { + /* Result is negative, so this is a slave, free map registers */ + DeviceExtension->MapRegisterBase = NULL; + IoFreeAdapterChannel(DeviceExtension->AdapterObject); + } + + /* Convert status */ + Irp->IoStatus.Status = SpiStatusSrbToNt(Srb->SrbStatus); + + /* It's not a bypass, it's busy or the queue is full? */ + if ((Srb->ScsiStatus == SCSISTAT_BUSY || + Srb->SrbStatus == SRB_STATUS_BUSY || + Srb->ScsiStatus == SCSISTAT_QUEUE_FULL) && + !(Srb->SrbFlags & SRB_FLAGS_BYPASS_FROZEN_QUEUE)) + { + + DPRINT("Busy SRB status %x\n", Srb->SrbStatus); + + /* Requeu, if needed */ + if (LunExtension->Flags & (LUNEX_FROZEN_QUEUE | LUNEX_BUSY)) + { + DPRINT("it's being requeued\n"); + + Srb->SrbStatus = SRB_STATUS_PENDING; + Srb->ScsiStatus = 0; + + if (!KeInsertByKeyDeviceQueue(&LunExtension->DeviceQueue, + &Irp->Tail.Overlay.DeviceQueueEntry, + Srb->QueueSortKey)) + { + /* It's a big f.ck up if we got here */ + Srb->SrbStatus = SRB_STATUS_ERROR; + Srb->ScsiStatus = SCSISTAT_BUSY; + + ASSERT(FALSE); + goto Error; + } + + /* Release the spinlock */ + KeReleaseSpinLockFromDpcLevel(&DeviceExtension->SpinLock); + + } + else if (LunExtension->AttemptCount++ < 20) + { + /* LUN is still busy */ + Srb->ScsiStatus = 0; + Srb->SrbStatus = SRB_STATUS_PENDING; + + LunExtension->BusyRequest = Irp; + LunExtension->Flags |= LUNEX_BUSY; + + /* Release the spinlock */ + KeReleaseSpinLockFromDpcLevel(&DeviceExtension->SpinLock); + } + else + { +Error: + /* Freeze the queue*/ + Srb->SrbStatus |= SRB_STATUS_QUEUE_FROZEN; + LunExtension->Flags |= LUNEX_FROZEN_QUEUE; + + /* "Unfull" the queue */ + LunExtension->Flags &= ~LUNEX_FULL_QUEUE; + + /* Release the spinlock */ + KeReleaseSpinLockFromDpcLevel(&DeviceExtension->SpinLock); + + /* Return status that the device is not ready */ + Irp->IoStatus.Status = STATUS_DEVICE_NOT_READY; + IoCompleteRequest(Irp, IO_DISK_INCREMENT); + } + + return; + } + + /* Start the next request, if LUN is idle, and this is sense request */ + if (((Srb->ScsiStatus != SCSISTAT_CHECK_CONDITION) || + (Srb->SrbStatus & SRB_STATUS_AUTOSENSE_VALID) || + !Srb->SenseInfoBuffer || !Srb->SenseInfoBufferLength) + && (Srb->SrbFlags & SRB_FLAGS_NO_QUEUE_FREEZE)) + { + if (LunExtension->RequestTimeout == -1) + SpiGetNextRequestFromLun(DeviceExtension, LunExtension); + else + KeReleaseSpinLockFromDpcLevel(&DeviceExtension->SpinLock); + } + else + { + /* Freeze the queue */ + Srb->SrbStatus |= SRB_STATUS_QUEUE_FROZEN; + LunExtension->Flags |= LUNEX_FROZEN_QUEUE; + + /* Do we need a request sense? */ + if (Srb->ScsiStatus == SCSISTAT_CHECK_CONDITION && + !(Srb->SrbStatus & SRB_STATUS_AUTOSENSE_VALID) && + Srb->SenseInfoBuffer && Srb->SenseInfoBufferLength) + { + /* If LUN is busy, we have to requeue it in order to allow request sense */ + if (LunExtension->Flags & LUNEX_BUSY) + { + DPRINT("Requeueing busy request to allow request sense\n"); + + if (!KeInsertByKeyDeviceQueue(&LunExtension->DeviceQueue, + &LunExtension->BusyRequest->Tail.Overlay.DeviceQueueEntry, + Srb->QueueSortKey)) + { + /* We should never get here */ + ASSERT(FALSE); + + KeReleaseSpinLockFromDpcLevel(&DeviceExtension->SpinLock); + IoCompleteRequest(Irp, IO_DISK_INCREMENT); + return; + + } + + /* Clear busy flags */ + LunExtension->Flags &= ~(LUNEX_FULL_QUEUE | LUNEX_BUSY); + } + + /* Release the spinlock */ + KeReleaseSpinLockFromDpcLevel(&DeviceExtension->SpinLock); + + /* Send RequestSense */ + SpiSendRequestSense(DeviceExtension, Srb); + + /* Exit */ + return; + } + + /* Release the spinlock */ + KeReleaseSpinLockFromDpcLevel(&DeviceExtension->SpinLock); + } + + /* Complete the request */ + IoCompleteRequest(Irp, IO_DISK_INCREMENT); +} + +NTSTATUS +STDCALL +SpiCompletionRoutine(PDEVICE_OBJECT DeviceObject, + PIRP Irp, + PVOID Context) +{ + PSCSI_REQUEST_BLOCK Srb = (PSCSI_REQUEST_BLOCK)Context; + PSCSI_REQUEST_BLOCK InitialSrb; + PIRP InitialIrp; + + DPRINT("SpiCompletionRoutine() entered, IRP %p \n", Irp); + + if ((Srb->Function == SRB_FUNCTION_RESET_BUS) || + (Srb->Function == SRB_FUNCTION_ABORT_COMMAND)) + { + /* Deallocate SRB and IRP and exit */ + ExFreePool(Srb); + IoFreeIrp(Irp); + + return STATUS_MORE_PROCESSING_REQUIRED; + } + + /* Get a pointer to the SRB and IRP which were initially sent */ + InitialSrb = *((PVOID *)(Srb+1)); + InitialIrp = InitialSrb->OriginalRequest; + + if ((SRB_STATUS(Srb->SrbStatus) == SRB_STATUS_SUCCESS) || + (SRB_STATUS(Srb->SrbStatus) == SRB_STATUS_DATA_OVERRUN)) + { + /* Sense data is OK */ + InitialSrb->SrbStatus |= SRB_STATUS_AUTOSENSE_VALID; + + /* Set length to be the same */ + InitialSrb->SenseInfoBufferLength = (UCHAR)Srb->DataTransferLength; + } + + /* Make sure initial SRB's queue is frozen */ + ASSERT(InitialSrb->SrbStatus & SRB_STATUS_QUEUE_FROZEN); + + /* Complete this request */ + IoCompleteRequest(InitialIrp, IO_DISK_INCREMENT); + + /* Deallocate everything (internal) */ + ExFreePool(Srb); + + if (Irp->MdlAddress != NULL) + { + MmUnlockPages(Irp->MdlAddress); + IoFreeMdl(Irp->MdlAddress); + Irp->MdlAddress = NULL; + } + + IoFreeIrp(Irp); + return STATUS_MORE_PROCESSING_REQUIRED; +} + + + static BOOLEAN STDCALL ScsiPortIsr(IN PKINTERRUPT Interrupt, IN PVOID ServiceContext) @@ -2540,6 +3039,220 @@ return TRUE; } + +BOOLEAN +STDCALL +SpiSaveInterruptData(IN PVOID Context) +{ + PSCSI_PORT_SAVE_INTERRUPT InterruptContext = Context; + PSCSI_PORT_LUN_EXTENSION LunExtension; + PSCSI_REQUEST_BLOCK Srb; + PSCSI_REQUEST_BLOCK_INFO SrbInfo, NextSrbInfo; + PSCSI_PORT_DEVICE_EXTENSION DeviceExtension; + BOOLEAN IsTimed; + + /* Get pointer to the device extension */ + DeviceExtension = InterruptContext->DeviceExtension; + + /* If we don't have anything pending - return */ + if (!(DeviceExtension->InterruptData.Flags & SCSI_PORT_NOTIFICATION_NEEDED)) + return FALSE; + + /* Actually save the interrupt data */ + *InterruptContext->InterruptData = DeviceExtension->InterruptData; + + /* Clear the data stored in the device extension */ + DeviceExtension->InterruptData.Flags &= + (SCSI_PORT_RESET | SCSI_PORT_RESET_REQUEST | SCSI_PORT_DISABLE_INTERRUPTS); + DeviceExtension->InterruptData.CompletedAbort = NULL; + DeviceExtension->InterruptData.ReadyLun = NULL; + DeviceExtension->InterruptData.CompletedRequests = NULL; + + /* Loop through the list of completed requests */ + SrbInfo = InterruptContext->InterruptData->CompletedRequests; + + while (SrbInfo) + { + /* Make sure we have SRV */ + ASSERT(SrbInfo->Srb); + + /* Get SRB and LunExtension */ + Srb = SrbInfo->Srb; + + LunExtension = SpiGetLunExtension(DeviceExtension, + Srb->PathId, + Srb->TargetId, + Srb->Lun); + + /* We have to check special cases if request is unsuccessfull*/ + if (Srb->SrbStatus != SRB_STATUS_SUCCESS) + { + /* Check if we need request sense by a few conditions */ + if (Srb->SenseInfoBuffer && Srb->SenseInfoBufferLength && + Srb->ScsiStatus == SCSISTAT_CHECK_CONDITION && + !(Srb->SrbStatus & SRB_STATUS_AUTOSENSE_VALID)) + { + if (LunExtension->Flags & LUNEX_NEED_REQUEST_SENSE) + { + /* It means: we tried to send REQUEST SENSE, but failed */ + + Srb->ScsiStatus = 0; + Srb->SrbStatus = SRB_STATUS_REQUEST_SENSE_FAILED; + } + else + { + /* Set the corresponding flag, so that REQUEST SENSE + will be sent */ + LunExtension->Flags |= LUNEX_NEED_REQUEST_SENSE; + } + + } + + /* Check for a full queue */ + if (Srb->ScsiStatus == SCSISTAT_QUEUE_FULL) + { + /* TODO: Implement when it's encountered */ + ASSERT(FALSE); + } + } + + /* Let's decide if we need to watch timeout or not */ + if (Srb->QueueTag == SP_UNTAGGED) + { + IsTimed = TRUE; + } + else + { + if (LunExtension->SrbInfo.Requests.Flink == &SrbInfo->Requests) + IsTimed = TRUE; + else + IsTimed = FALSE; + + /* Remove it from the queue */ + RemoveEntryList(&SrbInfo->Requests); + } + + if (IsTimed) + { + /* We have to maintain timeout counter */ + if (IsListEmpty(&LunExtension->SrbInfo.Requests)) + { + LunExtension->RequestTimeout = -1; + } + else + { + NextSrbInfo = CONTAINING_RECORD(LunExtension->SrbInfo.Requests.Flink, + SCSI_REQUEST_BLOCK_INFO, + Requests); + + Srb = NextSrbInfo->Srb; + + /* Update timeout counter */ + LunExtension->RequestTimeout = Srb->TimeOutValue; + } + } + + SrbInfo = SrbInfo->CompletedRequests; + } + + return TRUE; +} + +VOID +STDCALL +SpiGetNextRequestFromLun(IN PSCSI_PORT_DEVICE_EXTENSION DeviceExtension, + IN PSCSI_PORT_LUN_EXTENSION LunExtension) +{ + PIO_STACK_LOCATION IrpStack; + PIRP NextIrp; + PKDEVICE_QUEUE_ENTRY Entry; + PSCSI_REQUEST_BLOCK Srb; + + + /* If LUN is not active or queue is more than maximum allowed */ + if (LunExtension->QueueCount >= LunExtension->MaxQueueCount || + !(LunExtension->Flags & SCSI_PORT_LU_ACTIVE)) + { + /* Release the spinlock and exit */ + KeReleaseSpinLockFromDpcLevel(&DeviceExtension->SpinLock); + return; + } + + /* Check if we can get a next request */ + if (LunExtension->Flags & + (LUNEX_NEED_REQUEST_SENSE | LUNEX_BUSY | + LUNEX_FULL_QUEUE | LUNEX_FROZEN_QUEUE | LUNEX_REQUEST_PENDING)) + { + /* Pending requests can only be started if the queue is empty */ + if (IsListEmpty(&LunExtension->SrbInfo.Requests) && + !(LunExtension->Flags & + (LUNEX_BUSY | LUNEX_FROZEN_QUEUE | LUNEX_FULL_QUEUE | LUNEX_NEED_REQUEST_SENSE))) + { + /* Make sure we have SRB */ + ASSERT(LunExtension->SrbInfo.Srb == NULL); + + /* Clear active and pending flags */ + LunExtension->Flags &= ~(LUNEX_REQUEST_PENDING | SCSI_PORT_LU_ACTIVE); + + /* Get next Irp, and clear pending requests list */ + NextIrp = LunExtension->PendingRequest; + LunExtension->PendingRequest = NULL; + + /* Set attempt counter to zero */ + LunExtension->AttemptCount = 0; + + /* Release the spinlock */ + KeReleaseSpinLockFromDpcLevel(&DeviceExtension->SpinLock); + + /* Start the next pending request */ + IoStartPacket(DeviceExtension->DeviceObject, NextIrp, (PULONG)NULL, NULL); + + return; + } + else + { + /* Release the spinlock, without clearing any flags and exit */ + KeReleaseSpinLockFromDpcLevel(&DeviceExtension->SpinLock); + + return; + } + } + + /* Reset active flag */ + LunExtension->Flags &= ~SCSI_PORT_LU_ACTIVE; + + /* Set attempt counter to zero */ + LunExtension->AttemptCount = 0; + + /* Remove packet from the device queue */ + Entry = KeRemoveByKeyDeviceQueue(&LunExtension->DeviceQueue, LunExtension->SortKey); + + if (Entry != NULL) + { + /* Get pointer to the next irp */ + NextIrp = CONTAINING_RECORD(Entry, IRP, Tail.Overlay.DeviceQueueEntry); + + /* Get point to the SRB */ + IrpStack = IoGetCurrentIrpStackLocation(NextIrp); + Srb = (PSCSI_REQUEST_BLOCK)IrpStack->Parameters.Others.Argument1; + + /* Set new key*/ + LunExtension->SortKey = Srb->QueueSortKey; + LunExtension->SortKey++; + + /* Release the spinlock */ + KeReleaseSpinLockFromDpcLevel(&DeviceExtension->SpinLock); + + /* Start the next pending request */ + IoStartPacket(DeviceExtension->DeviceObject, NextIrp, (PULONG)NULL, NULL); + } + else + { + /* Release the spinlock */ + KeReleaseSpinLockFromDpcLevel(&DeviceExtension->SpinLock); + } +} + // ScsiPortDpcForIsr @@ -2559,99 +3272,195 @@ IN PIRP DpcIrp, IN PVOID DpcContext) { - PSCSI_PORT_DEVICE_EXTENSION DeviceExtension; - PIO_STACK_LOCATION IrpStack; - PSCSI_REQUEST_BLOCK Srb; - - DPRINT("ScsiPortDpcForIsr(Dpc %p DpcDeviceObject %p DpcIrp %p DpcContext %p)\n", - Dpc, DpcDeviceObject, DpcIrp, DpcContext); - - DeviceExtension = (PSCSI_PORT_DEVICE_EXTENSION)DpcContext; - - KeAcquireSpinLockAtDpcLevel(&DeviceExtension->IrpLock); - if (DeviceExtension->IrpFlags) - { - IrpStack = IoGetCurrentIrpStackLocation(DeviceExtension->CurrentIrp); - Srb = IrpStack->Parameters.Scsi.Srb; - - if (DeviceExtension->OriginalSrb != NULL) - { - DPRINT("Got sense data!\n"); - - DPRINT("Valid: %x\n", DeviceExtension->InternalSenseData.Valid); - DPRINT("ErrorCode: %x\n", DeviceExtension->InternalSenseData.ErrorCode); - DPRINT("SenseKey: %x\n", DeviceExtension->InternalSenseData.SenseKey); - DPRINT("SenseCode: %x\n", DeviceExtension->InternalSenseData.AdditionalSenseCode); - - /* Copy sense data */ - if (DeviceExtension->OriginalSrb->SenseInfoBufferLength != 0) - { - RtlCopyMemory(DeviceExtension->OriginalSrb->SenseInfoBuffer, - &DeviceExtension->InternalSenseData, - sizeof(SENSE_DATA)); - DeviceExtension->OriginalSrb->SrbStatus |= SRB_STATUS_AUTOSENSE_VALID; - } - - /* Clear current sense data */ - RtlZeroMemory(&DeviceExtension->InternalSenseData, sizeof(SENSE_DATA)); - - IrpStack->Parameters.Scsi.Srb = DeviceExtension->OriginalSrb; - ScsiPortFreeSenseRequestSrb (DeviceExtension); - } - else if ((SRB_STATUS(Srb->SrbStatus) != SRB_STATUS_SUCCESS) && - (Srb->ScsiStatus == SCSISTAT_CHECK_CONDITION)) - { - DPRINT("SCSIOP_REQUEST_SENSE required!\n"); - - DeviceExtension->OriginalSrb = Srb; - IrpStack->Parameters.Scsi.Srb = ScsiPortInitSenseRequestSrb(DeviceExtension, - Srb); - KeReleaseSpinLockFromDpcLevel(&DeviceExtension->IrpLock); - if (!KeSynchronizeExecution(DeviceExtension->Interrupt, - ScsiPortStartPacket, - DpcDeviceObject)) - { - DPRINT1("Synchronization failed!\n"); - - DpcIrp->IoStatus.Status = STATUS_UNSUCCESSFUL; - DpcIrp->IoStatus.Information = 0; - IoCompleteRequest(DpcIrp, - IO_NO_INCREMENT); - IoStartNextPacket(DpcDeviceObject, - FALSE); - } - - return; - } - - DeviceExtension->CurrentIrp = NULL; - -// DpcIrp->IoStatus.Information = 0; -// DpcIrp->IoStatus.Status = STATUS_SUCCESS; - - if (DeviceExtension->IrpFlags & IRP_FLAG_COMPLETE) - { - DeviceExtension->IrpFlags &= ~IRP_FLAG_COMPLETE; - IoCompleteRequest(DpcIrp, IO_NO_INCREMENT); - } - - if (DeviceExtension->IrpFlags & IRP_FLAG_NEXT) - { - DeviceExtension->IrpFlags &= ~IRP_FLAG_NEXT; - KeReleaseSpinLockFromDpcLevel(&DeviceExtension->IrpLock); - IoStartNextPacket(DpcDeviceObject, FALSE); - } - else - { - KeReleaseSpinLockFromDpcLevel(&DeviceExtension->IrpLock); - } - } - else - { - KeReleaseSpinLockFromDpcLevel(&DeviceExtension->IrpLock); - } - - DPRINT("ScsiPortDpcForIsr() done\n"); + PSCSI_PORT_DEVICE_EXTENSION DeviceExtension = DpcDeviceObject->DeviceExtension; + SCSI_PORT_INTERRUPT_DATA InterruptData; + SCSI_PORT_SAVE_INTERRUPT Context; + PSCSI_PORT_LUN_EXTENSION LunExtension; + BOOLEAN NeedToStartIo; + PSCSI_REQUEST_BLOCK_INFO SrbInfo; + + DPRINT("ScsiPortDpcForIsr(Dpc %p DpcDeviceObject %p DpcIrp %p DpcContext %p)\n", + Dpc, DpcDeviceObject, DpcIrp, DpcContext); + + /* We need to acquire spinlock */ + KeAcquireSpinLockAtDpcLevel(&DeviceExtension->SpinLock); + +TryAgain: + + /* Interrupt structure must be snapshotted, and only then analyzed */ + Context.InterruptData = &InterruptData; + Context.DeviceExtension = DeviceExtension; + + if (!KeSynchronizeExecution(DeviceExtension->Interrupt, + SpiSaveInterruptData, + &Context)) + { + /* Nothing - just return (don't forget to release the spinlock */ + KeReleaseSpinLockFromDpcLevel(&DeviceExtension->SpinLock); + DPRINT("ScsiPortDpcForIsr() done\n"); + return; + } + + /* If flush of adapters is needed - do it */ + if (InterruptData.Flags & SCSI_PORT_FLUSH_ADAPTERS) + { + /* TODO: Implement */ + ASSERT(FALSE); + } + + /* Check for IoMapTransfer */ + if (InterruptData.Flags & SCSI_PORT_MAP_TRANSFER) + { + /* TODO: Implement */ + ASSERT(FALSE); + } + + /* Check if timer is needed */ + if (InterruptData.Flags & SCIS_PORT_TIMER_NEEDED) + { + /* TODO: Implement */ + ASSERT(FALSE); + } + + /* If it's ready for the next request */ + if (InterruptData.Flags & SCSI_PORT_NEXT_REQUEST_READY) + { + /* Check for a duplicate request (NextRequest+NextLuRequest) */ + if ((DeviceExtension->Flags & + (SCSI_PORT_DEVICE_BUSY | SCSI_PORT_DISCONNECT_ALLOWED)) == + (SCSI_PORT_DEVICE_BUSY | SCSI_PORT_DISCONNECT_ALLOWED)) + { + /* Clear busy flag set by ScsiPortStartPacket() */ + DeviceExtension->Flags &= ~SCSI_PORT_DEVICE_BUSY; + + if (!(InterruptData.Flags & SCSI_PORT_RESET)) + { + /* Ready for next, and no reset is happening */ + DeviceExtension->TimerCount = -1; + } + } + else + { + /* Not busy, but not ready for the next request */ + DeviceExtension->Flags &= ~SCSI_PORT_DEVICE_BUSY; + InterruptData.Flags &= ~SCSI_PORT_NEXT_REQUEST_READY; + } + } + + /* Any resets? */ + if (InterruptData.Flags & SCSI_PORT_RESET_REPORTED) + { + /* Hold for a bit */ + DeviceExtension->TimerCount = 4; + } + + /* Any ready LUN? */ + if (InterruptData.ReadyLun != NULL) + { + + /* Process all LUNs from the list*/ + while (TRUE) + { + /* Remove it from the list first (as processed) */ + LunExtension = InterruptData.ReadyLun; + InterruptData.ReadyLun = LunExtension->ReadyLun; + LunExtension->ReadyLun = NULL; + + /* Get next request for this LUN */ + SpiGetNextRequestFromLun(DeviceExtension, LunExtension); + + /* Still ready requests exist? + If yes - get spinlock, if no - stop here */ + if (InterruptData.ReadyLun != NULL) + KeAcquireSpinLockAtDpcLevel(&DeviceExtension->SpinLock); + else + break; + } + } + else + { + /* Release the spinlock */ + KeReleaseSpinLockFromDpcLevel(&DeviceExtension->SpinLock); + } + + /* If we ready for next packet, start it */ + if (InterruptData.Flags & SCSI_PORT_NEXT_REQUEST_READY) + IoStartNextPacket(DeviceExtension->DeviceObject, FALSE); + + NeedToStartIo = FALSE; + + /* Loop the completed request list */ + while (InterruptData.CompletedRequests) + { + /* Remove the request */ + SrbInfo = InterruptData.CompletedRequests; + InterruptData.CompletedRequests = SrbInfo->CompletedRequests; + SrbInfo->CompletedRequests = NULL; + + /* Process it */ + SpiProcessCompletedRequest(DeviceExtension, + SrbInfo, + &NeedToStartIo); + } + + /* Loop abort request list */ + while (InterruptData.CompletedAbort) + { + LunExtension = InterruptData.CompletedAbort; + + /* Remove the request */ + InterruptData.CompletedAbort = LunExtension->CompletedAbortRequests; + + /* Get spinlock since we're going to change flags */ + KeAcquireSpinLockAtDpcLevel(&DeviceExtension->SpinLock); + + /* TODO: Put SrbExtension to the list of free extensions */ + ASSERT(FALSE); + } + + /* If we need - call StartIo routine */ + if (NeedToStartIo) + { + /* Make sure CurrentIrp is not null! */ + ASSERT(DpcDeviceObject->CurrentIrp != NULL); + ScsiPortStartIo(DpcDeviceObject, DpcDeviceObject->CurrentIrp); + } + + /* Everything has been done, check */ + if (InterruptData.Flags & SCSI_PORT_ENABLE_INT_REQUEST) + { + /* Synchronize using spinlock */ + KeAcquireSpinLockAtDpcLevel(&DeviceExtension->SpinLock); + + /* Request an interrupt */ + DeviceExtension->HwInterrupt(DeviceExtension->MiniPortDeviceExtension); + + ASSERT(DeviceExtension->Flags & SCSI_PORT_DISABLE_INT_REQUESET); + + /* Should interrupts be enabled again? */ + if (DeviceExtension->Flags & SCSI_PORT_DISABLE_INT_REQUESET) + { + /* Clear this flag */ + DeviceExtension->Flags &= ~SCSI_PORT_DISABLE_INT_REQUESET; + + /* Call a special routine to do this */ + ASSERT(FALSE); +#if 0 + KeSynchronizeExecution(DeviceExtension->Interrupt, + SpiEnableInterrupts, + DeviceExtension); +#endif + } + + /* If we need a notification again - loop */ + if (DeviceExtension->InterruptData.Flags & SCSI_PORT_NOTIFICATION_NEEDED) + goto TryAgain; + + /* Release the spinlock */ + KeReleaseSpinLockFromDpcLevel(&DeviceExtension->SpinLock); + } + + DPRINT("ScsiPortDpcForIsr() done\n"); } @@ -2673,7 +3482,7 @@ DPRINT1("ScsiPortIoTimer()\n"); } - +#if 0 static PSCSI_REQUEST_BLOCK ScsiPortInitSenseRequestSrb(PSCSI_PORT_DEVICE_EXTENSION DeviceExtension, PSCSI_REQUEST_BLOCK OriginalSrb) @@ -2711,7 +3520,7 @@ { DeviceExtension->OriginalSrb = NULL; } - +#endif /********************************************************************** * NAME INTERNAL @@ -3136,6 +3945,39 @@ return Status; } +static +NTSTATUS +SpiStatusSrbToNt(UCHAR SrbStatus) +{ + switch (SRB_STATUS(SrbStatus)) + { + case SRB_STATUS_TIMEOUT: + case SRB_STATUS_COMMAND_TIMEOUT: + return STATUS_IO_TIMEOUT; + + case SRB_STATUS_BAD_SRB_BLOCK_LENGTH: + case SRB_STATUS_BAD_FUNCTION: + return STATUS_INVALID_DEVICE_REQUEST; + + case SRB_STATUS_NO_DEVICE: + case SRB_STATUS_INVALID_LUN: + case SRB_STATUS_INVALID_TARGET_ID: + case SRB_STATUS_NO_HBA: + return STATUS_DEVICE_DOES_NOT_EXIST; + + case SRB_STATUS_DATA_OVERRUN: + return STATUS_BUFFER_OVERFLOW; + + case SRB_STATUS_SELECTION_TIMEOUT: + return STATUS_DEVICE_NOT_CONNECTED; + + default: + return STATUS_IO_DEVICE_ERROR; + } + + return STATUS_IO_DEVICE_ERROR; +} + #undef ScsiPortConvertPhysicalAddressToUlong /* Modified: trunk/reactos/drivers/storage/scsiport-new/scsiport_int.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/storage/scsiport-n…
============================================================================== --- trunk/reactos/drivers/storage/scsiport-new/scsiport_int.h (original) +++ trunk/reactos/drivers/storage/scsiport-new/scsiport_int.h Fri Mar 30 01:05:41 2007 @@ -24,13 +24,25 @@ #define SCSI_PORT_LU_ACTIVE 0x0002 #define SCSI_PORT_NOTIFICATION_NEEDED 0x0004 #define SCSI_PORT_NEXT_REQUEST_READY 0x0008 +#define SCSI_PORT_FLUSH_ADAPTERS 0x0010 +#define SCSI_PORT_MAP_TRANSFER 0x0020 #define SCSI_PORT_RESET 0x0080 #define SCSI_PORT_RESET_REQUEST 0x0100 +#define SCSI_PORT_RESET_REPORTED 0x0200 +#define SCSI_PORT_REQUEST_PENDING 0x0800 #define SCSI_PORT_DISCONNECT_ALLOWED 0x1000 +#define SCSI_PORT_DISABLE_INT_REQUESET 0x2000 #define SCSI_PORT_DISABLE_INTERRUPTS 0x4000 +#define SCSI_PORT_ENABLE_INT_REQUEST 0x8000 +#define SCIS_PORT_TIMER_NEEDED 0x10000 + +/* LUN Extension flags*/ +#define LUNEX_FROZEN_QUEUE 0x0001 +#define LUNEX_NEED_REQUEST_SENSE 0x0004 +#define LUNEX_BUSY 0x0008 +#define LUNEX_FULL_QUEUE 0x0010 +#define LUNEX_REQUEST_PENDING 0x0020 #define SCSI_PORT_SCAN_IN_PROGRESS 0x8000 - - @@ -58,6 +70,14 @@ LIST_ENTRY Requests; PSCSI_REQUEST_BLOCK Srb; PCHAR DataOffset; + PVOID SaveSenseRequest; + + ULONG SequenceNumber; + + /* DMA stuff */ + PVOID BaseOfMapRegister; + ULONG NumberOfMapRegisters; + struct _SCSI_REQUEST_BLOCK_INFO *CompletedRequests; } SCSI_REQUEST_BLOCK_INFO, *PSCSI_REQUEST_BLOCK_INFO; @@ -77,9 +97,18 @@ INQUIRYDATA InquiryData; KDEVICE_QUEUE DeviceQueue; + ULONG SortKey; ULONG QueueCount; - + ULONG MaxQueueCount; + + ULONG AttemptCount; LONG RequestTimeout; + + PIRP BusyRequest; + PIRP PendingRequest; + + struct _SCSI_PORT_LUN_EXTENSION *ReadyLun; + struct _SCSI_PORT_LUN_EXTENSION *CompletedAbortRequests; SCSI_REQUEST_BLOCK_INFO SrbInfo; @@ -120,9 +149,17 @@ { ULONG Flags; /* Interrupt-time flags */ PSCSI_REQUEST_BLOCK_INFO CompletedRequests; /* Linked list of Srb info data */ - + PSCSI_PORT_LUN_EXTENSION CompletedAbort; + PSCSI_PORT_LUN_EXTENSION ReadyLun; } SCSI_PORT_INTERRUPT_DATA, *PSCSI_PORT_INTERRUPT_DATA; + +/* Only for interrupt data saving function */ +typedef struct _SCSI_PORT_SAVE_INTERRUPT +{ + PSCSI_PORT_INTERRUPT_DATA InterruptData; + struct _SCSI_PORT_DEVICE_EXTENSION *DeviceExtension; +} SCSI_PORT_SAVE_INTERRUPT, *PSCSI_PORT_SAVE_INTERRUPT; /* * SCSI_PORT_DEVICE_EXTENSION @@ -159,7 +196,14 @@ SCSI_PORT_INTERRUPT_DATA InterruptData; + /* SRB extension stuff*/ ULONG SrbExtensionSize; + PVOID SrbExtensionBuffer; + PVOID FreeSrbExtensions; + + /* SRB information */ + PSCSI_REQUEST_BLOCK_INFO SrbInfo; + PSCSI_REQUEST_BLOCK_INFO FreeSrbInfo; PIO_SCSI_CAPABILITIES PortCapabilities; @@ -178,6 +222,12 @@ ULONG MapRegisterCount; BOOLEAN MapBuffers; BOOLEAN MapRegisters; + PVOID MapRegisterBase; + + /* Features */ + BOOLEAN SupportsTaggedQueuing; + BOOLEAN SupportsAutoSense; + PHYSICAL_ADDRESS PhysicalAddress; PVOID VirtualAddress;
17 years, 8 months
1
0
0
0
[fireball] 26198: - Change unclear flag name to a better one. - Set needed flags in a few places (which I forgot to set) - this fixes the hang introduced by the previous commit. - Further code prettification.
by fireball@svn.reactos.org
Author: fireball Date: Wed Mar 28 23:26:41 2007 New Revision: 26198 URL:
http://svn.reactos.org/svn/reactos?rev=26198&view=rev
Log: - Change unclear flag name to a better one. - Set needed flags in a few places (which I forgot to set) - this fixes the hang introduced by the previous commit. - Further code prettification. Modified: trunk/reactos/drivers/storage/scsiport-new/scsiport.c trunk/reactos/drivers/storage/scsiport-new/scsiport_int.h Modified: trunk/reactos/drivers/storage/scsiport-new/scsiport.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/storage/scsiport-n…
============================================================================== --- trunk/reactos/drivers/storage/scsiport-new/scsiport.c (original) +++ trunk/reactos/drivers/storage/scsiport-new/scsiport.c Wed Mar 28 23:26:41 2007 @@ -638,54 +638,60 @@ IN struct _HW_INITIALIZATION_DATA *HwInitializationData, IN PVOID HwContext) { - PDRIVER_OBJECT DriverObject = (PDRIVER_OBJECT)Argument1; -// PUNICODE_STRING RegistryPath = (PUNICODE_STRING)Argument2; - PSCSI_PORT_DEVICE_EXTENSION DeviceExtension; - PCONFIGURATION_INFORMATION SystemConfig; - PPORT_CONFIGURATION_INFORMATION PortConfig; - ULONG DeviceExtensionSize; - ULONG PortConfigSize; - BOOLEAN Again; - BOOLEAN DeviceFound = FALSE; - ULONG i; - ULONG Result; - NTSTATUS Status; - ULONG MaxBus; - ULONG BusNumber; - PCI_SLOT_NUMBER SlotNumber; - - PDEVICE_OBJECT PortDeviceObject; - WCHAR NameBuffer[80]; - UNICODE_STRING DeviceName; - WCHAR DosNameBuffer[80]; - UNICODE_STRING DosDeviceName; - PIO_SCSI_CAPABILITIES PortCapabilities; - ULONG MappedIrq; - KIRQL Dirql; - KAFFINITY Affinity; - - - DPRINT ("ScsiPortInitialize() called!\n"); - - if ((HwInitializationData->HwInitialize == NULL) || - (HwInitializationData->HwStartIo == NULL) || - (HwInitializationData->HwInterrupt == NULL) || - (HwInitializationData->HwFindAdapter == NULL) || - (HwInitializationData->HwResetBus == NULL)) - return(STATUS_INVALID_PARAMETER); - - DriverObject->DriverStartIo = ScsiPortStartIo; - DriverObject->MajorFunction[IRP_MJ_CREATE] = ScsiPortCreateClose; - DriverObject->MajorFunction[IRP_MJ_CLOSE] = ScsiPortCreateClose; - DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = ScsiPortDeviceControl; - DriverObject->MajorFunction[IRP_MJ_SCSI] = ScsiPortDispatchScsi; - - SystemConfig = IoGetConfigurationInformation(); - - DeviceExtensionSize = sizeof(SCSI_PORT_DEVICE_EXTENSION) + - HwInitializationData->DeviceExtensionSize; - PortConfigSize = sizeof(PORT_CONFIGURATION_INFORMATION) + - HwInitializationData->NumberOfAccessRanges * sizeof(ACCESS_RANGE); + PDRIVER_OBJECT DriverObject = (PDRIVER_OBJECT)Argument1; + // PUNICODE_STRING RegistryPath = (PUNICODE_STRING)Argument2; + PSCSI_PORT_DEVICE_EXTENSION DeviceExtension; + PCONFIGURATION_INFORMATION SystemConfig; + PPORT_CONFIGURATION_INFORMATION PortConfig; + ULONG DeviceExtensionSize; + ULONG PortConfigSize; + BOOLEAN Again; + BOOLEAN DeviceFound = FALSE; + ULONG i; + ULONG Result; + NTSTATUS Status; + ULONG MaxBus; + ULONG BusNumber; + PCI_SLOT_NUMBER SlotNumber; + + PDEVICE_OBJECT PortDeviceObject; + WCHAR NameBuffer[80]; + UNICODE_STRING DeviceName; + WCHAR DosNameBuffer[80]; + UNICODE_STRING DosDeviceName; + PIO_SCSI_CAPABILITIES PortCapabilities; + ULONG MappedIrq; + KIRQL Dirql; + KAFFINITY Affinity; + + + DPRINT ("ScsiPortInitialize() called!\n"); + + /* Check params for validity */ + if ((HwInitializationData->HwInitialize == NULL) || + (HwInitializationData->HwStartIo == NULL) || + (HwInitializationData->HwInterrupt == NULL) || + (HwInitializationData->HwFindAdapter == NULL) || + (HwInitializationData->HwResetBus == NULL)) + { + return STATUS_INVALID_PARAMETER; + } + + /* Set handlers */ + DriverObject->DriverStartIo = ScsiPortStartIo; + DriverObject->MajorFunction[IRP_MJ_CREATE] = ScsiPortCreateClose; + DriverObject->MajorFunction[IRP_MJ_CLOSE] = ScsiPortCreateClose; + DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = ScsiPortDeviceControl; + DriverObject->MajorFunction[IRP_MJ_SCSI] = ScsiPortDispatchScsi; + + /* Obtain configuration information */ + SystemConfig = IoGetConfigurationInformation(); + + /* Calculate sizes of DeviceExtension and PortConfig */ + DeviceExtensionSize = sizeof(SCSI_PORT_DEVICE_EXTENSION) + + HwInitializationData->DeviceExtensionSize; + PortConfigSize = sizeof(PORT_CONFIGURATION_INFORMATION) + + HwInitializationData->NumberOfAccessRanges * sizeof(ACCESS_RANGE); MaxBus = (HwInitializationData->AdapterInterfaceType == PCIBus) ? 8 : 1; @@ -762,7 +768,7 @@ /* Initialize the device timer */ DeviceExtension->TimerState = IDETimerIdle; - DeviceExtension->TimerCount = 0; + DeviceExtension->TimerCount = -1; IoInitializeTimer (PortDeviceObject, ScsiPortIoTimer, DeviceExtension); @@ -885,6 +891,9 @@ goto ByeBye; } + /* Set flag that it's allowed to disconnect during this command */ + DeviceExtension->Flags |= SCSI_PORT_DISCONNECT_ALLOWED; + /* Initialize counter of active requests (-1 means there are none) */ DeviceExtension->ActiveRequestCounter = -1; @@ -1187,6 +1196,9 @@ } va_end(ap); + + /* Request a DPC after we're done with the interrupt */ + DeviceExtension->InterruptData.Flags |= SCSI_PORT_NOTIFICATION_NEEDED; } @@ -1836,7 +1848,7 @@ } /* Set the time out value */ - DeviceExtension->TimeOutCount = Srb->TimeOutValue; + DeviceExtension->TimerCount = Srb->TimeOutValue; /* We are busy */ DeviceExtension->Flags |= SCSI_PORT_DEVICE_BUSY; @@ -1863,7 +1875,7 @@ if (Srb->SrbFlags & SRB_FLAGS_DISABLE_DISCONNECT) { /* It's a disconnect, so no more requests can go */ - DeviceExtension->Flags &= ~SCSI_PORT_DISCONNECT_IN_PROGRESS; + DeviceExtension->Flags &= ~SCSI_PORT_DISCONNECT_ALLOWED; } LunExtension->Flags |= SCSI_PORT_LU_ACTIVE; @@ -2051,6 +2063,7 @@ /* Wait for it to complete */ if (Status == STATUS_PENDING) { + DPRINT("SpiSendInquiry(): Waiting for the driver to process request...\n"); KeWaitForSingleObject(&Event, Executive, KernelMode, @@ -2058,6 +2071,8 @@ NULL); Status = IoStatusBlock.Status; } + + DPRINT("SpiSendInquiry(): Request processed by driver, status = 0x%08X\n", Status); if (SRB_STATUS(Srb.SrbStatus) == SRB_STATUS_SUCCESS) { @@ -2133,6 +2148,8 @@ /* Free buffers */ ExFreePool(InquiryBuffer); ExFreePool(SenseBuffer); + + DPRINT("SpiSendInquiry() done\n"); return Status; } Modified: trunk/reactos/drivers/storage/scsiport-new/scsiport_int.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/storage/scsiport-n…
============================================================================== --- trunk/reactos/drivers/storage/scsiport-new/scsiport_int.h (original) +++ trunk/reactos/drivers/storage/scsiport-new/scsiport_int.h Wed Mar 28 23:26:41 2007 @@ -26,7 +26,7 @@ #define SCSI_PORT_NEXT_REQUEST_READY 0x0008 #define SCSI_PORT_RESET 0x0080 #define SCSI_PORT_RESET_REQUEST 0x0100 -#define SCSI_PORT_DISCONNECT_IN_PROGRESS 0x1000 +#define SCSI_PORT_DISCONNECT_ALLOWED 0x1000 #define SCSI_PORT_DISABLE_INTERRUPTS 0x4000 #define SCSI_PORT_SCAN_IN_PROGRESS 0x8000 @@ -142,7 +142,6 @@ LONG ActiveRequestCounter; ULONG Flags; - LONG TimeOutCount; KSPIN_LOCK IrpLock; KSPIN_LOCK SpinLock;
17 years, 9 months
1
0
0
0
[hpoussin] 26197: Don't use ntoskrnl.RtlDuplicateUnicodeString, as it is not exported on MS Windows
by hpoussin@svn.reactos.org
Author: hpoussin Date: Wed Mar 28 22:47:35 2007 New Revision: 26197 URL:
http://svn.reactos.org/svn/reactos?rev=26197&view=rev
Log: Don't use ntoskrnl.RtlDuplicateUnicodeString, as it is not exported on MS Windows Modified: trunk/reactos/drivers/bus/serenum/detect.c trunk/reactos/drivers/bus/serenum/fdo.c trunk/reactos/drivers/bus/serenum/misc.c trunk/reactos/drivers/bus/serenum/pdo.c trunk/reactos/drivers/bus/serenum/serenum.c trunk/reactos/drivers/bus/serenum/serenum.h trunk/reactos/drivers/bus/serenum/serenum.rbuild Modified: trunk/reactos/drivers/bus/serenum/detect.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/bus/serenum/detect…
============================================================================== --- trunk/reactos/drivers/bus/serenum/detect.c (original) +++ trunk/reactos/drivers/bus/serenum/detect.c Wed Mar 28 22:47:35 2007 @@ -9,7 +9,6 @@ * Hervé Poussineau (hpoussin(a)reactos.com) */ -#define NDEBUG #include "serenum.h" static NTSTATUS @@ -129,15 +128,15 @@ FdoDeviceExtension = (PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension; RtlZeroMemory(PdoDeviceExtension, sizeof(PDO_DEVICE_EXTENSION)); PdoDeviceExtension->Common.IsFDO = FALSE; - Status = RtlDuplicateUnicodeString(RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE, DeviceDescription, &PdoDeviceExtension->DeviceDescription); - if (!NT_SUCCESS(Status)) goto ByeBye; - Status = RtlDuplicateUnicodeString(RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE, DeviceId, &PdoDeviceExtension->DeviceId); - if (!NT_SUCCESS(Status)) goto ByeBye; - Status = RtlDuplicateUnicodeString(RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE, InstanceId, &PdoDeviceExtension->InstanceId); - if (!NT_SUCCESS(Status)) goto ByeBye; - Status = RtlDuplicateUnicodeString(RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE, HardwareIds, &PdoDeviceExtension->HardwareIds); - if (!NT_SUCCESS(Status)) goto ByeBye; - Status = RtlDuplicateUnicodeString(RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE, CompatibleIds, &PdoDeviceExtension->CompatibleIds); + Status = DuplicateUnicodeString(RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE, DeviceDescription, &PdoDeviceExtension->DeviceDescription); + if (!NT_SUCCESS(Status)) goto ByeBye; + Status = DuplicateUnicodeString(RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE, DeviceId, &PdoDeviceExtension->DeviceId); + if (!NT_SUCCESS(Status)) goto ByeBye; + Status = DuplicateUnicodeString(RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE, InstanceId, &PdoDeviceExtension->InstanceId); + if (!NT_SUCCESS(Status)) goto ByeBye; + Status = DuplicateUnicodeString(RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE, HardwareIds, &PdoDeviceExtension->HardwareIds); + if (!NT_SUCCESS(Status)) goto ByeBye; + Status = DuplicateUnicodeString(RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE, CompatibleIds, &PdoDeviceExtension->CompatibleIds); if (!NT_SUCCESS(Status)) goto ByeBye; /* Device attached to serial port (Pdo) may delegate work to Modified: trunk/reactos/drivers/bus/serenum/fdo.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/bus/serenum/fdo.c?…
============================================================================== --- trunk/reactos/drivers/bus/serenum/fdo.c (original) +++ trunk/reactos/drivers/bus/serenum/fdo.c Wed Mar 28 22:47:35 2007 @@ -7,7 +7,6 @@ * PROGRAMMERS: Hervé Poussineau (hpoussin(a)reactos.com) */ -#define NDEBUG #include "serenum.h" NTSTATUS NTAPI Modified: trunk/reactos/drivers/bus/serenum/misc.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/bus/serenum/misc.c…
============================================================================== --- trunk/reactos/drivers/bus/serenum/misc.c (original) +++ trunk/reactos/drivers/bus/serenum/misc.c Wed Mar 28 22:47:35 2007 @@ -7,9 +7,10 @@ * PROGRAMMERS: Hervé Poussineau (hpoussin(a)reactos.com) */ -#define NDEBUG #include "serenum.h" #include <stdarg.h> + +static IO_COMPLETION_ROUTINE ForwardIrpAndWaitCompletion; /* I really want PCSZ strings as last arguments because * PnP ids are ANSI-encoded in PnP device string @@ -114,7 +115,7 @@ KeInitializeEvent(&Event, NotificationEvent, FALSE); IoCopyCurrentIrpStackLocationToNext(Irp); - DPRINT("Calling lower device %p [%wZ]\n", LowerDevice, &LowerDevice->DriverObject->DriverName); + DPRINT("Calling lower device %p\n", LowerDevice); IoSetCompletionRoutine(Irp, ForwardIrpAndWaitCompletion, &Event, TRUE, TRUE, TRUE); Status = IoCallDriver(LowerDevice, Irp); @@ -141,8 +142,7 @@ LowerDevice = DeviceExtension->LowerDevice; ASSERT(LowerDevice); - DPRINT("Calling lower device 0x%p [%wZ]\n", - LowerDevice, &LowerDevice->DriverObject->DriverName); + DPRINT("Calling lower device 0x%p\n", LowerDevice); IoSkipCurrentIrpStackLocation(Irp); return IoCallDriver(LowerDevice, Irp); } @@ -160,8 +160,7 @@ Fdo = DeviceExtension->AttachedFdo; ASSERT(Fdo); - DPRINT("Calling attached Fdo 0x%p [%wZ]\n", - Fdo, &Fdo->DriverObject->DriverName); + DPRINT("Calling attached Fdo 0x%p\n", Fdo); IoSkipCurrentIrpStackLocation(Irp); return IoCallDriver(Fdo, Irp); } @@ -180,3 +179,48 @@ IoSkipCurrentIrpStackLocation(Irp); return IoCallDriver(LowerDevice, Irp); } + +NTSTATUS +DuplicateUnicodeString( + IN ULONG Flags, + IN PCUNICODE_STRING SourceString, + OUT PUNICODE_STRING DestinationString) +{ + if (SourceString == NULL || DestinationString == NULL + || SourceString->Length > SourceString->MaximumLength + || (SourceString->Length == 0 && SourceString->MaximumLength > 0 && SourceString->Buffer == NULL) + || Flags == RTL_DUPLICATE_UNICODE_STRING_ALLOCATE_NULL_STRING || Flags >= 4) + { + return STATUS_INVALID_PARAMETER; + } + + + if ((SourceString->Length == 0) + && (Flags != (RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE | + RTL_DUPLICATE_UNICODE_STRING_ALLOCATE_NULL_STRING))) + { + DestinationString->Length = 0; + DestinationString->MaximumLength = 0; + DestinationString->Buffer = NULL; + } + else + { + USHORT DestMaxLength = SourceString->Length; + + if (Flags & RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE) + DestMaxLength += sizeof(UNICODE_NULL); + + DestinationString->Buffer = ExAllocatePoolWithTag(PagedPool, DestMaxLength, SERENUM_TAG); + if (DestinationString->Buffer == NULL) + return STATUS_NO_MEMORY; + + RtlCopyMemory(DestinationString->Buffer, SourceString->Buffer, SourceString->Length); + DestinationString->Length = SourceString->Length; + DestinationString->MaximumLength = DestMaxLength; + + if (Flags & RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE) + DestinationString->Buffer[DestinationString->Length / sizeof(WCHAR)] = 0; + } + + return STATUS_SUCCESS; +} Modified: trunk/reactos/drivers/bus/serenum/pdo.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/bus/serenum/pdo.c?…
============================================================================== --- trunk/reactos/drivers/bus/serenum/pdo.c (original) +++ trunk/reactos/drivers/bus/serenum/pdo.c Wed Mar 28 22:47:35 2007 @@ -7,7 +7,6 @@ * PROGRAMMERS: Hervé Poussineau (hpoussin(a)reactos.com) */ -#define NDEBUG #include "serenum.h" static NTSTATUS @@ -70,7 +69,7 @@ return STATUS_NOT_SUPPORTED; } - Status = RtlDuplicateUnicodeString( + Status = DuplicateUnicodeString( RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE, SourceString, &String); Modified: trunk/reactos/drivers/bus/serenum/serenum.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/bus/serenum/serenu…
============================================================================== --- trunk/reactos/drivers/bus/serenum/serenum.c (original) +++ trunk/reactos/drivers/bus/serenum/serenum.c Wed Mar 28 22:47:35 2007 @@ -7,9 +7,13 @@ * PROGRAMMERS: Hervé Poussineau (hpoussin(a)reactos.com) */ -#define NDEBUG #define INITGUID #include "serenum.h" + +static DRIVER_DISPATCH SerenumPnp; +static DRIVER_DISPATCH IrpStub; +static DRIVER_UNLOAD DriverUnload; +DRIVER_INITIALIZE DriverEntry; static NTSTATUS NTAPI SerenumPnp( Modified: trunk/reactos/drivers/bus/serenum/serenum.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/bus/serenum/serenu…
============================================================================== --- trunk/reactos/drivers/bus/serenum/serenum.h (original) +++ trunk/reactos/drivers/bus/serenum/serenum.h Wed Mar 28 22:47:35 2007 @@ -86,10 +86,7 @@ /************************************ fdo.c */ -NTSTATUS NTAPI -SerenumAddDevice( - IN PDRIVER_OBJECT DriverObject, - IN PDEVICE_OBJECT Pdo); +DRIVER_ADD_DEVICE SerenumAddDevice; NTSTATUS SerenumFdoPnp( @@ -123,6 +120,12 @@ IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp); +NTSTATUS +DuplicateUnicodeString( + IN ULONG Flags, + IN PCUNICODE_STRING SourceString, + OUT PUNICODE_STRING DestinationString); + /************************************ pdo.c */ NTSTATUS Modified: trunk/reactos/drivers/bus/serenum/serenum.rbuild URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/bus/serenum/serenu…
============================================================================== --- trunk/reactos/drivers/bus/serenum/serenum.rbuild (original) +++ trunk/reactos/drivers/bus/serenum/serenum.rbuild Wed Mar 28 22:47:35 2007 @@ -1,6 +1,7 @@ <module name="serenum" type="kernelmodedriver" installbase="system32/drivers" installname="serenum.sys"> <include base="serenum">.</include> <define name="__USE_W32API" /> + <define name="NDEBUG" /> <library>ntoskrnl</library> <library>hal</library> <file>detect.c</file>
17 years, 9 months
1
0
0
0
[fireball] 26196: - Rearrange code inside ScsiPortStartIo() routine (some code for dma-support added, but currently disabled), also change time when spinlock is being held. - Respective changes in ScsiPortStartPacket(), also some code is missing for rare kind of requests. - Add flags check into ScsiPortIsr(), so that we skip unwanted interrupts (and change to usage of the new interrupt flags structure instead of a strange and unclear "IrpFlags" field).
by fireball@svn.reactos.org
Author: fireball Date: Wed Mar 28 22:29:15 2007 New Revision: 26196 URL:
http://svn.reactos.org/svn/reactos?rev=26196&view=rev
Log: - Rearrange code inside ScsiPortStartIo() routine (some code for dma-support added, but currently disabled), also change time when spinlock is being held. - Respective changes in ScsiPortStartPacket(), also some code is missing for rare kind of requests. - Add flags check into ScsiPortIsr(), so that we skip unwanted interrupts (and change to usage of the new interrupt flags structure instead of a strange and unclear "IrpFlags" field). Modified: trunk/reactos/drivers/storage/scsiport-new/scsiport.c trunk/reactos/drivers/storage/scsiport-new/scsiport_int.h Modified: trunk/reactos/drivers/storage/scsiport-new/scsiport.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/storage/scsiport-n…
============================================================================== --- trunk/reactos/drivers/storage/scsiport-new/scsiport.c (original) +++ trunk/reactos/drivers/storage/scsiport-new/scsiport.c Wed Mar 28 22:29:15 2007 @@ -885,6 +885,9 @@ goto ByeBye; } + /* Initialize counter of active requests (-1 means there are none) */ + DeviceExtension->ActiveRequestCounter = -1; + if (!(HwInitializationData->HwInitialize)(&DeviceExtension->MiniPortDeviceExtension)) { DbgPrint("HwInitialize() failed!"); @@ -1642,152 +1645,253 @@ ScsiPortStartIo(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp) { - PSCSI_PORT_DEVICE_EXTENSION DeviceExtension; - PSCSI_PORT_LUN_EXTENSION LunExtension; - PIO_STACK_LOCATION IrpStack; - PSCSI_REQUEST_BLOCK Srb; - KIRQL oldIrql; - - DPRINT("ScsiPortStartIo() called!\n"); - - DeviceExtension = DeviceObject->DeviceExtension; - IrpStack = IoGetCurrentIrpStackLocation(Irp); - - DPRINT("DeviceExtension %p\n", DeviceExtension); - - oldIrql = KeGetCurrentIrql(); - - if (IrpStack->MajorFunction != IRP_MJ_SCSI) - { - DPRINT("No IRP_MJ_SCSI!\n"); - Irp->IoStatus.Status = STATUS_NOT_SUPPORTED; - Irp->IoStatus.Information = 0; - IoCompleteRequest (Irp, - IO_NO_INCREMENT); - if (oldIrql < DISPATCH_LEVEL) - { - KeRaiseIrql (DISPATCH_LEVEL, - &oldIrql); - IoStartNextPacket (DeviceObject, - FALSE); - KeLowerIrql (oldIrql); - } - else - { - IoStartNextPacket (DeviceObject, - FALSE); - } - return; - } - - Srb = IrpStack->Parameters.Scsi.Srb; - - LunExtension = SpiGetLunExtension(DeviceExtension, - Srb->PathId, - Srb->TargetId, - Srb->Lun); - if (LunExtension == NULL) - { - DPRINT("Can't get LunExtension!\n"); - Irp->IoStatus.Status = STATUS_NO_SUCH_DEVICE; - Irp->IoStatus.Information = 0; - IoCompleteRequest (Irp, - IO_NO_INCREMENT); - if (oldIrql < DISPATCH_LEVEL) - { - KeRaiseIrql (DISPATCH_LEVEL, - &oldIrql); - IoStartNextPacket (DeviceObject, - FALSE); - KeLowerIrql (oldIrql); - } - else - { - IoStartNextPacket (DeviceObject, - FALSE); - } - return; - } - - Irp->IoStatus.Status = STATUS_SUCCESS; - Irp->IoStatus.Information = Srb->DataTransferLength; - - DeviceExtension->CurrentIrp = Irp; - - if (!KeSynchronizeExecution(DeviceExtension->Interrupt, - ScsiPortStartPacket, - DeviceExtension)) - { - DPRINT("Synchronization failed!\n"); - - Irp->IoStatus.Status = STATUS_UNSUCCESSFUL; - Irp->IoStatus.Information = 0; - IoCompleteRequest(Irp, - IO_NO_INCREMENT); - if (oldIrql < DISPATCH_LEVEL) - { - KeRaiseIrql (DISPATCH_LEVEL, - &oldIrql); - IoStartNextPacket (DeviceObject, - FALSE); - KeLowerIrql (oldIrql); - } - else - { - IoStartNextPacket (DeviceObject, - FALSE); - } - } - - KeAcquireSpinLock(&DeviceExtension->IrpLock, &oldIrql); - if (DeviceExtension->IrpFlags & IRP_FLAG_COMPLETE) - { - DeviceExtension->IrpFlags &= ~IRP_FLAG_COMPLETE; - IoCompleteRequest(Irp, - IO_NO_INCREMENT); - } - - if (DeviceExtension->IrpFlags & IRP_FLAG_NEXT) - { - DeviceExtension->IrpFlags &= ~IRP_FLAG_NEXT; - KeReleaseSpinLockFromDpcLevel(&DeviceExtension->IrpLock); - IoStartNextPacket(DeviceObject, - FALSE); - KeLowerIrql(oldIrql); - } - else - { - KeReleaseSpinLock(&DeviceExtension->IrpLock, oldIrql); - } - - DPRINT("ScsiPortStartIo() done\n"); + PSCSI_PORT_DEVICE_EXTENSION DeviceExtension; + PSCSI_PORT_LUN_EXTENSION LunExtension; + PIO_STACK_LOCATION IrpStack; + PSCSI_REQUEST_BLOCK Srb; + PSCSI_REQUEST_BLOCK_INFO SrbInfo; + LONG CounterResult; + + DPRINT("ScsiPortStartIo() called!\n"); + + DeviceExtension = DeviceObject->DeviceExtension; + IrpStack = IoGetCurrentIrpStackLocation(Irp); + + DPRINT("DeviceExtension %p\n", DeviceExtension); + + Srb = IrpStack->Parameters.Scsi.Srb; + + /* FIXME: Apply standard flags to Srb->SrbFlags ? */ + + /* Get LUN extension */ + LunExtension = SpiGetLunExtension(DeviceExtension, + Srb->PathId, + Srb->TargetId, + Srb->Lun); + + if (DeviceExtension->NeedSrbDataAlloc || + DeviceExtension->NeedSrbExtensionAlloc) + { + /* TODO: Implement */ + ASSERT(FALSE); + SrbInfo = NULL; + } + else + { + /* No allocations are needed */ + SrbInfo = &LunExtension->SrbInfo; + Srb->SrbExtension = NULL; + Srb->QueueTag = SP_UNTAGGED; + } + + /* FIXME: Increase sequence number here of SRB, if it's ever needed */ + + /* Check some special SRBs */ + if (Srb->Function == SRB_FUNCTION_ABORT_COMMAND) + { + /* Some special handling */ + DPRINT1("Abort command! Unimplemented now\n"); + } + else + { + SrbInfo->Srb = Srb; + } + + if (Srb->SrbFlags & SRB_FLAGS_UNSPECIFIED_DIRECTION) + { + // Store the MDL virtual address in SrbInfo structure + SrbInfo->DataOffset = MmGetMdlVirtualAddress(Irp->MdlAddress); + + if (DeviceExtension->MapBuffers && Irp->MdlAddress) + { + /* Calculate offset within DataBuffer */ + SrbInfo->DataOffset = MmGetSystemAddressForMdl(Irp->MdlAddress); + Srb->DataBuffer = SrbInfo->DataOffset + + (ULONG)((PUCHAR)Srb->DataBuffer - + (PUCHAR)MmGetMdlVirtualAddress(Irp->MdlAddress)); + } + + if (DeviceExtension->AdapterObject) + { + /* Flush buffers */ + KeFlushIoBuffers(Irp->MdlAddress, + Srb->SrbFlags & SRB_FLAGS_DATA_IN ? TRUE : FALSE, + TRUE); + } + + if (DeviceExtension->MapRegisters) + { +#if 0 + /* Calculate number of needed map registers */ + SrbInfo->NumberOfMapRegisters = ADDRESS_AND_SIZE_TO_SPAN_PAGES( + Srb->DataBuffer, + Srb->DataTransferLength); + + /* Allocate adapter channel */ + Status = IoAllocateAdapterChannel(DeviceExtension->AdapterObject, + DeviceExtension->DeviceObject, + SrbInfo->NumberOfMapRegisters, + SpiAdapterControl, + SrbInfo); + + if (!NT_SUCCESS(Status)) + { + DPRINT1("IoAllocateAdapterChannel() failed!\n"); + + Srb->SrbStatus = SRB_STATUS_INVALID_REQUEST; + ScsiPortNotification(RequestComplete, + DeviceExtension + 1, + Srb); + + ScsiPortNotification(NextRequest, + DeviceExtension + 1); + + /* Request DPC for that work */ + IoRequestDpc(DeviceExtension->DeviceObject, NULL, NULL); + } + + /* Control goes to SpiAdapterControl */ + return; +#else + ASSERT(FALSE); +#endif + } + } + + /* Increase active request counter */ + CounterResult = InterlockedIncrement(&DeviceExtension->ActiveRequestCounter); + + if (CounterResult == 0 && + DeviceExtension->AdapterObject != NULL && + !DeviceExtension->MapRegisters) + { +#if 0 + IoAllocateAdapterChannel( + DeviceExtension->AdapterObject, + DeviceObject, + DeviceExtension->PortCapabilities.MaximumPhysicalPages, + ScsiPortAllocationRoutine, + LunExtension + ); + + return; +#else + /* TODO: DMA is not implemented yet */ + ASSERT(FALSE); +#endif + } + + + KeAcquireSpinLockAtDpcLevel(&DeviceExtension->IrpLock); + + if (!KeSynchronizeExecution(DeviceExtension->Interrupt, + ScsiPortStartPacket, + DeviceObject)) + { + DPRINT("Synchronization failed!\n"); + + Irp->IoStatus.Status = STATUS_UNSUCCESSFUL; + Irp->IoStatus.Information = 0; + KeReleaseSpinLockFromDpcLevel(&DeviceExtension->IrpLock); + + IoCompleteRequest(Irp, IO_NO_INCREMENT); + } + + KeReleaseSpinLockFromDpcLevel(&DeviceExtension->IrpLock); + + DPRINT("ScsiPortStartIo() done\n"); } static BOOLEAN STDCALL ScsiPortStartPacket(IN OUT PVOID Context) { - PSCSI_PORT_DEVICE_EXTENSION DeviceExtension; - PIO_STACK_LOCATION IrpStack; - PSCSI_REQUEST_BLOCK Srb; - - DPRINT("ScsiPortStartPacket() called\n"); - - DeviceExtension = (PSCSI_PORT_DEVICE_EXTENSION)Context; - - IrpStack = IoGetCurrentIrpStackLocation(DeviceExtension->CurrentIrp); - Srb = IrpStack->Parameters.Scsi.Srb; - - /* Allocte SRB extension */ - if (DeviceExtension->SrbExtensionSize != 0) - { - Srb->SrbExtension = DeviceExtension->VirtualAddress; - } - - return(DeviceExtension->HwStartIo(&DeviceExtension->MiniPortDeviceExtension, - Srb)); -} - + PSCSI_PORT_DEVICE_EXTENSION DeviceExtension; + PIO_STACK_LOCATION IrpStack; + PSCSI_REQUEST_BLOCK Srb; + PDEVICE_OBJECT DeviceObject = (PDEVICE_OBJECT)Context; + PSCSI_PORT_LUN_EXTENSION LunExtension; + BOOLEAN Result; + BOOLEAN StartTimer; + + DPRINT("ScsiPortStartPacket() called\n"); + + DeviceExtension = (PSCSI_PORT_DEVICE_EXTENSION)DeviceObject->DeviceExtension; + + IrpStack = IoGetCurrentIrpStackLocation(DeviceObject->CurrentIrp); + Srb = IrpStack->Parameters.Scsi.Srb; + + /* Get LUN extension */ + LunExtension = SpiGetLunExtension(DeviceExtension, + Srb->PathId, + Srb->TargetId, + Srb->Lun); + + /* Check if we are in a reset state */ + if (DeviceExtension->InterruptData.Flags & SCSI_PORT_RESET) + { + /* Mark the we've got requests while being in the reset state */ + DeviceExtension->InterruptData.Flags |= SCSI_PORT_RESET_REQUEST; + return TRUE; + } + + /* Set the time out value */ + DeviceExtension->TimeOutCount = Srb->TimeOutValue; + + /* We are busy */ + DeviceExtension->Flags |= SCSI_PORT_DEVICE_BUSY; + + if (LunExtension->RequestTimeout != -1) + { + /* Timer already active */ + StartTimer = FALSE; + } + else + { + /* It hasn't been initialized yet */ + LunExtension->RequestTimeout = Srb->TimeOutValue; + StartTimer = TRUE; + } + + if (Srb->SrbFlags & SRB_FLAGS_BYPASS_FROZEN_QUEUE) + { + /* TODO: Handle bypass-requests */ + ASSERT(FALSE); + } + else + { + if (Srb->SrbFlags & SRB_FLAGS_DISABLE_DISCONNECT) + { + /* It's a disconnect, so no more requests can go */ + DeviceExtension->Flags &= ~SCSI_PORT_DISCONNECT_IN_PROGRESS; + } + + LunExtension->Flags |= SCSI_PORT_LU_ACTIVE; + + /* Increment queue count */ + LunExtension->QueueCount++; + + /* If it's tagged - special thing */ + if (Srb->QueueTag != SP_UNTAGGED) + { + /* TODO: Support tagged requests */ + ASSERT(FALSE); + } + } + + /* Mark this Srb active */ + Srb->SrbFlags |= SRB_FLAGS_IS_ACTIVE; + + /* Call HwStartIo routine */ + Result = DeviceExtension->HwStartIo(&DeviceExtension->MiniPortDeviceExtension, + Srb); + + /* If notification is needed, then request a DPC */ + if (DeviceExtension->InterruptData.Flags & SCSI_PORT_NOTIFICATION_NEEDED) + IoRequestDpc(DeviceExtension->DeviceObject, NULL, NULL); + + return Result; +} static PSCSI_PORT_LUN_EXTENSION SpiAllocateLunExtension (IN PSCSI_PORT_DEVICE_EXTENSION DeviceExtension) @@ -1817,6 +1921,9 @@ /* Initialize a list of requests */ InitializeListHead(&LunExtension->SrbInfo.Requests); + + /* Initialize timeout counter */ + LunExtension->RequestTimeout = -1; /* TODO: Initialize other fields */ @@ -2390,29 +2497,31 @@ static BOOLEAN STDCALL ScsiPortIsr(IN PKINTERRUPT Interrupt, - IN PVOID ServiceContext) -{ - PSCSI_PORT_DEVICE_EXTENSION DeviceExtension; - BOOLEAN Result; - - DPRINT("ScsiPortIsr() called!\n"); - - DeviceExtension = (PSCSI_PORT_DEVICE_EXTENSION)ServiceContext; - - Result = DeviceExtension->HwInterrupt(&DeviceExtension->MiniPortDeviceExtension); - if (Result == FALSE) - { - return(FALSE); - } - - if (DeviceExtension->IrpFlags) - { - IoRequestDpc(DeviceExtension->DeviceObject, - DeviceExtension->CurrentIrp, - DeviceExtension); - } - - return(TRUE); + IN PVOID ServiceContext) +{ + PSCSI_PORT_DEVICE_EXTENSION DeviceExtension; + BOOLEAN Result; + + DPRINT("ScsiPortIsr() called!\n"); + + DeviceExtension = (PSCSI_PORT_DEVICE_EXTENSION)ServiceContext; + + /* If interrupts are disabled - we don't expect any */ + if (DeviceExtension->InterruptData.Flags & SCSI_PORT_DISABLE_INTERRUPTS) + return FALSE; + + /* Call miniport's HwInterrupt routine */ + Result = DeviceExtension->HwInterrupt(&DeviceExtension->MiniPortDeviceExtension); + + /* If flag of notification is set - queue a DPC */ + if (DeviceExtension->InterruptData.Flags & SCSI_PORT_NOTIFICATION_NEEDED) + { + IoRequestDpc(DeviceExtension->DeviceObject, + DeviceExtension->CurrentIrp, + DeviceExtension); + } + + return TRUE; } @@ -2483,7 +2592,7 @@ KeReleaseSpinLockFromDpcLevel(&DeviceExtension->IrpLock); if (!KeSynchronizeExecution(DeviceExtension->Interrupt, ScsiPortStartPacket, - DeviceExtension)) + DpcDeviceObject)) { DPRINT1("Synchronization failed!\n"); Modified: trunk/reactos/drivers/storage/scsiport-new/scsiport_int.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/storage/scsiport-n…
============================================================================== --- trunk/reactos/drivers/storage/scsiport-new/scsiport_int.h (original) +++ trunk/reactos/drivers/storage/scsiport-new/scsiport_int.h Wed Mar 28 22:29:15 2007 @@ -20,8 +20,19 @@ #define LUS_NUMBER 8 /* Flags */ -#define SCSI_PORT_NEXT_REQUEST_READY 0x0008 -#define SCSI_PORT_SCAN_IN_PROGRESS 0x8000 +#define SCSI_PORT_DEVICE_BUSY 0x0001 +#define SCSI_PORT_LU_ACTIVE 0x0002 +#define SCSI_PORT_NOTIFICATION_NEEDED 0x0004 +#define SCSI_PORT_NEXT_REQUEST_READY 0x0008 +#define SCSI_PORT_RESET 0x0080 +#define SCSI_PORT_RESET_REQUEST 0x0100 +#define SCSI_PORT_DISCONNECT_IN_PROGRESS 0x1000 +#define SCSI_PORT_DISABLE_INTERRUPTS 0x4000 +#define SCSI_PORT_SCAN_IN_PROGRESS 0x8000 + + + + typedef enum _SCSI_PORT_TIMER_STATES { @@ -46,6 +57,7 @@ { LIST_ENTRY Requests; PSCSI_REQUEST_BLOCK Srb; + PCHAR DataOffset; struct _SCSI_REQUEST_BLOCK_INFO *CompletedRequests; } SCSI_REQUEST_BLOCK_INFO, *PSCSI_REQUEST_BLOCK_INFO; @@ -65,6 +77,9 @@ INQUIRYDATA InquiryData; KDEVICE_QUEUE DeviceQueue; + ULONG QueueCount; + + LONG RequestTimeout; SCSI_REQUEST_BLOCK_INFO SrbInfo; @@ -125,6 +140,10 @@ PBUSES_CONFIGURATION_INFORMATION BusesConfig; ULONG PortNumber; + LONG ActiveRequestCounter; + ULONG Flags; + LONG TimeOutCount; + KSPIN_LOCK IrpLock; KSPIN_LOCK SpinLock; PKINTERRUPT Interrupt; @@ -158,10 +177,15 @@ /* DMA related stuff */ PADAPTER_OBJECT AdapterObject; ULONG MapRegisterCount; + BOOLEAN MapBuffers; + BOOLEAN MapRegisters; PHYSICAL_ADDRESS PhysicalAddress; PVOID VirtualAddress; ULONG CommonBufferLength; + BOOLEAN NeedSrbExtensionAlloc; + BOOLEAN NeedSrbDataAlloc; + UCHAR MiniPortDeviceExtension[1]; /* must be the last entry */ } SCSI_PORT_DEVICE_EXTENSION, *PSCSI_PORT_DEVICE_EXTENSION;
17 years, 9 months
1
0
0
0
[janderwald] 26195: - fix memory leak
by janderwald@svn.reactos.org
Author: janderwald Date: Wed Mar 28 21:43:44 2007 New Revision: 26195 URL:
http://svn.reactos.org/svn/reactos?rev=26195&view=rev
Log: - fix memory leak Modified: trunk/reactos/drivers/filesystems/np/create.c Modified: trunk/reactos/drivers/filesystems/np/create.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/np/cre…
============================================================================== --- trunk/reactos/drivers/filesystems/np/create.c (original) +++ trunk/reactos/drivers/filesystems/np/create.c Wed Mar 28 21:43:44 2007 @@ -390,6 +390,7 @@ if (Fcb == NULL) { KeUnlockMutex(&DeviceExt->PipeListLock); + ExFreePool(Ccb); Irp->IoStatus.Status = STATUS_NO_MEMORY; Irp->IoStatus.Information = 0; IoCompleteRequest(Irp, IO_NO_INCREMENT);
17 years, 9 months
1
0
0
0
[hpoussin] 26194: Fix interrupt resources (related to r21188 fix)
by hpoussin@svn.reactos.org
Author: hpoussin Date: Wed Mar 28 21:40:57 2007 New Revision: 26194 URL:
http://svn.reactos.org/svn/reactos?rev=26194&view=rev
Log: Fix interrupt resources (related to r21188 fix) Modified: trunk/reactos/boot/freeldr/freeldr/arch/i386/hardware.c trunk/reactos/drivers/bus/acpi/ospm/fdo.c trunk/reactos/drivers/bus/pci/pdo.c Modified: trunk/reactos/boot/freeldr/freeldr/arch/i386/hardware.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/arch/…
============================================================================== --- trunk/reactos/boot/freeldr/freeldr/arch/i386/hardware.c (original) +++ trunk/reactos/boot/freeldr/freeldr/arch/i386/hardware.c Wed Mar 28 21:40:57 2007 @@ -937,8 +937,8 @@ PartialDescriptor->Type = CmResourceTypeInterrupt; PartialDescriptor->ShareDisposition = CmResourceShareUndetermined; PartialDescriptor->Flags = CM_RESOURCE_INTERRUPT_LATCHED; - PartialDescriptor->u.Interrupt.Level = 0; - PartialDescriptor->u.Interrupt.Vector = 6; + PartialDescriptor->u.Interrupt.Level = 6; + PartialDescriptor->u.Interrupt.Vector = 0; PartialDescriptor->u.Interrupt.Affinity = 0xFFFFFFFF; /* Set DMA channel */ @@ -1422,8 +1422,8 @@ PartialDescriptor->Type = CmResourceTypeInterrupt; PartialDescriptor->ShareDisposition = CmResourceShareUndetermined; PartialDescriptor->Flags = CM_RESOURCE_INTERRUPT_LATCHED; - PartialDescriptor->u.Interrupt.Level = 0; - PartialDescriptor->u.Interrupt.Vector = Irq[i]; + PartialDescriptor->u.Interrupt.Level = Irq[i]; + PartialDescriptor->u.Interrupt.Vector = 0; PartialDescriptor->u.Interrupt.Affinity = 0xFFFFFFFF; /* Set serial data (device specific) */ @@ -1570,8 +1570,8 @@ PartialDescriptor->Type = CmResourceTypeInterrupt; PartialDescriptor->ShareDisposition = CmResourceShareUndetermined; PartialDescriptor->Flags = CM_RESOURCE_INTERRUPT_LATCHED; - PartialDescriptor->u.Interrupt.Level = 0; - PartialDescriptor->u.Interrupt.Vector = Irq[i]; + PartialDescriptor->u.Interrupt.Level = Irq[i]; + PartialDescriptor->u.Interrupt.Vector = 0; PartialDescriptor->u.Interrupt.Affinity = 0xFFFFFFFF; } @@ -1828,8 +1828,8 @@ PartialDescriptor->Type = CmResourceTypeInterrupt; PartialDescriptor->ShareDisposition = CmResourceShareUndetermined; PartialDescriptor->Flags = CM_RESOURCE_INTERRUPT_LATCHED; - PartialDescriptor->u.Interrupt.Level = 0; - PartialDescriptor->u.Interrupt.Vector = 1; + PartialDescriptor->u.Interrupt.Level = 1; + PartialDescriptor->u.Interrupt.Vector = 0; PartialDescriptor->u.Interrupt.Affinity = 0xFFFFFFFF; /* Set IO Port 0x60 */ @@ -2020,8 +2020,8 @@ FullResourceDescriptor.PartialResourceList.PartialDescriptors[0].Type = CmResourceTypeInterrupt; FullResourceDescriptor.PartialResourceList.PartialDescriptors[0].ShareDisposition = CmResourceShareUndetermined; FullResourceDescriptor.PartialResourceList.PartialDescriptors[0].Flags = CM_RESOURCE_INTERRUPT_LATCHED; - FullResourceDescriptor.PartialResourceList.PartialDescriptors[0].u.Interrupt.Level = 0; - FullResourceDescriptor.PartialResourceList.PartialDescriptors[0].u.Interrupt.Vector = 12; + FullResourceDescriptor.PartialResourceList.PartialDescriptors[0].u.Interrupt.Level = 12; + FullResourceDescriptor.PartialResourceList.PartialDescriptors[0].u.Interrupt.Vector = 0; FullResourceDescriptor.PartialResourceList.PartialDescriptors[0].u.Interrupt.Affinity = 0xFFFFFFFF; /* Set 'Configuration Data' value */ Modified: trunk/reactos/drivers/bus/acpi/ospm/fdo.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/bus/acpi/ospm/fdo.…
============================================================================== --- trunk/reactos/drivers/bus/acpi/ospm/fdo.c (original) +++ trunk/reactos/drivers/bus/acpi/ospm/fdo.c Wed Mar 28 21:40:57 2007 @@ -262,8 +262,8 @@ (irq_data->shared_exclusive == SHARED ? CmResourceShareShared : CmResourceShareDeviceExclusive); ResourceDescriptor->Flags = (irq_data->edge_level == LEVEL_SENSITIVE ? CM_RESOURCE_INTERRUPT_LEVEL_SENSITIVE : CM_RESOURCE_INTERRUPT_LATCHED); - ResourceDescriptor->u.Interrupt.Level = 0; - ResourceDescriptor->u.Interrupt.Vector = irq_data->interrupts[i]; + ResourceDescriptor->u.Interrupt.Level = irq_data->interrupts[i]; + ResourceDescriptor->u.Interrupt.Vector = 0; ResourceDescriptor->u.Interrupt.Affinity = (KAFFINITY)(-1); RequirementDescriptor->Option = 0; /* Required */ Modified: trunk/reactos/drivers/bus/pci/pdo.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/bus/pci/pdo.c?rev=…
============================================================================== --- trunk/reactos/drivers/bus/pci/pdo.c (original) +++ trunk/reactos/drivers/bus/pci/pdo.c Wed Mar 28 21:40:57 2007 @@ -764,7 +764,7 @@ Descriptor->ShareDisposition = CmResourceShareShared; Descriptor->Flags = CM_RESOURCE_INTERRUPT_LEVEL_SENSITIVE; Descriptor->u.Interrupt.Level = PciConfig.u.type0.InterruptLine; - Descriptor->u.Interrupt.Vector = PciConfig.u.type0.InterruptLine; + Descriptor->u.Interrupt.Vector = 0; Descriptor->u.Interrupt.Affinity = 0xFFFFFFFF; } }
17 years, 9 months
1
0
0
0
← Newer
1
2
3
4
5
6
...
29
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
Results per page:
10
25
50
100
200