ReactOS.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
List overview
Download
Ros-diffs
May 2011
----- 2024 -----
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
ros-diffs@reactos.org
26 participants
511 discussions
Start a n
N
ew thread
[gadamopoulos] 51679: [regedit] - Reduce flicker
by gadamopoulos@svn.reactos.org
Author: gadamopoulos Date: Wed May 11 21:34:47 2011 New Revision: 51679 URL:
http://svn.reactos.org/svn/reactos?rev=51679&view=rev
Log: [regedit] - Reduce flicker Modified: trunk/reactos/base/applications/regedit/main.c Modified: trunk/reactos/base/applications/regedit/main.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/regedit/…
============================================================================== --- trunk/reactos/base/applications/regedit/main.c [iso-8859-1] (original) +++ trunk/reactos/base/applications/regedit/main.c [iso-8859-1] Wed May 11 21:34:47 2011 @@ -68,7 +68,6 @@ ZeroMemory(&wcFrame, sizeof(WNDCLASSEX)); wcFrame.cbSize = sizeof(WNDCLASSEX); - wcFrame.style = CS_HREDRAW | CS_VREDRAW; wcFrame.lpfnWndProc = FrameWndProc; wcFrame.hInstance = hInstance; wcFrame.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_REGEDIT)); @@ -82,7 +81,6 @@ ZeroMemory(&wcChild, sizeof(WNDCLASSEX)); wcChild.cbSize = sizeof(WNDCLASSEX); - wcChild.style = CS_HREDRAW | CS_VREDRAW; wcChild.lpfnWndProc = ChildWndProc; wcChild.cbWndExtra = sizeof(HANDLE); wcChild.hInstance = hInstance; @@ -135,7 +133,7 @@ } /* Create the status bar */ - hStatusBar = CreateStatusWindow(WS_VISIBLE|WS_CHILD|WS_CLIPSIBLINGS|SBT_NOBORDERS, + hStatusBar = CreateStatusWindow(WS_VISIBLE|WS_CHILD|WS_CLIPSIBLINGS|WS_CLIPCHILDREN|SBT_NOBORDERS, _T(""), hFrameWnd, STATUS_WINDOW); if (hStatusBar) {
13 years, 6 months
1
0
0
0
[gadamopoulos] 51678: [eventvwr] - Reduce flicker
by gadamopoulos@svn.reactos.org
Author: gadamopoulos Date: Wed May 11 21:33:27 2011 New Revision: 51678 URL:
http://svn.reactos.org/svn/reactos?rev=51678&view=rev
Log: [eventvwr] - Reduce flicker Modified: trunk/reactos/base/applications/mscutils/eventvwr/eventvwr.c Modified: trunk/reactos/base/applications/mscutils/eventvwr/eventvwr.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mscutils…
============================================================================== --- trunk/reactos/base/applications/mscutils/eventvwr/eventvwr.c [iso-8859-1] (original) +++ trunk/reactos/base/applications/mscutils/eventvwr/eventvwr.c [iso-8859-1] Wed May 11 21:33:27 2011 @@ -741,7 +741,7 @@ wcex.cbSize = sizeof(WNDCLASSEX); - wcex.style = CS_HREDRAW | CS_VREDRAW; + wcex.style = 0; wcex.lpfnWndProc = WndProc; wcex.cbClsExtra = 0; wcex.cbWndExtra = 0; @@ -779,7 +779,7 @@ hwndMainWindow = CreateWindowW(szWindowClass, szTitle, - WS_OVERLAPPEDWINDOW, + WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN, CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL,
13 years, 6 months
1
0
0
0
[gadamopoulos] 51677: [rapps] - Don't use CS_HREDRAW and CS_VREDRAW for the main window - Reduces flicker
by gadamopoulos@svn.reactos.org
Author: gadamopoulos Date: Wed May 11 20:54:33 2011 New Revision: 51677 URL:
http://svn.reactos.org/svn/reactos?rev=51677&view=rev
Log: [rapps] - Don't use CS_HREDRAW and CS_VREDRAW for the main window - Reduces flicker Modified: trunk/reactos/base/applications/rapps/winmain.c Modified: trunk/reactos/base/applications/rapps/winmain.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/rapps/wi…
============================================================================== --- trunk/reactos/base/applications/rapps/winmain.c [iso-8859-1] (original) +++ trunk/reactos/base/applications/rapps/winmain.c [iso-8859-1] Wed May 11 20:54:33 2011 @@ -794,7 +794,6 @@ WndClass.lpszClassName = szWindowClass; WndClass.lpfnWndProc = MainWindowProc; WndClass.hInstance = hInstance; - WndClass.style = CS_HREDRAW | CS_VREDRAW; WndClass.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_MAIN)); WndClass.hCursor = LoadCursor(NULL, IDC_ARROW); WndClass.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
13 years, 6 months
1
0
0
0
[jimtabor] 51676: [User32] - DispatchMessage does not allow pointers to be passed forward so need to check for non synchronous messages. Added the same check for the other functions in User32 leavi...
by jimtabor@svn.reactos.org
Author: jimtabor Date: Wed May 11 19:59:03 2011 New Revision: 51676 URL:
http://svn.reactos.org/svn/reactos?rev=51676&view=rev
Log: [User32] - DispatchMessage does not allow pointers to be passed forward so need to check for non synchronous messages. Added the same check for the other functions in User32 leaving the rest to be checked in Win32k. - Add the timer callback validation check. Modified: trunk/reactos/dll/win32/user32/windows/message.c Modified: trunk/reactos/dll/win32/user32/windows/message.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/windows/m…
============================================================================== --- trunk/reactos/dll/win32/user32/windows/message.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/user32/windows/message.c [iso-8859-1] Wed May 11 19:59:03 2011 @@ -12,6 +12,81 @@ #include <wine/debug.h> WINE_DEFAULT_DEBUG_CHANNEL(user32); + +/* From wine: */ +/* flag for messages that contain pointers */ +/* 32 messages per entry, messages 0..31 map to bits 0..31 */ + +#define SET(msg) (1 << ((msg) & 31)) + +static const unsigned int message_pointer_flags[] = +{ + /* 0x00 - 0x1f */ + SET(WM_CREATE) | SET(WM_SETTEXT) | SET(WM_GETTEXT) | + SET(WM_WININICHANGE) | SET(WM_DEVMODECHANGE), + /* 0x20 - 0x3f */ + SET(WM_GETMINMAXINFO) | SET(WM_DRAWITEM) | SET(WM_MEASUREITEM) | SET(WM_DELETEITEM) | + SET(WM_COMPAREITEM), + /* 0x40 - 0x5f */ + SET(WM_WINDOWPOSCHANGING) | SET(WM_WINDOWPOSCHANGED) | SET(WM_COPYDATA) | + SET(WM_COPYGLOBALDATA) | SET(WM_NOTIFY) | SET(WM_HELP), + /* 0x60 - 0x7f */ + SET(WM_STYLECHANGING) | SET(WM_STYLECHANGED), + /* 0x80 - 0x9f */ + SET(WM_NCCREATE) | SET(WM_NCCALCSIZE) | SET(WM_GETDLGCODE), + /* 0xa0 - 0xbf */ + SET(EM_GETSEL) | SET(EM_GETRECT) | SET(EM_SETRECT) | SET(EM_SETRECTNP), + /* 0xc0 - 0xdf */ + SET(EM_REPLACESEL) | SET(EM_GETLINE) | SET(EM_SETTABSTOPS), + /* 0xe0 - 0xff */ + SET(SBM_GETRANGE) | SET(SBM_SETSCROLLINFO) | SET(SBM_GETSCROLLINFO) | SET(SBM_GETSCROLLBARINFO), + /* 0x100 - 0x11f */ + 0, + /* 0x120 - 0x13f */ + 0, + /* 0x140 - 0x15f */ + SET(CB_GETEDITSEL) | SET(CB_ADDSTRING) | SET(CB_DIR) | SET(CB_GETLBTEXT) | + SET(CB_INSERTSTRING) | SET(CB_FINDSTRING) | SET(CB_SELECTSTRING) | + SET(CB_GETDROPPEDCONTROLRECT) | SET(CB_FINDSTRINGEXACT), + /* 0x160 - 0x17f */ + 0, + /* 0x180 - 0x19f */ + SET(LB_ADDSTRING) | SET(LB_INSERTSTRING) | SET(LB_GETTEXT) | SET(LB_SELECTSTRING) | + SET(LB_DIR) | SET(LB_FINDSTRING) | + SET(LB_GETSELITEMS) | SET(LB_SETTABSTOPS) | SET(LB_ADDFILE) | SET(LB_GETITEMRECT), + /* 0x1a0 - 0x1bf */ + SET(LB_FINDSTRINGEXACT), + /* 0x1c0 - 0x1df */ + 0, + /* 0x1e0 - 0x1ff */ + 0, + /* 0x200 - 0x21f */ + SET(WM_NEXTMENU) | SET(WM_SIZING) | SET(WM_MOVING) | SET(WM_DEVICECHANGE), + /* 0x220 - 0x23f */ + SET(WM_MDICREATE) | SET(WM_MDIGETACTIVE) | SET(WM_DROPOBJECT) | + SET(WM_QUERYDROPOBJECT) | SET(WM_DRAGLOOP) | SET(WM_DRAGSELECT) | SET(WM_DRAGMOVE), + /* 0x240 - 0x25f */ + 0, + /* 0x260 - 0x27f */ + 0, + /* 0x280 - 0x29f */ + 0, + /* 0x2a0 - 0x2bf */ + 0, + /* 0x2c0 - 0x2df */ + 0, + /* 0x2e0 - 0x2ff */ + 0, + /* 0x300 - 0x31f */ + SET(WM_ASKCBFORMATNAME) +}; + +/* check whether a given message type includes pointers */ +static inline int is_pointer_message( UINT message ) +{ + if (message >= 8*sizeof(message_pointer_flags)) return FALSE; + return (message_pointer_flags[message / 32] & SET(message)) != 0; +} /* DDE message exchange * @@ -1500,12 +1575,20 @@ else Wnd = NULL; + if (is_pointer_message(lpmsg->message)) + { + SetLastError( ERROR_MESSAGE_SYNC_ONLY ); + return 0; + } + if ((lpmsg->message == WM_TIMER || lpmsg->message == WM_SYSTIMER) && lpmsg->lParam != 0) { WNDPROC WndProc = (WNDPROC)lpmsg->lParam; if ( lpmsg->message == WM_SYSTIMER ) return NtUserDispatchMessage( (PMSG)lpmsg ); + + if (!NtUserValidateTimerCallback(lpmsg->hwnd, lpmsg->wParam, lpmsg->lParam)) return 0; _SEH2_TRY // wine does this. Hint: Prevents call to another thread.... { @@ -1572,12 +1655,20 @@ else Wnd = NULL; + if (is_pointer_message(lpmsg->message)) + { + SetLastError( ERROR_MESSAGE_SYNC_ONLY ); + return 0; + } + if ((lpmsg->message == WM_TIMER || lpmsg->message == WM_SYSTIMER) && lpmsg->lParam != 0) { WNDPROC WndProc = (WNDPROC)lpmsg->lParam; if ( lpmsg->message == WM_SYSTIMER ) return NtUserDispatchMessage( (PMSG) lpmsg ); + + if (!NtUserValidateTimerCallback(lpmsg->hwnd, lpmsg->wParam, lpmsg->lParam)) return 0; _SEH2_TRY { @@ -2032,6 +2123,12 @@ MSG AnsiMsg, UcMsg; CALL_BACK_INFO CallBackInfo; + if (is_pointer_message(Msg)) + { + SetLastError( ERROR_MESSAGE_SYNC_ONLY ); + return FALSE; + } + CallBackInfo.CallBack = lpCallBack; CallBackInfo.Context = dwData; @@ -2072,6 +2169,12 @@ ULONG_PTR dwData) { CALL_BACK_INFO CallBackInfo; + + if (is_pointer_message(Msg)) + { + SetLastError( ERROR_MESSAGE_SYNC_ONLY ); + return FALSE; + } CallBackInfo.CallBack = lpCallBack; CallBackInfo.Context = dwData; @@ -2237,6 +2340,12 @@ BOOL Ret; MSG AnsiMsg, UcMsg; + if (is_pointer_message(Msg)) + { + SetLastError( ERROR_MESSAGE_SYNC_ONLY ); + return FALSE; + } + AnsiMsg.hwnd = hWnd; AnsiMsg.message = Msg; AnsiMsg.wParam = wParam; @@ -2265,6 +2374,12 @@ { MSG UMMsg, KMMsg; LRESULT Result; + + if (is_pointer_message(Msg)) + { + SetLastError( ERROR_MESSAGE_SYNC_ONLY ); + return FALSE; + } UMMsg.hwnd = hWnd; UMMsg.message = Msg;
13 years, 6 months
1
0
0
0
[tkreuzer] 51675: [GDI FONT DRIVER] - Implement basics of 1bpp vs 4bpp bitmap handling - Fix special ansi characters - Fix direction of normalized base vectors (inverted y axis) - Fix ptqD member i...
by tkreuzer@svn.reactos.org
Author: tkreuzer Date: Wed May 11 19:47:49 2011 New Revision: 51675 URL:
http://svn.reactos.org/svn/reactos?rev=51675&view=rev
Log: [GDI FONT DRIVER] - Implement basics of 1bpp vs 4bpp bitmap handling - Fix special ansi characters - Fix direction of normalized base vectors (inverted y axis) - Fix ptqD member in GLYPHDATA structure Modified: branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/font.c branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/ftfd.h branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/glyph.c branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/todo.txt branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/tttables.c branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/tttables.h Modified: branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/font.c URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/GdiFontDriver/drivers…
============================================================================== --- branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/font.c [iso-8859-1] (original) +++ branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/font.c [iso-8859-1] Wed May 11 19:47:49 2011 @@ -217,7 +217,10 @@ } /* Convert the special characters from unicode to ansi */ - EngUnicodeToMultiByteN(&pifi->chFirstChar, 4, NULL, &pifi->wcFirstChar, 3); + EngUnicodeToMultiByteN(&pifi->chFirstChar, 4, NULL, &pifi->wcFirstChar, 8); + + /* This one seems to be hardcoded to 0xff */ + pifi->chLastChar = 0xff; /* Convert names to unicode */ EngMultiByteToUnicodeN(pifiex->awcFamilyName, @@ -249,6 +252,7 @@ pifi->achVendId, 4); + //__debugbreak(); return TRUE; } @@ -486,6 +490,8 @@ PFTFD_FILE pfile = NULL; TRACE("FtfdLoadFontFile()\n"); +//__debugbreak(); +//return 0; /* Check parameters */ if (cFiles != 1) Modified: branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/ftfd.h URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/GdiFontDriver/drivers…
============================================================================== --- branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/ftfd.h [iso-8859-1] (original) +++ branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/ftfd.h [iso-8859-1] Wed May 11 19:47:49 2011 @@ -146,6 +146,7 @@ ULONG xScale; HGLYPH hgSelected; ULONG cjSelected; + UCHAR jBpp; } FTFD_FONT, *PFTFD_FONT; Modified: branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/glyph.c URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/GdiFontDriver/drivers…
============================================================================== --- branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/glyph.c [iso-8859-1] (original) +++ branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/glyph.c [iso-8859-1] Wed May 11 19:47:49 2011 @@ -37,7 +37,7 @@ if (FLOATOBJ_bIsNull(&pptef->x)) { efLength = pptef->y; - FLOATOBJ_SetLong(&pptef->y, 1); + FLOATOBJ_SetLong(&pptef->y, -1); return efLength; } @@ -59,6 +59,9 @@ /* Now divide the vector by the length */ FLOATOBJ_Div(&pptef->x, &efLength); FLOATOBJ_Div(&pptef->y, &efLength); + + /* y axis is inverted! */ + FLOATOBJ_Neg(&pptef->y); /* Return the former length of the vector */ return efLength; @@ -110,6 +113,9 @@ } pfont->ftface = ftface; + + /* Set requested number of bits per pixel */ + pfont->jBpp = pfo->flFontType & FO_GRAY16 ? 4 : 1; /* Get the XFORMOBJ from the font */ pxo = FONTOBJ_pxoGetXform(pfo); @@ -316,13 +322,15 @@ pfddm->pteSide.y = FLOATOBJ_GetFloat(&pfont->ptefSide.y); /* cjGlyphMax is the full size of the GLYPHBITS structure */ - pfddm->cjGlyphMax = GLYPHBITS_SIZE(pfddm->cxMax, pfddm->cyMax, 4); + pfddm->cjGlyphMax = GLYPHBITS_SIZE(pfddm->cxMax, + pfddm->cyMax, + pfont->jBpp); /* Copy the quantized matrix from the font structure */ pfddm->fdxQuantized = pfont->fdxQuantized; pfddm->lNonLinearExtLeading = 0x00000000; - pfddm->lNonLinearIntLeading = 0x00000010; + pfddm->lNonLinearIntLeading = 0x00000080; // FIXME pfddm->lNonLinearMaxCharWidth = 0x80000000; pfddm->lNonLinearAvgCharWidth = 0x80000000; @@ -405,17 +413,28 @@ if (ftglyph->bitmap.width == 0) pgd->rclInk.right++; if (ftglyph->bitmap.rows == 0) pgd->rclInk.bottom++; - pgd->ptqD.x.LowPart = 0x000000fd; // ftglyph->advance.x + // FIXME: + pgd->ptqD.x.LowPart = pgd->fxD; pgd->ptqD.x.HighPart = 0; - pgd->ptqD.y.LowPart = 0x000000a0; // ftglyph->advance.y + pgd->ptqD.y.LowPart = 0; pgd->ptqD.y.HighPart = 0; //pgd->ptqD.x.QuadPart = 0; //pgd->ptqD.y.QuadPart = 0; //__debugbreak(); } +static VOID -FtfdCopyBitmap( +FtfdCopyBitmap1Bpp( + BYTE *pjDest, + FT_Bitmap *ftbitmap) +{ + __debugbreak(); +} + +static +VOID +FtfdCopyBitmap4Bpp( BYTE *pjDest, FT_Bitmap *ftbitmap) { @@ -469,7 +488,9 @@ pgb->sizlBitmap.cx = ftglyph->bitmap.width; pgb->sizlBitmap.cy = ftglyph->bitmap.rows; - cjBitmapSize = BITMAP_SIZE(pgb->sizlBitmap.cx, pgb->sizlBitmap.cy, 4); + cjBitmapSize = BITMAP_SIZE(pgb->sizlBitmap.cx, + pgb->sizlBitmap.cy, + pfont->jBpp); if (cjBitmapSize + FIELD_OFFSET(GLYPHBITS, aj) > cjSize) { WARN("Buffer too small, got %ld, need %ld\n", @@ -479,13 +500,14 @@ } /* Copy the bitmap */ - FtfdCopyBitmap(pgb->aj, &ftglyph->bitmap); - - //RtlCopyMemory(pgb->aj, ftglyph->bitmap.buffer, cjBitmapSize); + if (pfont->jBpp == 4) + FtfdCopyBitmap4Bpp(pgb->aj, &ftglyph->bitmap); + else + FtfdCopyBitmap1Bpp(pgb->aj, &ftglyph->bitmap); TRACE("QueryGlyphBits hg=%lx, (%ld,%ld) cjSize=%ld, need %ld\n", hg, pgb->sizlBitmap.cx, pgb->sizlBitmap.cy, cjSize, - GLYPHBITS_SIZE(pgb->sizlBitmap.cx, pgb->sizlBitmap.cy, 4)); + GLYPHBITS_SIZE(pgb->sizlBitmap.cx, pgb->sizlBitmap.cy, pfont->jBpp)); } @@ -504,8 +526,10 @@ PFTFD_FONT pfont) { FT_Error fterror; - - fterror = FT_Render_Glyph(pfont->ftface->glyph, FT_RENDER_MODE_NORMAL); + FT_Render_Mode mode; + + mode = pfont->jBpp == 1 ? FT_RENDER_MODE_MONO : FT_RENDER_MODE_NORMAL; + fterror = FT_Render_Glyph(pfont->ftface->glyph, mode); if (fterror) { WARN("Cound't render glyph\n"); @@ -553,7 +577,7 @@ /* Return the size for a 1bpp bitmap */ return GLYPHBITS_SIZE(pfont->ftface->glyph->bitmap.width, pfont->ftface->glyph->bitmap.rows, - 4); + pfont->jBpp); case QFD_GLYPHANDOUTLINE: TRACE("QFD_GLYPHANDOUTLINE\n"); Modified: branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/todo.txt URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/GdiFontDriver/drivers…
============================================================================== --- branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/todo.txt [iso-8859-1] (original) +++ branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/todo.txt [iso-8859-1] Wed May 11 19:47:49 2011 @@ -34,8 +34,11 @@ - FtfdInitIfiMetrics: 70% done - handle other font types than TTF/OTF - fix fwdLowestPPEm, fwdMacLineGap, ptlBaseline, ptlAspect, ptlCaret - - cKerningPairs, ulPanoseCulture + - cKerningPairs from atmfd is bigger, ulPanoseCulture - check fwdMacAscender, fwdMacDescender + - Check jWinPitchandFamily (from OS/2 table, Apolonia: 0,0->0x12) + - chLastChar: hardcoded 0xff ? + - fix fwdUnderscorePosition - FtfdInitGlyphSet: 100% done - FtfdInitKerningPairs: unimplemented, later @@ -50,9 +53,14 @@ - hande accelerator flags for bitmap / outline - FtfdQueryGlyphData: 70% done - handle vertical layout - - handle ptqD + - handle ptqD for rotation / skewing -- FtfdQueryGlyphBits: 40% +- FtfdQueryGlyphBits: 50% depends on FtfdCopyBitmap4Bpp and FtfdCopyBitmap1Bpp - handle 1bpp bitmaps - FtfdQueryGlyphOutline: unimplemented +- FtfdCopyBitmap4Bpp: 90 % + - add rounding + - Could need optimization +- FtfdCopyBitmap1Bpp: unimplemented + Modified: branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/tttables.c URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/GdiFontDriver/drivers…
============================================================================== --- branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/tttables.c [iso-8859-1] (original) +++ branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/tttables.c [iso-8859-1] Wed May 11 19:47:49 2011 @@ -152,7 +152,7 @@ switch (jClassId) { case 0: // Class ID = 0 No Classification - return FF_SWISS; + return FF_ROMAN;//FF_SWISS; case 1: // Class ID = 1 Oldstyle Serifs switch (jSubclassId) Modified: branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/tttables.h URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/GdiFontDriver/drivers…
============================================================================== --- branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/tttables.h [iso-8859-1] (original) +++ branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/tttables.h [iso-8859-1] Wed May 11 19:47:49 2011 @@ -47,7 +47,7 @@ typedef struct _TT_OS2_DATA { - USHORT version; // 0x0004 + USHORT version; // // 0x00 SHORT xAvgCharWidth; USHORT usWeightClass; USHORT usWidthClass; @@ -55,14 +55,14 @@ SHORT ySubscriptXSize; SHORT ySubscriptYSize; SHORT ySubscriptXOffset; - SHORT ySubscriptYOffset; + SHORT ySubscriptYOffset; // 0x10 SHORT ySuperscriptXSize; SHORT ySuperscriptYSize; SHORT ySuperscriptXOffset; SHORT ySuperscriptYOffset; SHORT yStrikeoutSize; SHORT yStrikeoutPosition; - union // 0x30 + union // 0x1e { struct {
13 years, 6 months
1
0
0
0
[gadamopoulos] 51674: [shell32] - Don't create the ShellView class with the CS_HREDRAW and CS_VREDRAW styles - Should reduce flicker in explorer
by gadamopoulos@svn.reactos.org
Author: gadamopoulos Date: Wed May 11 19:19:03 2011 New Revision: 51674 URL:
http://svn.reactos.org/svn/reactos?rev=51674&view=rev
Log: [shell32] - Don't create the ShellView class with the CS_HREDRAW and CS_VREDRAW styles - Should reduce flicker in explorer Modified: trunk/reactos/dll/win32/shell32/shlview.c Modified: trunk/reactos/dll/win32/shell32/shlview.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/shlview.…
============================================================================== --- trunk/reactos/dll/win32/shell32/shlview.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/shell32/shlview.c [iso-8859-1] Wed May 11 19:19:03 2011 @@ -2115,7 +2115,7 @@ if(!GetClassInfoW(shell32_hInstance, SV_CLASS_NAME, &wc)) { ZeroMemory(&wc, sizeof(wc)); - wc.style = CS_HREDRAW | CS_VREDRAW; + wc.style = 0; wc.lpfnWndProc = ShellView_WndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0;
13 years, 6 months
1
0
0
0
[janderwald] 51673: [USBSTOR] - Rewrite scsi method to act asynchronous
by janderwald@svn.reactos.org
Author: janderwald Date: Wed May 11 03:49:15 2011 New Revision: 51673 URL:
http://svn.reactos.org/svn/reactos?rev=51673&view=rev
Log: [USBSTOR] - Rewrite scsi method to act asynchronous Modified: branches/usb-bringup/drivers/usb/usbstor/disk.c branches/usb-bringup/drivers/usb/usbstor/scsi.c branches/usb-bringup/drivers/usb/usbstor/usbstor.c branches/usb-bringup/drivers/usb/usbstor/usbstor.h Modified: branches/usb-bringup/drivers/usb/usbstor/disk.c URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/usb/usbstor…
============================================================================== --- branches/usb-bringup/drivers/usb/usbstor/disk.c [iso-8859-1] (original) +++ branches/usb-bringup/drivers/usb/usbstor/disk.c [iso-8859-1] Wed May 11 03:49:15 2011 @@ -20,7 +20,6 @@ { PCDB pCDB; NTSTATUS Status; - ULONG TransferredLength; // // get SCSI command data block @@ -29,6 +28,7 @@ DPRINT1("USBSTOR_HandleExecuteSCSI Operation Code %x\n", pCDB->AsByte[0]); + if (pCDB->AsByte[0] == SCSIOP_READ_CAPACITY) { // @@ -36,43 +36,8 @@ // ASSERT(Request->DataBuffer); - if (Request->DataTransferLength == sizeof(READ_CAPACITY_DATA_EX)) - { - // - // retrieve capacity extended structure - // - Status = USBSTOR_SendCapacityCmd(DeviceObject, (PREAD_CAPACITY_DATA_EX)Request->DataBuffer, NULL); - } - else - { - // - // sanity check - // - ASSERT(Request->DataTransferLength == sizeof(READ_CAPACITY_DATA)); - - // - // retrieve capacity - // - Status = USBSTOR_SendCapacityCmd(DeviceObject, NULL, (PREAD_CAPACITY_DATA)Request->DataBuffer); - } - DPRINT1("USBSTOR_SendCapacityCmd %x\n", Status); - - if (NT_SUCCESS(Status)) - { - // - // store returned info length - // - Irp->IoStatus.Information = Request->DataTransferLength; - Request->SrbStatus = SRB_STATUS_SUCCESS; - } - else - { - // - // failed to retrieve capacity - // - Irp->IoStatus.Information = 0; - Request->SrbStatus = SRB_STATUS_ERROR; - } + DPRINT1("SCSIOP_READ_CAPACITY Length %\n", Request->DataTransferLength); + Status = USBSTOR_SendCapacityCmd(DeviceObject, Irp); } else if (pCDB->MODE_SENSE.OperationCode == SCSIOP_MODE_SENSE) { @@ -83,25 +48,7 @@ // // send mode sense command // - Status = USBSTOR_SendModeSenseCmd(DeviceObject, Request, &TransferredLength); - DPRINT1("USBSTOR_SendModeSenseCmd Status %x BytesReturned %lu\n", Status, TransferredLength); - - if (NT_SUCCESS(Status)) - { - // - // store returned info length - // - Irp->IoStatus.Information = TransferredLength; - Request->SrbStatus = SRB_STATUS_SUCCESS; - } - else - { - // - // failed to retrieve sense data - // - Irp->IoStatus.Information = 0; - Request->SrbStatus = SRB_STATUS_ERROR; - } + Status = USBSTOR_SendModeSenseCmd(DeviceObject, Irp); } else if (pCDB->MODE_SENSE.OperationCode == SCSIOP_READ) { @@ -111,25 +58,7 @@ // // send read command // - Status = USBSTOR_SendReadCmd(DeviceObject, Request, &TransferredLength); - DPRINT1("USBSTOR_SendReadCmd Status %x BytesReturned %lu\n", Status, TransferredLength); - - if (NT_SUCCESS(Status)) - { - // - // store returned info length - // - Irp->IoStatus.Information = TransferredLength; - Request->SrbStatus = SRB_STATUS_SUCCESS; - } - else - { - // - // failed to read - // - Irp->IoStatus.Information = 0; - Request->SrbStatus = SRB_STATUS_ERROR; - } + Status = USBSTOR_SendReadCmd(DeviceObject, Irp); } else if (pCDB->MODE_SENSE.OperationCode == SCSIOP_TEST_UNIT_READY) { @@ -138,22 +67,7 @@ // // send test unit command // - Status = USBSTOR_SendTestUnitCmd(DeviceObject, Request); - - if (NT_SUCCESS(Status)) - { - // - // store returned info length - // - Request->SrbStatus = SRB_STATUS_SUCCESS; - } - else - { - // - // test unit command failed - // - Request->SrbStatus = SRB_STATUS_ERROR; - } + Status = USBSTOR_SendTestUnitCmd(DeviceObject, Irp); } else { @@ -202,8 +116,7 @@ case SRB_FUNCTION_EXECUTE_SCSI: { DPRINT1("SRB_FUNCTION_EXECUTE_SCSI\n"); - Status = USBSTOR_HandleExecuteSCSI(DeviceObject, Irp, Request, PDODeviceExtension); - break; + return USBSTOR_HandleExecuteSCSI(DeviceObject, Irp, Request, PDODeviceExtension); } case SRB_FUNCTION_RELEASE_DEVICE: { @@ -280,6 +193,11 @@ } } + // + // complete request + // + Irp->IoStatus.Status = Status; + IoCompleteRequest(Irp, IO_NO_INCREMENT); return Status; } Modified: branches/usb-bringup/drivers/usb/usbstor/scsi.c URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/usb/usbstor…
============================================================================== --- branches/usb-bringup/drivers/usb/usbstor/scsi.c [iso-8859-1] (original) +++ branches/usb-bringup/drivers/usb/usbstor/scsi.c [iso-8859-1] Wed May 11 03:49:15 2011 @@ -46,19 +46,363 @@ return STATUS_SUCCESS; } -NTSTATUS -USBSTOR_SendCBW( +PIRP_CONTEXT +USBSTOR_AllocateIrpContext() +{ + PIRP_CONTEXT Context; + + // + // allocate irp context + // + Context = (PIRP_CONTEXT)AllocateItem(NonPagedPool, sizeof(IRP_CONTEXT)); + if (!Context) + { + // + // no memory + // + return NULL; + } + + // + // allocate cbw block + // + Context->cbw = (PCBW)AllocateItem(NonPagedPool, 512); + if (!Context->cbw) + { + // + // no memory + // + FreeItem(Context); + return NULL; + } + + // + // done + // + return Context; + +} + +// +// driver verifier +// +IO_COMPLETION_ROUTINE USBSTOR_CSWCompletionRoutine; + +NTSTATUS +NTAPI +USBSTOR_CSWCompletionRoutine( + PDEVICE_OBJECT DeviceObject, + PIRP Irp, + PVOID Ctx) +{ + PIRP_CONTEXT Context; + PIO_STACK_LOCATION IoStack; + PSCSI_REQUEST_BLOCK Request; + PCDB pCDB; + PREAD_CAPACITY_DATA_EX CapacityDataEx; + PREAD_CAPACITY_DATA CapacityData; + PUFI_CAPACITY_RESPONSE Response; + + DPRINT1("USBSTOR_CSWCompletionRoutine Irp %p Ctx %p\n", Irp, Ctx); + + // + // access context + // + Context = (PIRP_CONTEXT)Ctx; + + if (Context->TransferBufferMDL) + { + // + // free mdl + // + IoFreeMdl(Context->TransferBufferMDL); + } + + if (Context->Irp) + { + // + // get current stack location + // + IoStack = IoGetCurrentIrpStackLocation(Context->Irp); + + // + // get request block + // + Request = (PSCSI_REQUEST_BLOCK)IoStack->Parameters.Others.Argument1; + ASSERT(Request); + + // + // FIXME: check status + // + Request->SrbStatus = SRB_STATUS_SUCCESS; + + // + // get SCSI command data block + // + pCDB = (PCDB)Request->Cdb; + + // + // read capacity needs special work + // + if (pCDB->AsByte[0] == SCSIOP_READ_CAPACITY) + { + // + // get output buffer + // + Response = (PUFI_CAPACITY_RESPONSE)Context->TransferData; + + // + // store in pdo + // + Context->PDODeviceExtension->BlockLength = NTOHL(Response->BlockLength); + Context->PDODeviceExtension->LastLogicBlockAddress = NTOHL(Response->LastLogicalBlockAddress); + + if (Request->DataTransferLength == sizeof(READ_CAPACITY_DATA_EX)) + { + // + // get input buffer + // + CapacityDataEx = (PREAD_CAPACITY_DATA_EX)Request->DataBuffer; + + // + // set result + // + CapacityDataEx->BytesPerBlock = Response->BlockLength; + CapacityDataEx->LogicalBlockAddress.QuadPart = Response->LastLogicalBlockAddress; + Irp->IoStatus.Information = sizeof(READ_CAPACITY_DATA_EX); + } + else + { + // + // get input buffer + // + CapacityData = (PREAD_CAPACITY_DATA)Request->DataBuffer; + + // + // set result + // + CapacityData->BytesPerBlock = Response->BlockLength; + CapacityData->LogicalBlockAddress = Response->LastLogicalBlockAddress; + Irp->IoStatus.Information = sizeof(READ_CAPACITY_DATA); + } + + // + // free response + // + FreeItem(Context->TransferData); + } + } + + // + // free cbw + // + FreeItem(Context->cbw); + + + if (Context->Irp) + { + // + // FIXME: check status + // + Context->Irp->IoStatus.Status = Irp->IoStatus.Status; + Context->Irp->IoStatus.Information = Context->TransferDataLength; + + // + // complete request + // + IoCompleteRequest(Context->Irp, IO_NO_INCREMENT); + } + + if (Context->Event) + { + // + // signal event + // + KeSetEvent(Context->Event, 0, FALSE); + } + + + // + // free context + // + FreeItem(Context); + + // + // done + // + return STATUS_MORE_PROCESSING_REQUIRED; +} + +// +// driver verifier +// +IO_COMPLETION_ROUTINE USBSTOR_DataCompletionRoutine; + +NTSTATUS +NTAPI +USBSTOR_DataCompletionRoutine( + PDEVICE_OBJECT DeviceObject, + PIRP Irp, + PVOID Ctx) +{ + PIRP_CONTEXT Context; + PIO_STACK_LOCATION IoStack; + + DPRINT1("USBSTOR_DataCompletionRoutine Irp %p Ctx %p\n", Irp, Ctx); + + // + // access context + // + Context = (PIRP_CONTEXT)Ctx; + + // + // get next stack location + // + IoStack = IoGetNextIrpStackLocation(Irp); + + // + // now initialize the urb for sending the csw + // + Context->Urb.UrbBulkOrInterruptTransfer.Hdr.Length = sizeof(URB); + Context->Urb.UrbBulkOrInterruptTransfer.Hdr.Function = URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER; + Context->Urb.UrbBulkOrInterruptTransfer.PipeHandle = Context->FDODeviceExtension->InterfaceInformation->Pipes[Context->FDODeviceExtension->BulkInPipeIndex].PipeHandle; + Context->Urb.UrbBulkOrInterruptTransfer.TransferBuffer = Context->csw; + Context->Urb.UrbBulkOrInterruptTransfer.TransferBufferLength = 512; //FIXME + Context->Urb.UrbBulkOrInterruptTransfer.TransferBufferMDL = NULL; + Context->Urb.UrbBulkOrInterruptTransfer.TransferFlags = USBD_TRANSFER_DIRECTION_IN | USBD_SHORT_TRANSFER_OK; + + + // + // initialize stack location + // + IoStack->MajorFunction = IRP_MJ_INTERNAL_DEVICE_CONTROL; + IoStack->Parameters.DeviceIoControl.IoControlCode = IOCTL_INTERNAL_USB_SUBMIT_URB; + IoStack->Parameters.Others.Argument1 = (PVOID)&Context->Urb; + IoStack->Parameters.DeviceIoControl.InputBufferLength = Context->Urb.UrbHeader.Length; + Irp->IoStatus.Status = STATUS_SUCCESS; + + + // + // setup completion routine + // + IoSetCompletionRoutine(Irp, USBSTOR_CSWCompletionRoutine, Context, TRUE, TRUE, TRUE); + + // + // call driver + // + IoCallDriver(Context->FDODeviceExtension->LowerDeviceObject, Irp); + return STATUS_MORE_PROCESSING_REQUIRED; +} + +// +// driver verifier +// +IO_COMPLETION_ROUTINE USBSTOR_CBWCompletionRoutine; + +NTSTATUS +NTAPI +USBSTOR_CBWCompletionRoutine( + PDEVICE_OBJECT DeviceObject, + PIRP Irp, + PVOID Ctx) +{ + PIRP_CONTEXT Context; + PIO_STACK_LOCATION IoStack; + + DPRINT1("USBSTOR_CBWCompletionRoutine Irp %p Ctx %p\n", Irp, Ctx); + + // + // access context + // + Context = (PIRP_CONTEXT)Ctx; + + + // + // get next stack location + // + IoStack = IoGetNextIrpStackLocation(Irp); + + // + // is there data to be submitted + // + if (Context->TransferDataLength) + { + // + // now initialize the urb for sending data + // + Context->Urb.UrbBulkOrInterruptTransfer.Hdr.Length = sizeof(URB); + Context->Urb.UrbBulkOrInterruptTransfer.Hdr.Function = URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER; + Context->Urb.UrbBulkOrInterruptTransfer.PipeHandle = Context->FDODeviceExtension->InterfaceInformation->Pipes[Context->FDODeviceExtension->BulkInPipeIndex].PipeHandle; + Context->Urb.UrbBulkOrInterruptTransfer.TransferBufferMDL = Context->TransferBufferMDL; + Context->Urb.UrbBulkOrInterruptTransfer.TransferBufferLength = Context->TransferDataLength; + Context->Urb.UrbBulkOrInterruptTransfer.TransferFlags = USBD_TRANSFER_DIRECTION_IN | USBD_SHORT_TRANSFER_OK; + + // + // setup completion routine + // + IoSetCompletionRoutine(Irp, USBSTOR_DataCompletionRoutine, Context, TRUE, TRUE, TRUE); + } + else + { + // + // now initialize the urb for sending the csw + // + Context->Urb.UrbBulkOrInterruptTransfer.Hdr.Length = sizeof(URB); + Context->Urb.UrbBulkOrInterruptTransfer.Hdr.Function = URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER; + Context->Urb.UrbBulkOrInterruptTransfer.PipeHandle = Context->FDODeviceExtension->InterfaceInformation->Pipes[Context->FDODeviceExtension->BulkInPipeIndex].PipeHandle; + Context->Urb.UrbBulkOrInterruptTransfer.TransferBuffer = Context->csw; + Context->Urb.UrbBulkOrInterruptTransfer.TransferBufferLength = 512; //FIXME + Context->Urb.UrbBulkOrInterruptTransfer.TransferFlags = USBD_TRANSFER_DIRECTION_IN | USBD_SHORT_TRANSFER_OK; + + // + // setup completion routine + // + IoSetCompletionRoutine(Irp, USBSTOR_CSWCompletionRoutine, Context, TRUE, TRUE, TRUE); + } + + // + // initialize stack location + // + IoStack->MajorFunction = IRP_MJ_INTERNAL_DEVICE_CONTROL; + IoStack->Parameters.DeviceIoControl.IoControlCode = IOCTL_INTERNAL_USB_SUBMIT_URB; + IoStack->Parameters.Others.Argument1 = (PVOID)&Context->Urb; + IoStack->Parameters.DeviceIoControl.InputBufferLength = Context->Urb.UrbHeader.Length; + Irp->IoStatus.Status = STATUS_SUCCESS; + + // + // call driver + // + IoCallDriver(Context->FDODeviceExtension->LowerDeviceObject, Irp); + return STATUS_MORE_PROCESSING_REQUIRED; +} + +NTSTATUS +USBSTOR_SendRequest( IN PDEVICE_OBJECT DeviceObject, - IN UCHAR CommandBlockLength, - IN PUCHAR CommandBlock, - IN ULONG DataTransferLength, - OUT PCBW *OutControl) -{ - PCBW Control; - NTSTATUS Status; - PURB Urb; + IN PIRP OriginalRequest, + IN OPTIONAL PKEVENT Event, + IN ULONG CommandLength, + IN PUCHAR Command, + IN ULONG TransferDataLength, + IN PUCHAR TransferData) +{ + PIRP_CONTEXT Context; PPDO_DEVICE_EXTENSION PDODeviceExtension; PFDO_DEVICE_EXTENSION FDODeviceExtension; + PIRP Irp; + PIO_STACK_LOCATION IoStack; + + // + // first allocate irp context + // + Context = USBSTOR_AllocateIrpContext(); + if (!Context) + { + // + // no memory + // + return STATUS_INSUFFICIENT_RESOURCES; + } // // get PDO device extension @@ -71,222 +415,106 @@ FDODeviceExtension = (PFDO_DEVICE_EXTENSION)PDODeviceExtension->LowerDeviceObject->DeviceExtension; // - // first allocate CBW - // - Control = (PCBW)AllocateItem(NonPagedPool, 512); - if (!Control) - { - // - // no memory - // + // now build the cbw + // + USBSTOR_BuildCBW(0xDEADDEAD, // FIXME tag + TransferDataLength, + PDODeviceExtension->LUN, + CommandLength, + Command, + Context->cbw); + + // + // now initialize the urb + // + Context->Urb.UrbBulkOrInterruptTransfer.Hdr.Length = sizeof(URB); + Context->Urb.UrbBulkOrInterruptTransfer.Hdr.Function = URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER; + Context->Urb.UrbBulkOrInterruptTransfer.PipeHandle = FDODeviceExtension->InterfaceInformation->Pipes[FDODeviceExtension->BulkOutPipeIndex].PipeHandle; + Context->Urb.UrbBulkOrInterruptTransfer.TransferBuffer = (PVOID)Context->cbw; + Context->Urb.UrbBulkOrInterruptTransfer.TransferBufferLength = sizeof(CBW); + Context->Urb.UrbBulkOrInterruptTransfer.TransferFlags = USBD_TRANSFER_DIRECTION_OUT | USBD_SHORT_TRANSFER_OK; + + // + // initialize rest of context + // + Context->Irp = OriginalRequest; + Context->TransferData = TransferData; + Context->TransferDataLength = TransferDataLength; + Context->FDODeviceExtension = FDODeviceExtension; + Context->PDODeviceExtension = PDODeviceExtension; + Context->Event = Event; + + // + // is there transfer data + // + if (Context->TransferDataLength) + { + // + // allocate mdl for buffer, buffer must be allocated from NonPagedPool + // + Context->TransferBufferMDL = IoAllocateMdl(Context->TransferData, Context->TransferDataLength, FALSE, FALSE, NULL); + if (!Context->TransferBufferMDL) + { + // + // failed to allocate MDL + // + return STATUS_INSUFFICIENT_RESOURCES; + } + + // + // build mdl for nonpaged pool + // + MmBuildMdlForNonPagedPool(Context->TransferBufferMDL); + } + + // + // now allocate the request + // + Irp = IoAllocateIrp(DeviceObject->StackSize, FALSE); + if (!Irp) + { + FreeItem(Context->cbw); + FreeItem(Context); return STATUS_INSUFFICIENT_RESOURCES; } - // - // first allocate CBW - // - Status = USBSTOR_BuildCBW(0xDEADDEAD, DataTransferLength, PDODeviceExtension->LUN, CommandBlockLength, CommandBlock, Control); - if (!NT_SUCCESS(Status)) - { - // - // failed to build CBW - // - return Status; - } - - // - // now build the urb - // - Urb = (PURB)AllocateItem(NonPagedPool, sizeof(URB)); - if (!Urb) - { - // - // failed to allocate urb - // - FreeItem(Control); - return STATUS_INSUFFICIENT_RESOURCES; - } - - // - // now initialize the urb - // - Urb->UrbBulkOrInterruptTransfer.Hdr.Length = sizeof(URB); - Urb->UrbBulkOrInterruptTransfer.Hdr.Function = URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER; - Urb->UrbBulkOrInterruptTransfer.PipeHandle = FDODeviceExtension->InterfaceInformation->Pipes[FDODeviceExtension->BulkOutPipeIndex].PipeHandle; - Urb->UrbBulkOrInterruptTransfer.TransferBuffer = (PVOID)Control; - Urb->UrbBulkOrInterruptTransfer.TransferBufferLength = sizeof(CBW); - Urb->UrbBulkOrInterruptTransfer.TransferFlags = USBD_TRANSFER_DIRECTION_OUT | USBD_SHORT_TRANSFER_OK; - - // - // now send urb - // - Status = USBSTOR_SyncUrbRequest(FDODeviceExtension->LowerDeviceObject, Urb); - - // - // free urb - // - FreeItem(Urb); - - // - // store cbw - // - *OutControl = Control; - - // - // return operation status - // - return Status; -} - -NTSTATUS -USBSTOR_SendData( - IN PDEVICE_OBJECT DeviceObject, - IN ULONG DataTransferLength, - IN PVOID DataTransfer) -{ - PMDL TransferBufferMDL; - PURB Urb; - NTSTATUS Status; - PPDO_DEVICE_EXTENSION PDODeviceExtension; - PFDO_DEVICE_EXTENSION FDODeviceExtension; - - // - // get PDO device extension - // - PDODeviceExtension = (PPDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension; - - // - // get FDO device extension - // - FDODeviceExtension = (PFDO_DEVICE_EXTENSION)PDODeviceExtension->LowerDeviceObject->DeviceExtension; - - // - // allocate mdl for buffer, buffer must be allocated from NonPagedPool - // - TransferBufferMDL = IoAllocateMdl(DataTransfer, DataTransferLength, FALSE, FALSE, NULL); - if (!TransferBufferMDL) - { - // - // failed to allocate MDL - // - return STATUS_INSUFFICIENT_RESOURCES; - } - - // - // build mdl for nonpaged pool - // - MmBuildMdlForNonPagedPool(TransferBufferMDL); - - // - // now build the urb - // - Urb = (PURB)AllocateItem(NonPagedPool, sizeof(URB)); - if (!Urb) - { - // - // failed to allocate urb - // - IoFreeMdl(TransferBufferMDL); - return STATUS_INSUFFICIENT_RESOURCES; - } - - // - // now initialize the urb - // - Urb->UrbBulkOrInterruptTransfer.Hdr.Length = sizeof(URB); - Urb->UrbBulkOrInterruptTransfer.Hdr.Function = URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER; - Urb->UrbBulkOrInterruptTransfer.PipeHandle = FDODeviceExtension->InterfaceInformation->Pipes[FDODeviceExtension->BulkInPipeIndex].PipeHandle; - Urb->UrbBulkOrInterruptTransfer.TransferBufferMDL = TransferBufferMDL; - Urb->UrbBulkOrInterruptTransfer.TransferBufferLength = DataTransferLength; - Urb->UrbBulkOrInterruptTransfer.TransferFlags = USBD_TRANSFER_DIRECTION_IN | USBD_SHORT_TRANSFER_OK; - - // - // now send urb - // - Status = USBSTOR_SyncUrbRequest(FDODeviceExtension->LowerDeviceObject, Urb); - - // - // free urb - // - FreeItem(Urb); - - // - // free mdl - // - IoFreeMdl(TransferBufferMDL); + + // + // get next stack location + // + IoStack = IoGetNextIrpStackLocation(Irp); + + // + // initialize stack location + // + IoStack->MajorFunction = IRP_MJ_INTERNAL_DEVICE_CONTROL; + IoStack->Parameters.DeviceIoControl.IoControlCode = IOCTL_INTERNAL_USB_SUBMIT_URB; + IoStack->Parameters.Others.Argument1 = (PVOID)&Context->Urb; + IoStack->Parameters.DeviceIoControl.InputBufferLength = Context->Urb.UrbHeader.Length; + Irp->IoStatus.Status = STATUS_SUCCESS; + + // + // setup completion routine + // + IoSetCompletionRoutine(Irp, USBSTOR_CBWCompletionRoutine, Context, TRUE, TRUE, TRUE); + + if (OriginalRequest) + { + // + // mark orignal irp as pending + // + IoMarkIrpPending(OriginalRequest); + } + + // + // call driver + // + IoCallDriver(FDODeviceExtension->LowerDeviceObject, Irp); // // done // - return Status; -} - -NTSTATUS -USBSTOR_SendCSW( - IN PDEVICE_OBJECT DeviceObject, - IN PVOID Data, - IN ULONG DataLength, - OUT PCSW OutCSW) -{ - NTSTATUS Status; - PPDO_DEVICE_EXTENSION PDODeviceExtension; - PFDO_DEVICE_EXTENSION FDODeviceExtension; - PURB Urb; - - // - // get PDO device extension - // - PDODeviceExtension = (PPDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension; - - // - // get FDO device extension - // - FDODeviceExtension = (PFDO_DEVICE_EXTENSION)PDODeviceExtension->LowerDeviceObject->DeviceExtension; - - // - // now build the urb - // - Urb = (PURB)AllocateItem(NonPagedPool, sizeof(URB)); - if (!Urb) - { - // - // failed to allocate urb - // - return STATUS_INSUFFICIENT_RESOURCES; - } - - // - // now initialize the urb - // - Urb->UrbBulkOrInterruptTransfer.Hdr.Length = sizeof(URB); - Urb->UrbBulkOrInterruptTransfer.Hdr.Function = URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER; - Urb->UrbBulkOrInterruptTransfer.PipeHandle = FDODeviceExtension->InterfaceInformation->Pipes[FDODeviceExtension->BulkInPipeIndex].PipeHandle; - Urb->UrbBulkOrInterruptTransfer.TransferBuffer = Data; - Urb->UrbBulkOrInterruptTransfer.TransferBufferLength = DataLength; - Urb->UrbBulkOrInterruptTransfer.TransferFlags = USBD_TRANSFER_DIRECTION_IN | USBD_SHORT_TRANSFER_OK; - - // - // now send urb - // - Status = USBSTOR_SyncUrbRequest(FDODeviceExtension->LowerDeviceObject, Urb); - - if (NT_SUCCESS(Status)) - { - // - // copy csw status - // - RtlCopyMemory(OutCSW, Data, sizeof(CSW)); - } - - // - // free urb - // - FreeItem(Urb); - - // - // done - // - return Status; + return STATUS_PENDING; } NTSTATUS @@ -294,28 +522,28 @@ IN PDEVICE_OBJECT DeviceObject) { UFI_INQUIRY_CMD Cmd; - CSW CSW; NTSTATUS Status; + KEVENT Event; + PPDO_DEVICE_EXTENSION PDODeviceExtension; PUFI_INQUIRY_RESPONSE Response; - PPDO_DEVICE_EXTENSION PDODeviceExtension; - PCBW OutControl; + + + // + // allocate inquiry response + // + Response = AllocateItem(NonPagedPool, PAGE_SIZE); + if (!Response) + { + // + // no memory + // + return STATUS_INSUFFICIENT_RESOURCES; + } // // get PDO device extension // PDODeviceExtension = (PPDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension; - - // - // allocate inquiry response - // - Response = (PUFI_INQUIRY_RESPONSE)AllocateItem(NonPagedPool, sizeof(UFI_INQUIRY_RESPONSE)); - if (!Response) - { - // - // no memory - // - return STATUS_INSUFFICIENT_RESOURCES; - } // // initialize inquiry cmd @@ -326,34 +554,19 @@ Cmd.AllocationLength = sizeof(UFI_INQUIRY_RESPONSE); // - // now send inquiry cmd - // - Status = USBSTOR_SendCBW(DeviceObject, UFI_INQUIRY_CMD_LEN, (PUCHAR)&Cmd, sizeof(UFI_INQUIRY_RESPONSE), &OutControl); - if (!NT_SUCCESS(Status)) - { - // - // failed to send CBW - // - DPRINT1("USBSTOR_SendInquiryCmd> USBSTOR_SendCBW failed with %x\n", Status); - FreeItem(Response); - ASSERT(FALSE); - return Status; - } - - // - // now send inquiry response - // - Status = USBSTOR_SendData(DeviceObject, sizeof(UFI_INQUIRY_RESPONSE), Response); - if (!NT_SUCCESS(Status)) - { - // - // failed to send CBW - // - DPRINT1("USBSTOR_SendInquiryCmd> USBSTOR_SendData failed with %x\n", Status); - FreeItem(Response); - ASSERT(FALSE); - return Status; - } + // initialize event + // + KeInitializeEvent(&Event, NotificationEvent, FALSE); + + // + // now send the request + // + Status = USBSTOR_SendRequest(DeviceObject, NULL, &Event, UFI_INQUIRY_CMD_LEN, (PUCHAR)&Cmd, sizeof(UFI_INQUIRY_RESPONSE), (PUCHAR)Response); + + // + // wait for the action to complete + // + KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL); DPRINT1("Response %p\n", Response); DPRINT1("DeviceType %x\n", Response->DeviceType); @@ -371,6 +584,164 @@ DPRINT1("Revision %c%c%c%c\n", Response->Revision[0], Response->Revision[1], Response->Revision[2], Response->Revision[3]); // + // store inquiry data + // + PDODeviceExtension->InquiryData = (PVOID)Response; + + // + // done + // + return Status; +} + +NTSTATUS +USBSTOR_SendCapacityCmd( + IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp) +{ + UFI_CAPACITY_CMD Cmd; + PUFI_CAPACITY_RESPONSE Response; + PPDO_DEVICE_EXTENSION PDODeviceExtension; + + // + // get PDO device extension + // + PDODeviceExtension = (PPDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension; + + // + // allocate capacity response + // + Response = (PUFI_CAPACITY_RESPONSE)AllocateItem(NonPagedPool, sizeof(UFI_CAPACITY_RESPONSE)); + if (!Response) + { + // + // no memory + // + return STATUS_INSUFFICIENT_RESOURCES; + } + + // + // initialize capacity cmd + // + RtlZeroMemory(&Cmd, sizeof(UFI_INQUIRY_CMD)); + Cmd.Code = SCSIOP_READ_CAPACITY; + Cmd.LUN = (PDODeviceExtension->LUN & MAX_LUN); + + // + // send request, response will be freed in completion routine + // + return USBSTOR_SendRequest(DeviceObject, Irp, NULL, UFI_INQUIRY_CMD_LEN, (PUCHAR)&Cmd, sizeof(UFI_CAPACITY_RESPONSE), (PUCHAR)Response); +} + +NTSTATUS +USBSTOR_SendModeSenseCmd( + IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp) +{ + UFI_SENSE_CMD Cmd; + NTSTATUS Status; + PVOID Response; + PPDO_DEVICE_EXTENSION PDODeviceExtension; + PCBW OutControl; + PCDB pCDB; + PUFI_MODE_PARAMETER_HEADER Header; + + ASSERT(FALSE); + return STATUS_NOT_IMPLEMENTED; + +#if 0 + // + // get SCSI command data block + // + pCDB = (PCDB)Request->Cdb; + + // + // get PDO device extension + // + PDODeviceExtension = (PPDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension; + + // + // allocate sense response from non paged pool + // + Response = (PUFI_CAPACITY_RESPONSE)AllocateItem(NonPagedPool, Request->DataTransferLength); + if (!Response) + { + // + // no memory + // + return STATUS_INSUFFICIENT_RESOURCES; + } + + // + // sanity check + // + + + // Supported pages + // MODE_PAGE_ERROR_RECOVERY + // MODE_PAGE_FLEXIBILE + // MODE_PAGE_LUN_MAPPING + // MODE_PAGE_FAULT_REPORTING + // MODE_SENSE_RETURN_ALL + + // + // initialize mode sense cmd + // + RtlZeroMemory(&Cmd, sizeof(UFI_INQUIRY_CMD)); + Cmd.Code = SCSIOP_MODE_SENSE; + Cmd.LUN = (PDODeviceExtension->LUN & MAX_LUN); + Cmd.PageCode = pCDB->MODE_SENSE.PageCode; + Cmd.PC = pCDB->MODE_SENSE.Pc; + Cmd.AllocationLength = HTONS(pCDB->MODE_SENSE.AllocationLength); + + DPRINT1("PageCode %x\n", pCDB->MODE_SENSE.PageCode); + DPRINT1("PC %x\n", pCDB->MODE_SENSE.Pc); + + // + // now send mode sense cmd + // + Status = USBSTOR_SendCBW(DeviceObject, UFI_SENSE_CMD_LEN, (PUCHAR)&Cmd, Request->DataTransferLength, &OutControl); + if (!NT_SUCCESS(Status)) + { + // + // failed to send CBW + // + DPRINT1("USBSTOR_SendCapacityCmd> USBSTOR_SendCBW failed with %x\n", Status); + FreeItem(Response); + ASSERT(FALSE); + return Status; + } + + // + // now send data block response + // + Status = USBSTOR_SendData(DeviceObject, Request->DataTransferLength, Response); + if (!NT_SUCCESS(Status)) + { + // + // failed to send CBW + // + DPRINT1("USBSTOR_SendCapacityCmd> USBSTOR_SendData failed with %x\n", Status); + FreeItem(Response); + ASSERT(FALSE); + return Status; + } + + Header = (PUFI_MODE_PARAMETER_HEADER)Response; + + // + // TODO: build layout + // + // first struct is the header + // MODE_PARAMETER_HEADER / _MODE_PARAMETER_HEADER10 + // + // followed by + // MODE_PARAMETER_BLOCK + // + // + UNIMPLEMENTED + + // // send csw // Status = USBSTOR_SendCSW(DeviceObject, OutControl, 512, &CSW); @@ -383,270 +754,6 @@ DPRINT1("Status %x\n", CSW.Status); // - // free item - // - FreeItem(OutControl); - - // - // store inquiry data - // - PDODeviceExtension->InquiryData = (PVOID)Response; - - // - // FIXME: handle error - // - ASSERT(CSW.Status == 0); - - - // - // done - // - return Status; -} - -NTSTATUS -USBSTOR_SendCapacityCmd( - IN PDEVICE_OBJECT DeviceObject, - OUT PREAD_CAPACITY_DATA_EX CapacityDataEx, - OUT PREAD_CAPACITY_DATA CapacityData) -{ - UFI_CAPACITY_CMD Cmd; - CSW CSW; - NTSTATUS Status; - PUFI_CAPACITY_RESPONSE Response; - PPDO_DEVICE_EXTENSION PDODeviceExtension; - PCBW OutControl; - - // - // get PDO device extension - // - PDODeviceExtension = (PPDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension; - - // - // allocate capacity response - // - Response = (PUFI_CAPACITY_RESPONSE)AllocateItem(NonPagedPool, sizeof(UFI_CAPACITY_RESPONSE)); - if (!Response) - { - // - // no memory - // - return STATUS_INSUFFICIENT_RESOURCES; - } - - // - // initialize capacity cmd - // - RtlZeroMemory(&Cmd, sizeof(UFI_INQUIRY_CMD)); - Cmd.Code = SCSIOP_READ_CAPACITY; - Cmd.LUN = (PDODeviceExtension->LUN & MAX_LUN); - - // - // now send capacity cmd - // - Status = USBSTOR_SendCBW(DeviceObject, UFI_CAPACITY_CMD_LEN, (PUCHAR)&Cmd, sizeof(UFI_CAPACITY_RESPONSE), &OutControl); - if (!NT_SUCCESS(Status)) - { - // - // failed to send CBW - // - DPRINT1("USBSTOR_SendCapacityCmd> USBSTOR_SendCBW failed with %x\n", Status); - FreeItem(Response); - ASSERT(FALSE); - return Status; - } - - // - // now send inquiry response - // - Status = USBSTOR_SendData(DeviceObject, sizeof(UFI_CAPACITY_RESPONSE), Response); - if (!NT_SUCCESS(Status)) - { - // - // failed to send CBW - // - DPRINT1("USBSTOR_SendCapacityCmd> USBSTOR_SendData failed with %x\n", Status); - FreeItem(Response); - ASSERT(FALSE); - return Status; - } - - DPRINT1("LastLogicalBlockAddress %lu\n", NTOHL(Response->LastLogicalBlockAddress)); - DPRINT1("BlockLength %lu\n", NTOHL(Response->BlockLength)); - DPRINT1("Medium Length %lu\n", NTOHL(Response->BlockLength) * NTOHL(Response->LastLogicalBlockAddress)); - - // - // store response - // - if (CapacityDataEx) - { - CapacityDataEx->LogicalBlockAddress.QuadPart = Response->LastLogicalBlockAddress; - CapacityDataEx->BytesPerBlock = Response->BlockLength; - } - else - { - CapacityData->LogicalBlockAddress = Response->LastLogicalBlockAddress; - CapacityData->BytesPerBlock = Response->BlockLength; - } - - // - // store result in device extension - // - PDODeviceExtension->LastLogicBlockAddress = NTOHL(Response->LastLogicalBlockAddress); - PDODeviceExtension->BlockLength = NTOHL(Response->BlockLength); - - // - // send csw - // - Status = USBSTOR_SendCSW(DeviceObject, OutControl, 512, &CSW); - - DPRINT1("------------------------\n"); - DPRINT1("CSW %p\n", &CSW); - DPRINT1("Signature %x\n", CSW.Signature); - DPRINT1("Tag %x\n", CSW.Tag); - DPRINT1("DataResidue %x\n", CSW.DataResidue); - DPRINT1("Status %x\n", CSW.Status); - - // - // FIXME: handle error - // - ASSERT(CSW.Status == 0); - - // - // free item - // - FreeItem(OutControl); - - // - // free response - // - FreeItem(Response); - - // - // done - // - return Status; -} - -NTSTATUS -USBSTOR_SendModeSenseCmd( - IN PDEVICE_OBJECT DeviceObject, - IN OUT PSCSI_REQUEST_BLOCK Request, - OUT PULONG TransferBufferLength) -{ - UFI_SENSE_CMD Cmd; - CSW CSW; - NTSTATUS Status; - PVOID Response; - PPDO_DEVICE_EXTENSION PDODeviceExtension; - PCBW OutControl; - PCDB pCDB; - PUFI_MODE_PARAMETER_HEADER Header; - - // - // get SCSI command data block - // - pCDB = (PCDB)Request->Cdb; - - // - // get PDO device extension - // - PDODeviceExtension = (PPDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension; - - // - // allocate sense response from non paged pool - // - Response = (PUFI_CAPACITY_RESPONSE)AllocateItem(NonPagedPool, Request->DataTransferLength); - if (!Response) - { - // - // no memory - // - return STATUS_INSUFFICIENT_RESOURCES; - } - - // - // sanity check - // - - - // Supported pages - // MODE_PAGE_ERROR_RECOVERY - // MODE_PAGE_FLEXIBILE - // MODE_PAGE_LUN_MAPPING - // MODE_PAGE_FAULT_REPORTING - // MODE_SENSE_RETURN_ALL - - // - // initialize mode sense cmd - // - RtlZeroMemory(&Cmd, sizeof(UFI_INQUIRY_CMD)); - Cmd.Code = SCSIOP_MODE_SENSE; - Cmd.LUN = (PDODeviceExtension->LUN & MAX_LUN); - Cmd.PageCode = pCDB->MODE_SENSE.PageCode; - Cmd.PC = pCDB->MODE_SENSE.Pc; - Cmd.AllocationLength = HTONS(pCDB->MODE_SENSE.AllocationLength); - - DPRINT1("PageCode %x\n", pCDB->MODE_SENSE.PageCode); - DPRINT1("PC %x\n", pCDB->MODE_SENSE.Pc); - - // - // now send mode sense cmd - // - Status = USBSTOR_SendCBW(DeviceObject, UFI_SENSE_CMD_LEN, (PUCHAR)&Cmd, Request->DataTransferLength, &OutControl); - if (!NT_SUCCESS(Status)) - { - // - // failed to send CBW - // - DPRINT1("USBSTOR_SendCapacityCmd> USBSTOR_SendCBW failed with %x\n", Status); - FreeItem(Response); - ASSERT(FALSE); - return Status; - } - - // - // now send data block response - // - Status = USBSTOR_SendData(DeviceObject, Request->DataTransferLength, Response); - if (!NT_SUCCESS(Status)) - { - // - // failed to send CBW - // - DPRINT1("USBSTOR_SendCapacityCmd> USBSTOR_SendData failed with %x\n", Status); - FreeItem(Response); - ASSERT(FALSE); - return Status; - } - - Header = (PUFI_MODE_PARAMETER_HEADER)Response; - - // - // TODO: build layout - // - // first struct is the header - // MODE_PARAMETER_HEADER / _MODE_PARAMETER_HEADER10 - // - // followed by - // MODE_PARAMETER_BLOCK - // - // - UNIMPLEMENTED - - // - // send csw - // - Status = USBSTOR_SendCSW(DeviceObject, OutControl, 512, &CSW); - - DPRINT1("------------------------\n"); - DPRINT1("CSW %p\n", &CSW); - DPRINT1("Signature %x\n", CSW.Signature); - DPRINT1("Tag %x\n", CSW.Tag); - DPRINT1("DataResidue %x\n", CSW.DataResidue); - DPRINT1("Status %x\n", CSW.Status); - - // // FIXME: handle error // ASSERT(CSW.Status == 0); @@ -676,22 +783,31 @@ // done // return Status; +#endif } NTSTATUS USBSTOR_SendReadCmd( IN PDEVICE_OBJECT DeviceObject, - IN OUT PSCSI_REQUEST_BLOCK Request, - OUT PULONG TransferBufferLength) + IN PIRP Irp) { UFI_READ_CMD Cmd; - CSW CSW; NTSTATUS Status; - PVOID Response; PPDO_DEVICE_EXTENSION PDODeviceExtension; - PCBW OutControl; PCDB pCDB; ULONG BlockCount; + PIO_STACK_LOCATION IoStack; + PSCSI_REQUEST_BLOCK Request; + + // + // get current stack location + // + IoStack = IoGetCurrentIrpStackLocation(Irp); + + // + // get request block + // + Request = (PSCSI_REQUEST_BLOCK)IoStack->Parameters.Others.Argument1; // // get SCSI command data block @@ -704,18 +820,6 @@ PDODeviceExtension = (PPDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension; // - // allocate read buffer response from non paged pool - // - Response = (PUFI_CAPACITY_RESPONSE)AllocateItem(NonPagedPool, Request->DataTransferLength); - if (!Response) - { - // - // no memory - // - return STATUS_INSUFFICIENT_RESOURCES; - } - - // // FIXME: support more logical blocks // ASSERT(Request->DataTransferLength == PDODeviceExtension->BlockLength); @@ -726,7 +830,7 @@ BlockCount = Request->DataTransferLength / PDODeviceExtension->BlockLength; // - // initialize read sense cmd + // initialize read cmd // RtlZeroMemory(&Cmd, sizeof(UFI_READ_CMD)); Cmd.Code = SCSIOP_READ; @@ -738,95 +842,40 @@ DPRINT1("BlockAddress %lu BlockCount %lu BlockLength %lu\n", NTOHL(Cmd.LogicalBlockAddress), BlockCount, PDODeviceExtension->BlockLength); // - // now send read cmd - // - Status = USBSTOR_SendCBW(DeviceObject, UFI_READ_CMD_LEN, (PUCHAR)&Cmd, Request->DataTransferLength, &OutControl); - if (!NT_SUCCESS(Status)) - { - // - // failed to send CBW - // - DPRINT1("USBSTOR_SendReadCmd> USBSTOR_SendCBW failed with %x\n", Status); - FreeItem(Response); - ASSERT(FALSE); - return Status; - } - - // - // now read the logical block - // - Status = USBSTOR_SendData(DeviceObject, Request->DataTransferLength, Response); - if (!NT_SUCCESS(Status)) - { - // - // failed to read logical block - // - DPRINT1("USBSTOR_SendReadCmd> USBSTOR_SendData failed with %x\n", Status); - FreeItem(Response); - ASSERT(FALSE); - return Status; - } - - - DbgBreakPoint(); - - // - // send csw - // - Status = USBSTOR_SendCSW(DeviceObject, OutControl, 512, &CSW); - - DPRINT1("------------------------\n"); - DPRINT1("CSW %p\n", &CSW); - DPRINT1("Signature %x\n", CSW.Signature); - DPRINT1("Tag %x\n", CSW.Tag); - DPRINT1("DataResidue %x\n", CSW.DataResidue); - DPRINT1("Status %x\n", CSW.Status); - - // - // FIXME: handle error - // - ASSERT(CSW.Status == 0); - ASSERT(CSW.DataResidue == 0); - - // - // calculate transfer length - // - *TransferBufferLength = Request->DataTransferLength - CSW.DataResidue; - - // - // copy buffer - // - RtlCopyMemory(Request->DataBuffer, Response, *TransferBufferLength); - - // - // free item - // - FreeItem(OutControl); - - // - // free response - // - FreeItem(Response); - - // - // done - // - return Status; + // send request + // + return USBSTOR_SendRequest(DeviceObject, Irp, NULL, UFI_READ_CMD_LEN, (PUCHAR)&Cmd, Request->DataTransferLength, (PUCHAR)Request->DataBuffer); } NTSTATUS USBSTOR_SendTestUnitCmd( IN PDEVICE_OBJECT DeviceObject, - IN OUT PSCSI_REQUEST_BLOCK Request) + IN OUT PIRP Irp) { UFI_TEST_UNIT_CMD Cmd; - CSW CSW; - NTSTATUS Status; - PVOID Response; PPDO_DEVICE_EXTENSION PDODeviceExtension; - PCBW OutControl; - PCDB pCDB; - ULONG BlockCount; + PIO_STACK_LOCATION IoStack; + PSCSI_REQUEST_BLOCK Request; + + // + // get current stack location + // + IoStack = IoGetCurrentIrpStackLocation(Irp); + + // + // get request block + // + Request = (PSCSI_REQUEST_BLOCK)IoStack->Parameters.Others.Argument1; + + // + // no transfer length + // + ASSERT(Request->DataTransferLength == 0); + + // + // get PDO device extension + // + PDODeviceExtension = (PPDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension; // // initialize test unit cmd @@ -836,54 +885,7 @@ Cmd.LUN = (PDODeviceExtension->LUN & MAX_LUN); // - // no data should be transferred - // - ASSERT(Request->DataTransferLength == 0); - - // - // now send test unit cmd - // - Status = USBSTOR_SendCBW(DeviceObject, UFI_TEST_UNIT_CMD_LEN, (PUCHAR)&Cmd, 0, &OutControl); - if (!NT_SUCCESS(Status)) - { - // - // failed to send CBW - // - DPRINT1("USBSTOR_SendReadCmd> USBSTOR_SendCBW failed with %x\n", Status); - FreeItem(Response); - ASSERT(FALSE); - return Status; - } - - // - // send csw - // - Status = USBSTOR_SendCSW(DeviceObject, OutControl, 512, &CSW); - - DPRINT1("------------------------\n"); - DPRINT1("CSW %p\n", &CSW); - DPRINT1("Signature %x\n", CSW.Signature); - DPRINT1("Tag %x\n", CSW.Tag); - DPRINT1("DataResidue %x\n", CSW.DataResidue); - DPRINT1("Status %x\n", CSW.Status); - - // - // FIXME: handle error - // - ASSERT(CSW.Status == 0); - ASSERT(CSW.DataResidue == 0); - - // - // free item - // - FreeItem(OutControl); - - // - // FIXME: read sense buffer - // - - // - // done - // - return Status; -} + // send the request + // + return USBSTOR_SendRequest(DeviceObject, Irp, NULL, UFI_TEST_UNIT_CMD_LEN, (PUCHAR)&Cmd, 0, NULL); +} Modified: branches/usb-bringup/drivers/usb/usbstor/usbstor.c URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/usb/usbstor…
============================================================================== --- branches/usb-bringup/drivers/usb/usbstor/usbstor.c [iso-8859-1] (original) +++ branches/usb-bringup/drivers/usb/usbstor/usbstor.c [iso-8859-1] Wed May 11 03:49:15 2011 @@ -165,11 +165,7 @@ // // handle requests // - Status = USBSTOR_HandleInternalDeviceControl(DeviceObject, Irp); - - Irp->IoStatus.Status = Status; - IoCompleteRequest(Irp, IO_NO_INCREMENT); - return Status; + return USBSTOR_HandleInternalDeviceControl(DeviceObject, Irp); } NTSTATUS Modified: branches/usb-bringup/drivers/usb/usbstor/usbstor.h URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/usb/usbstor…
============================================================================== --- branches/usb-bringup/drivers/usb/usbstor/usbstor.h [iso-8859-1] (original) +++ branches/usb-bringup/drivers/usb/usbstor/usbstor.h [iso-8859-1] Wed May 11 03:49:15 2011 @@ -250,6 +250,25 @@ #define UFI_TEST_UNIT_CMD_LEN (6) +typedef struct +{ + union + { + PCBW cbw; + PCSW csw; + }; + URB Urb; + PIRP Irp; + ULONG TransferDataLength; + PUCHAR TransferData; + PFDO_DEVICE_EXTENSION FDODeviceExtension; + PPDO_DEVICE_EXTENSION PDODeviceExtension; + PMDL TransferBufferMDL; + PKEVENT Event; +}IRP_CONTEXT, *PIRP_CONTEXT; + + + //--------------------------------------------------------------------- // // fdo.c routines @@ -345,26 +364,22 @@ NTSTATUS USBSTOR_SendCapacityCmd( IN PDEVICE_OBJECT DeviceObject, - OUT PREAD_CAPACITY_DATA_EX CapacityDataEx, - OUT PREAD_CAPACITY_DATA CapacityData); + IN PIRP Irp); NTSTATUS USBSTOR_SendModeSenseCmd( IN PDEVICE_OBJECT DeviceObject, - IN OUT PSCSI_REQUEST_BLOCK Request, - OUT PULONG TransferBufferLength); + IN PIRP Irp); NTSTATUS USBSTOR_SendReadCmd( IN PDEVICE_OBJECT DeviceObject, - IN OUT PSCSI_REQUEST_BLOCK Request, - OUT PULONG TransferBufferLength); + IN PIRP Irp); NTSTATUS USBSTOR_SendTestUnitCmd( IN PDEVICE_OBJECT DeviceObject, - IN OUT PSCSI_REQUEST_BLOCK Request); - + IN PIRP Irp); //--------------------------------------------------------------------- //
13 years, 6 months
1
0
0
0
[mjmartin] 51672: [USBHUB_NEW] - Save PortNumber in child device extensions as its needed when PNP request device capabilities. - Handle IOCTL_INTERNAL_USB_SUBMIT_URB request by creating a new Irp ...
by mjmartin@svn.reactos.org
Author: mjmartin Date: Wed May 11 02:25:11 2011 New Revision: 51672 URL:
http://svn.reactos.org/svn/reactos?rev=51672&view=rev
Log: [USBHUB_NEW] - Save PortNumber in child device extensions as its needed when PNP request device capabilities. - Handle IOCTL_INTERNAL_USB_SUBMIT_URB request by creating a new Irp and passing the Urb down to the miniport. - Now working with our ehci driver, we at least see a usb driver and can browse directory in Windows, though doing so results in assert as ehci doesnt support transfers over 5 Pages yet. Fix coming soon. Modified: branches/usb-bringup/drivers/usb/usbhub_new/fdo.c branches/usb-bringup/drivers/usb/usbhub_new/misc.c branches/usb-bringup/drivers/usb/usbhub_new/pdo.c branches/usb-bringup/drivers/usb/usbhub_new/usbhub.h Modified: branches/usb-bringup/drivers/usb/usbhub_new/fdo.c URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/usb/usbhub_…
============================================================================== --- branches/usb-bringup/drivers/usb/usbhub_new/fdo.c [iso-8859-1] (original) +++ branches/usb-bringup/drivers/usb/usbhub_new/fdo.c [iso-8859-1] Wed May 11 02:25:11 2011 @@ -9,8 +9,6 @@ */ #define INITGUID - -#define NDEBUG #include "usbhub.h" NTSTATUS @@ -73,11 +71,18 @@ // Status = IoCallDriver(RootHubDeviceObject, Irp); - if (Status == STATUS_PENDING) + // + // Its ok to block here as this function is called in an nonarbitrary thread + // + if (Status == STATUS_PENDING) { KeWaitForSingleObject(&Event, Suspended, KernelMode, FALSE, NULL); Status = IoStatus.Status; } + + // + // The IO Manager will free the IRP + // return Status; } @@ -353,9 +358,21 @@ DPRINT1("Port %d Status %x\n", PortId, PortStatus.Status); DPRINT1("Port %d Change %x\n", PortId, PortStatus.Change); + // + // Check that reset was cleared + // if(PortStatus.Change & USB_PORT_STATUS_RESET) { DPRINT1("Port did not clear reset! Possible Hardware problem!\n"); + } + + // + // Check if the device is still connected + // + if (!(PortStatus.Status & USB_PORT_STATUS_CONNECT)) + { + DPRINT1("Device has been disconnected\n"); + continue; } // @@ -838,8 +855,8 @@ DevDesc->bDeviceClass) + 1; } BufferPtr[Index] = UNICODE_NULL; + UsbChildExtension->usCompatibleIds.Buffer = BufferPtr; DPRINT1("usCompatibleIds %wZ\n", &UsbChildExtension->usCompatibleIds); - UsbChildExtension->usCompatibleIds.Buffer = BufferPtr; // // Initialize the DeviceId String @@ -860,8 +877,8 @@ // Construct DeviceId // swprintf(BufferPtr, L"USB\\Vid_%04x&Pid_%04x\0", UsbChildExtension->DeviceDesc.idVendor, UsbChildExtension->DeviceDesc.idProduct); - DPRINT1("usDeviceId) %wZ\n", &UsbChildExtension->usDeviceId); UsbChildExtension->usDeviceId.Buffer = BufferPtr; + DPRINT1("usDeviceId %wZ\n", &UsbChildExtension->usDeviceId); // // Initialize the HardwareId String @@ -889,8 +906,8 @@ L"USB\\Vid_%04x&Pid_%04x", UsbChildExtension->DeviceDesc.idVendor, UsbChildExtension->DeviceDesc.idProduct) + 1; BufferPtr[Index] = UNICODE_NULL; + UsbChildExtension->usHardwareIds.Buffer = BufferPtr; DPRINT1("usHardWareIds %wZ\n", &UsbChildExtension->usHardwareIds); - UsbChildExtension->usHardwareIds.Buffer = BufferPtr; // // FIXME: Handle Lang ids @@ -1049,6 +1066,7 @@ UsbChildExtension = (PHUB_CHILDDEVICE_EXTENSION)NewChildDeviceObject->DeviceExtension; RtlZeroMemory(UsbChildExtension, sizeof(HUB_CHILDDEVICE_EXTENSION)); UsbChildExtension->ParentDeviceObject = UsbHubDeviceObject; + UsbChildExtension->PortNumber = PortId; // // Create the UsbDeviceObject @@ -1567,6 +1585,10 @@ Status = HubDeviceExtension->HubInterface.RootHubInitNotification(HubInterfaceBusContext, DeviceObject, (PRH_INIT_CALLBACK)RootHubInitCallbackFunction); + if (!NT_SUCCESS(Status)) + { + DPRINT1("Failed to set callback\n"); + } } else { @@ -1574,11 +1596,6 @@ // Send the first SCE Request // QueryStatusChangeEndpoint(DeviceObject); - } - - if (!NT_SUCCESS(Status)) - { - DPRINT1("Failed to set callback\n"); } ExFreePool(Urb); Modified: branches/usb-bringup/drivers/usb/usbhub_new/misc.c URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/usb/usbhub_…
============================================================================== --- branches/usb-bringup/drivers/usb/usbhub_new/misc.c [iso-8859-1] (original) +++ branches/usb-bringup/drivers/usb/usbhub_new/misc.c [iso-8859-1] Wed May 11 02:25:11 2011 @@ -7,7 +7,6 @@ * Michael Martin (michael.martin(a)reactos.org) * Johannes Anderwald (johannes.anderwald(a)reactos.org) */ -#define NDEBUG #include "usbhub.h" #include <stdarg.h> Modified: branches/usb-bringup/drivers/usb/usbhub_new/pdo.c URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/usb/usbhub_…
============================================================================== --- branches/usb-bringup/drivers/usb/usbhub_new/pdo.c [iso-8859-1] (original) +++ branches/usb-bringup/drivers/usb/usbhub_new/pdo.c [iso-8859-1] Wed May 11 02:25:11 2011 @@ -9,24 +9,141 @@ * Johannes Anderwald (johannes.anderwald(a)reactos.org) */ -#define NDEBUG #include "usbhub.h" #define IO_METHOD_FROM_CTL_CODE(ctlCode) (ctlCode&0x00000003) - + +NTSTATUS +UrbCompletion( + PDEVICE_OBJECT DeviceObject, + PIRP Irp, + PVOID Context) +{ + PIRP OriginalIrp; + DPRINT("Entered Urb Completion\n"); + + // + // Get the original Irp + // + OriginalIrp = (PIRP)Context; + + // + // Update it to match what was returned for the IRP that was passed to RootHub + // + OriginalIrp->IoStatus.Status = Irp->IoStatus.Status; + OriginalIrp->IoStatus.Information = Irp->IoStatus.Information; + DPRINT("Status %x, Information %x\n", Irp->IoStatus.Status, Irp->IoStatus.Information); + + // + // Complete the original Irp + // + IoCompleteRequest(OriginalIrp, IO_NO_INCREMENT); + + // + // Return this status so the IO Manager doesnt mess with the Irp + // + return STATUS_MORE_PROCESSING_REQUIRED; +} + +NTSTATUS +FowardUrbToRootHub( + PDEVICE_OBJECT RootHubDeviceObject, + IN ULONG IoControlCode, + PIRP Irp, + OUT PVOID OutParameter1, + OUT PVOID OutParameter2) +{ + NTSTATUS Status; + PIRP ForwardIrp; + IO_STATUS_BLOCK IoStatus; + PIO_STACK_LOCATION ForwardStack, CurrentStack; + PURB Urb; + + // + // Get the current stack location for the Irp + // + CurrentStack = IoGetCurrentIrpStackLocation(Irp); + ASSERT(CurrentStack); + + // + // Pull the Urb from that stack, it will be reused in the Irp sent to RootHub + // + Urb = (PURB)CurrentStack->Parameters.Others.Argument1; + ASSERT(Urb); + + // + // Create the Irp to forward to RootHub + // + ForwardIrp = IoBuildAsynchronousFsdRequest(IRP_MJ_SHUTDOWN, + RootHubDeviceObject, + NULL, + 0, + 0, + &IoStatus); + if (!ForwardIrp) + { + DPRINT1("Failed to allocate IRP\n"); + return STATUS_INSUFFICIENT_RESOURCES; + } + + // + // Get the new Irps next stack + // + ForwardStack = IoGetNextIrpStackLocation(ForwardIrp); + + // + // Copy the stack for the current irp into the next stack of new irp + // + RtlCopyMemory(ForwardStack, CurrentStack, sizeof(IO_STACK_LOCATION)); + + IoStatus.Status = STATUS_NOT_SUPPORTED; + IoStatus.Information = 0; + + // + // Mark the Irp from upper driver as pending + // + IoMarkIrpPending(Irp); + + // + // Now set the completion routine for the new Irp. + // + IoSetCompletionRoutine(ForwardIrp, + (PIO_COMPLETION_ROUTINE)UrbCompletion, + Irp, + TRUE, + TRUE, + TRUE); + + Status = IoCallDriver(RootHubDeviceObject, ForwardIrp); + + // + // Always return pending as the completion routine will take care of it + // + return STATUS_PENDING; +} + NTSTATUS USBHUB_PdoHandleInternalDeviceControl( IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp) { + NTSTATUS Status; PIO_STACK_LOCATION Stack; ULONG_PTR Information = 0; - NTSTATUS Status; - - DPRINT1("UsbhubInternalDeviceControlPdo(%x) called\n", DeviceObject); + PHUB_DEVICE_EXTENSION HubDeviceExtension; + PHUB_CHILDDEVICE_EXTENSION ChildDeviceExtension; + PDEVICE_OBJECT RootHubDeviceObject; + PURB Urb; + + //DPRINT1("UsbhubInternalDeviceControlPdo(%x) called\n", DeviceObject); Stack = IoGetCurrentIrpStackLocation(Irp); Status = Irp->IoStatus.Status; + + ChildDeviceExtension = (PHUB_CHILDDEVICE_EXTENSION)DeviceObject->DeviceExtension; + ASSERT(ChildDeviceExtension->Common.IsFDO == FALSE); + HubDeviceExtension = (PHUB_DEVICE_EXTENSION)ChildDeviceExtension->ParentDeviceObject->DeviceExtension; + RootHubDeviceObject = HubDeviceExtension->RootHubPhysicalDeviceObject; switch (Stack->Parameters.DeviceIoControl.IoControlCode) { @@ -53,6 +170,102 @@ } break; } + case IOCTL_INTERNAL_USB_SUBMIT_URB: + { + //DPRINT1("IOCTL_INTERNAL_USB_SUBMIT_URB\n"); + // + // get current stack location + // + Stack = IoGetCurrentIrpStackLocation(Irp); + ASSERT(Stack); + + // + // Get the Urb + // + Urb = (PURB)Stack->Parameters.Others.Argument1; + ASSERT(Urb); + + // + // Set the real device handle + // + DPRINT("UsbdDeviceHandle %x, ChildDeviceHandle %x\n", Urb->UrbHeader.UsbdDeviceHandle, ChildDeviceExtension->UsbDeviceHandle); + + Urb->UrbHeader.UsbdDeviceHandle = ChildDeviceExtension->UsbDeviceHandle; + + // + // Submit to RootHub + // + switch (Urb->UrbHeader.Function) + { + // + // Debugging only + // + case URB_FUNCTION_GET_DESCRIPTOR_FROM_DEVICE: + DPRINT1("URB_FUNCTION_GET_DESCRIPTOR_FROM_DEVICE\n"); + break; + case URB_FUNCTION_CLASS_DEVICE: + DPRINT1("URB_FUNCTION_CLASS_DEVICE\n"); + break; + case URB_FUNCTION_GET_STATUS_FROM_DEVICE: + DPRINT1("URB_FUNCTION_GET_STATUS_FROM_DEVICE\n"); + break; + case URB_FUNCTION_SELECT_CONFIGURATION: + DPRINT1("URB_FUNCTION_SELECT_CONFIGURATION\n"); + break; + case URB_FUNCTION_SELECT_INTERFACE: + DPRINT1("URB_FUNCTION_SELECT_INTERFACE\n"); + break; + case URB_FUNCTION_CLASS_OTHER: + DPRINT1("URB_FUNCTION_CLASS_OTHER\n"); + break; + case URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER: + { + /* + DPRINT1("URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER\n"); + DPRINT1("PipeHandle %x\n", Urb->UrbBulkOrInterruptTransfer.PipeHandle); + DPRINT1("TransferFlags %x\n", Urb->UrbBulkOrInterruptTransfer.TransferFlags); + DPRINT1("Buffer %x\n", Urb->UrbBulkOrInterruptTransfer.TransferBuffer); + DPRINT1("BufferMDL %x\n", Urb->UrbBulkOrInterruptTransfer.TransferBufferMDL); + DPRINT1("Length %x\n", Urb->UrbBulkOrInterruptTransfer.TransferBufferLength); + DPRINT1("UrbLink %x\n", Urb->UrbBulkOrInterruptTransfer.UrbLink); + DPRINT1("hca %x\n", Urb->UrbBulkOrInterruptTransfer.hca); + */ + break; + } + case URB_FUNCTION_CLASS_INTERFACE: + DPRINT1("URB_FUNCTION_CLASS_INTERFACE\n"); + break; + default: + DPRINT1("IOCTL_INTERNAL_USB_SUBMIT_URB Function %x NOT IMPLEMENTED\n", Urb->UrbHeader.Function); + break; + } + Urb->UrbHeader.UsbdDeviceHandle = ChildDeviceExtension->UsbDeviceHandle; + //DPRINT1("Stack->CompletionRoutine %x\n", Stack->CompletionRoutine); + // + // Send the request to RootHub + // + Status = FowardUrbToRootHub(RootHubDeviceObject, IOCTL_INTERNAL_USB_SUBMIT_URB, Irp, Urb, NULL); + return Status; + break; + } + // + // FIXME: Can these be sent to RootHub? + // + case IOCTL_INTERNAL_USB_RESET_PORT: + DPRINT1("IOCTL_INTERNAL_USB_RESET_PORT\n"); + break; + case IOCTL_INTERNAL_USB_GET_PORT_STATUS: + DPRINT1("IOCTL_INTERNAL_USB_GET_PORT_STATUS\n"); + break; + case IOCTL_INTERNAL_USB_ENABLE_PORT: + DPRINT1("IOCTL_INTERNAL_USB_ENABLE_PORT\n"); + break; + case IOCTL_INTERNAL_USB_CYCLE_PORT: + DPRINT1("IOCTL_INTERNAL_USB_CYCLE_PORT\n"); + break; + case IOCTL_INTERNAL_USB_GET_DEVICE_HANDLE: + DPRINT1("IOCTL_INTERNAL_USB_GET_DEVICE_HANDLE\n"); + break; default: { DPRINT1("Unknown IOCTL code 0x%lx\n", Stack->Parameters.DeviceIoControl.IoControlCode); @@ -61,9 +274,12 @@ } } - Irp->IoStatus.Information = Information; - Irp->IoStatus.Status = Status; - IoCompleteRequest(Irp, IO_NO_INCREMENT); + if (Status != STATUS_PENDING) + { + Irp->IoStatus.Information = Information; + Irp->IoStatus.Status = Status; + IoCompleteRequest(Irp, IO_NO_INCREMENT); + } return Status; } @@ -202,11 +418,13 @@ IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp) { + NTSTATUS Status; ULONG MinorFunction; PIO_STACK_LOCATION Stack; ULONG_PTR Information = 0; - NTSTATUS Status; - + PHUB_CHILDDEVICE_EXTENSION UsbChildExtension; + + UsbChildExtension = (PHUB_CHILDDEVICE_EXTENSION)DeviceObject->DeviceExtension; Stack = IoGetCurrentIrpStackLocation(Irp); MinorFunction = Stack->MinorFunction; @@ -226,16 +444,18 @@ DeviceCapabilities = (PDEVICE_CAPABILITIES)Stack->Parameters.DeviceCapabilities.Capabilities; // FIXME: capabilities can change with connected device - DeviceCapabilities->LockSupported = TRUE; - DeviceCapabilities->EjectSupported = TRUE; + DeviceCapabilities->LockSupported = FALSE; + DeviceCapabilities->EjectSupported = FALSE; DeviceCapabilities->Removable = TRUE; DeviceCapabilities->DockDevice = FALSE; - DeviceCapabilities->UniqueID = TRUE; - DeviceCapabilities->SilentInstall = TRUE; + DeviceCapabilities->UniqueID = FALSE; + DeviceCapabilities->SilentInstall = FALSE; DeviceCapabilities->RawDeviceOK = FALSE; - DeviceCapabilities->SurpriseRemovalOK = TRUE; + DeviceCapabilities->SurpriseRemovalOK = FALSE; DeviceCapabilities->HardwareDisabled = FALSE; //DeviceCapabilities->NoDisplayInUI = FALSE; + DeviceCapabilities->Address = UsbChildExtension->PortNumber; + DeviceCapabilities->UINumber = 0; DeviceCapabilities->DeviceState[0] = PowerDeviceD0; for (i = 0; i < PowerSystemMaximum; i++) DeviceCapabilities->DeviceState[i] = PowerDeviceD3; @@ -318,6 +538,7 @@ // FIXME // Status = STATUS_SUCCESS; + break; } default: { Modified: branches/usb-bringup/drivers/usb/usbhub_new/usbhub.h URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/usb/usbhub_…
============================================================================== --- branches/usb-bringup/drivers/usb/usbhub_new/usbhub.h [iso-8859-1] (original) +++ branches/usb-bringup/drivers/usb/usbhub_new/usbhub.h [iso-8859-1] Wed May 11 02:25:11 2011 @@ -56,6 +56,7 @@ COMMON_DEVICE_EXTENSION Common; PDEVICE_OBJECT ParentDeviceObject; PUSB_DEVICE_HANDLE UsbDeviceHandle; + ULONG PortNumber; UNICODE_STRING usDeviceId; UNICODE_STRING usInstanceId; UNICODE_STRING usHardwareIds;
13 years, 6 months
1
0
0
0
[janderwald] 51671: [USBSTOR] - Partly implement test unit command
by janderwald@svn.reactos.org
Author: janderwald Date: Tue May 10 23:26:56 2011 New Revision: 51671 URL:
http://svn.reactos.org/svn/reactos?rev=51671&view=rev
Log: [USBSTOR] - Partly implement test unit command Modified: branches/usb-bringup/drivers/usb/usbstor/disk.c branches/usb-bringup/drivers/usb/usbstor/scsi.c branches/usb-bringup/drivers/usb/usbstor/usbstor.h Modified: branches/usb-bringup/drivers/usb/usbstor/disk.c URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/usb/usbstor…
============================================================================== --- branches/usb-bringup/drivers/usb/usbstor/disk.c [iso-8859-1] (original) +++ branches/usb-bringup/drivers/usb/usbstor/disk.c [iso-8859-1] Tue May 10 23:26:56 2011 @@ -125,13 +125,36 @@ else { // - // failed to retrieve sense data + // failed to read // Irp->IoStatus.Information = 0; Request->SrbStatus = SRB_STATUS_ERROR; } } - + else if (pCDB->MODE_SENSE.OperationCode == SCSIOP_TEST_UNIT_READY) + { + DPRINT1("SCSIOP_TEST_UNIT_READY\n"); + + // + // send test unit command + // + Status = USBSTOR_SendTestUnitCmd(DeviceObject, Request); + + if (NT_SUCCESS(Status)) + { + // + // store returned info length + // + Request->SrbStatus = SRB_STATUS_SUCCESS; + } + else + { + // + // test unit command failed + // + Request->SrbStatus = SRB_STATUS_ERROR; + } + } else { UNIMPLEMENTED; @@ -421,7 +444,7 @@ DeviceDescriptor->Size = TotalLength; DeviceDescriptor->DeviceType = InquiryData->DeviceType; DeviceDescriptor->DeviceTypeModifier = (InquiryData->RMB & 0x7F); - DeviceDescriptor->RemovableMedia = FALSE; //FIXME check if floppy + DeviceDescriptor->RemovableMedia = TRUE; DeviceDescriptor->CommandQueueing = FALSE; DeviceDescriptor->BusType = BusTypeUsb; DeviceDescriptor->VendorIdOffset = sizeof(STORAGE_DEVICE_DESCRIPTOR) - sizeof(UCHAR); Modified: branches/usb-bringup/drivers/usb/usbstor/scsi.c URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/usb/usbstor…
============================================================================== --- branches/usb-bringup/drivers/usb/usbstor/scsi.c [iso-8859-1] (original) +++ branches/usb-bringup/drivers/usb/usbstor/scsi.c [iso-8859-1] Tue May 10 23:26:56 2011 @@ -632,7 +632,7 @@ // MODE_PARAMETER_BLOCK // // - DbgBreakPoint(); + UNIMPLEMENTED // // send csw @@ -813,3 +813,77 @@ // return Status; } + +NTSTATUS +USBSTOR_SendTestUnitCmd( + IN PDEVICE_OBJECT DeviceObject, + IN OUT PSCSI_REQUEST_BLOCK Request) +{ + UFI_TEST_UNIT_CMD Cmd; + CSW CSW; + NTSTATUS Status; + PVOID Response; + PPDO_DEVICE_EXTENSION PDODeviceExtension; + PCBW OutControl; + PCDB pCDB; + ULONG BlockCount; + + // + // initialize test unit cmd + // + RtlZeroMemory(&Cmd, sizeof(UFI_TEST_UNIT_CMD)); + Cmd.Code = SCSIOP_TEST_UNIT_READY; + Cmd.LUN = (PDODeviceExtension->LUN & MAX_LUN); + + // + // no data should be transferred + // + ASSERT(Request->DataTransferLength == 0); + + // + // now send test unit cmd + // + Status = USBSTOR_SendCBW(DeviceObject, UFI_TEST_UNIT_CMD_LEN, (PUCHAR)&Cmd, 0, &OutControl); + if (!NT_SUCCESS(Status)) + { + // + // failed to send CBW + // + DPRINT1("USBSTOR_SendReadCmd> USBSTOR_SendCBW failed with %x\n", Status); + FreeItem(Response); + ASSERT(FALSE); + return Status; + } + + // + // send csw + // + Status = USBSTOR_SendCSW(DeviceObject, OutControl, 512, &CSW); + + DPRINT1("------------------------\n"); + DPRINT1("CSW %p\n", &CSW); + DPRINT1("Signature %x\n", CSW.Signature); + DPRINT1("Tag %x\n", CSW.Tag); + DPRINT1("DataResidue %x\n", CSW.DataResidue); + DPRINT1("Status %x\n", CSW.Status); + + // + // FIXME: handle error + // + ASSERT(CSW.Status == 0); + ASSERT(CSW.DataResidue == 0); + + // + // free item + // + FreeItem(OutControl); + + // + // FIXME: read sense buffer + // + + // + // done + // + return Status; +} Modified: branches/usb-bringup/drivers/usb/usbstor/usbstor.h URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/usb/usbstor…
============================================================================== --- branches/usb-bringup/drivers/usb/usbstor/usbstor.h [iso-8859-1] (original) +++ branches/usb-bringup/drivers/usb/usbstor/usbstor.h [iso-8859-1] Tue May 10 23:26:56 2011 @@ -19,6 +19,22 @@ #define USB_STOR_TAG 'sbsu' #define USB_MAXCHILDREN (16) + + +#define HTONS(n) (((((unsigned short)(n) & 0xFF)) << 8) | (((unsigned short)(n) & 0xFF00) >> 8)) +#define NTOHS(n) (((((unsigned short)(n) & 0xFF)) << 8) | (((unsigned short)(n) & 0xFF00) >> 8)) + +#define HTONL(n) (((((unsigned long)(n) & 0xFF)) << 24) | \ + ((((unsigned long)(n) & 0xFF00)) << 8) | \ + ((((unsigned long)(n) & 0xFF0000)) >> 8) | \ + ((((unsigned long)(n) & 0xFF000000)) >> 24)) + + +#define NTOHL(n) (((((unsigned long)(n) & 0xFF)) << 24) | \ + ((((unsigned long)(n) & 0xFF00)) << 8) | \ + ((((unsigned long)(n) & 0xFF0000)) >> 8) | \ + ((((unsigned long)(n) & 0xFF000000)) >> 24)) + NTSTATUS NTAPI IoAttachDeviceToDeviceStackSafe( IN PDEVICE_OBJECT SourceDevice, @@ -56,6 +72,8 @@ UCHAR LUN; // lun id PVOID InquiryData; // USB SCSI inquiry data UCHAR Claimed; // indicating if it has been claimed by upper driver + ULONG BlockLength; // length of block + ULONG LastLogicBlockAddress; // last block address }PDO_DEVICE_EXTENSION, *PPDO_DEVICE_EXTENSION; // @@ -127,6 +145,24 @@ //-------------------------------------------------------------------------------------------------------------------------------------------- // +// UFI read cmd +// +typedef struct +{ + UCHAR Code; // operation code + UCHAR LUN; // lun + ULONG LogicalBlockAddress; // logical block address + UCHAR Reserved; // reserved 0x00 + USHORT ContiguousLogicBlocks; // num of contiguous logical blocks + UCHAR Reserved1[3]; // reserved 0x00 +}UFI_READ_CMD; + +C_ASSERT(sizeof(UFI_READ_CMD) == 12); + +#define UFI_READ_CMD_LEN (0xA) + +//-------------------------------------------------------------------------------------------------------------------------------------------- +// // UFI read capacity cmd // typedef struct @@ -153,22 +189,6 @@ }UFI_CAPACITY_RESPONSE, *PUFI_CAPACITY_RESPONSE; C_ASSERT(sizeof(UFI_CAPACITY_RESPONSE) == 8); - -#define HTONS(n) (((((unsigned short)(n) & 0xFF)) << 8) | (((unsigned short)(n) & 0xFF00) >> 8)) -#define NTOHS(n) (((((unsigned short)(n) & 0xFF)) << 8) | (((unsigned short)(n) & 0xFF00) >> 8)) - -#define HTONL(n) (((((unsigned long)(n) & 0xFF)) << 24) | \ - ((((unsigned long)(n) & 0xFF00)) << 8) | \ - ((((unsigned long)(n) & 0xFF0000)) >> 8) | \ - ((((unsigned long)(n) & 0xFF000000)) >> 24)) - - -#define NTOHL(n) (((((unsigned long)(n) & 0xFF)) << 24) | \ - ((((unsigned long)(n) & 0xFF00)) << 8) | \ - ((((unsigned long)(n) & 0xFF0000)) >> 8) | \ - ((((unsigned long)(n) & 0xFF000000)) >> 24)) - - //-------------------------------------------------------------------------------------------------------------------------------------------- // @@ -214,6 +234,22 @@ }UFI_TIMER_PROTECT_PAGE, *PUFI_TIMER_PROTECT_PAGE; C_ASSERT(sizeof(UFI_TIMER_PROTECT_PAGE) == 8); +//-------------------------------------------------------------------------------------------------------------------------------------------- +// +// UFI test unit command +// + +typedef struct +{ + UCHAR Code; // operation code 0x00 + UCHAR LUN; // lun + UCHAR Reserved[10]; // reserved 0x00 +}UFI_TEST_UNIT_CMD, *PUFI_TEST_UNIT_CMD; + +C_ASSERT(sizeof(UFI_TEST_UNIT_CMD) == 12); + +#define UFI_TEST_UNIT_CMD_LEN (6) + //--------------------------------------------------------------------- // // fdo.c routines @@ -318,6 +354,18 @@ IN OUT PSCSI_REQUEST_BLOCK Request, OUT PULONG TransferBufferLength); +NTSTATUS +USBSTOR_SendReadCmd( + IN PDEVICE_OBJECT DeviceObject, + IN OUT PSCSI_REQUEST_BLOCK Request, + OUT PULONG TransferBufferLength); + +NTSTATUS +USBSTOR_SendTestUnitCmd( + IN PDEVICE_OBJECT DeviceObject, + IN OUT PSCSI_REQUEST_BLOCK Request); + + //--------------------------------------------------------------------- // // disk.c routines
13 years, 6 months
1
0
0
0
[ekohl] 51670: [EVENTLOG] Log product info upon startup.
by ekohl@svn.reactos.org
Author: ekohl Date: Tue May 10 20:19:14 2011 New Revision: 51670 URL:
http://svn.reactos.org/svn/reactos?rev=51670&view=rev
Log: [EVENTLOG] Log product info upon startup. Modified: trunk/reactos/base/services/eventlog/eventlog.c trunk/reactos/base/services/eventlog/eventlog.h trunk/reactos/base/services/eventlog/file.c Modified: trunk/reactos/base/services/eventlog/eventlog.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/services/eventlog/eve…
============================================================================== --- trunk/reactos/base/services/eventlog/eventlog.c [iso-8859-1] (original) +++ trunk/reactos/base/services/eventlog/eventlog.c [iso-8859-1] Tue May 10 20:19:14 2011 @@ -135,6 +135,71 @@ } +static VOID +ReportProductInfoEvent(VOID) +{ + OSVERSIONINFOW versionInfo; + WCHAR szBuffer[512]; + DWORD dwLength; + HKEY hKey; + DWORD dwValueLength; + DWORD dwType; + LONG lResult = ERROR_SUCCESS; + + ZeroMemory(&versionInfo, sizeof(OSVERSIONINFO)); + versionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); + + /* Get version information */ + if (!GetVersionExW(&versionInfo)) + return; + + ZeroMemory(szBuffer, 512 * sizeof(WCHAR)); + + /* Write version into the buffer */ + dwLength = swprintf(szBuffer, + L"%lu.%lu", + versionInfo.dwMajorVersion, + versionInfo.dwMinorVersion) + 1; + + /* Write build number into the buffer */ + dwLength += swprintf(&szBuffer[dwLength], + L"%lu", + versionInfo.dwBuildNumber) + 1; + + /* Write service pack info into the buffer */ + wcscpy(&szBuffer[dwLength], versionInfo.szCSDVersion); + dwLength += wcslen(versionInfo.szCSDVersion) + 1; + + /* Read 'CurrentType' from the registry and write it into the buffer */ + lResult = RegOpenKeyEx(HKEY_LOCAL_MACHINE, + L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", + 0, + KEY_QUERY_VALUE, + &hKey); + if (lResult == ERROR_SUCCESS) + { + dwValueLength = 512 - dwLength; + lResult = RegQueryValueEx(hKey, + L"CurrentType", + NULL, + &dwType, + (LPBYTE)&szBuffer[dwLength], + &dwValueLength); + + RegCloseKey(hKey); + } + + /* Log the product information */ + LogfReportEvent(EVENTLOG_INFORMATION_TYPE, + 0, + EVENT_EventLogProductInfo, + 4, + szBuffer, + 0, + NULL); +} + + static VOID CALLBACK ServiceMain(DWORD argc, LPWSTR *argv) @@ -169,9 +234,15 @@ DPRINT("Service started\n"); UpdateServiceStatus(SERVICE_RUNNING); + ReportProductInfoEvent(); + LogfReportEvent(EVENTLOG_INFORMATION_TYPE, 0, - EVENT_EventlogStarted); + EVENT_EventlogStarted, + 0, + NULL, + 0, + NULL); } DPRINT("ServiceMain() done\n"); Modified: trunk/reactos/base/services/eventlog/eventlog.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/services/eventlog/eve…
============================================================================== --- trunk/reactos/base/services/eventlog/eventlog.h [iso-8859-1] (original) +++ trunk/reactos/base/services/eventlog/eventlog.h [iso-8859-1] Tue May 10 20:19:14 2011 @@ -12,6 +12,7 @@ #define NDEBUG #define WIN32_NO_STATUS +#include <stdio.h> #include <windows.h> #include <netevent.h> #include <lpctypes.h> @@ -181,7 +182,11 @@ VOID LogfReportEvent(WORD wType, WORD wCategory, - DWORD dwEventId); + DWORD dwEventId, + WORD wNumStrings, + WCHAR *lpStrings, + DWORD dwDataSize, + LPVOID lpRawData); /* eventlog.c */ extern HANDLE MyHeap; Modified: trunk/reactos/base/services/eventlog/file.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/services/eventlog/fil…
============================================================================== --- trunk/reactos/base/services/eventlog/file.c [iso-8859-1] (original) +++ trunk/reactos/base/services/eventlog/file.c [iso-8859-1] Tue May 10 20:19:14 2011 @@ -1054,7 +1054,11 @@ VOID LogfReportEvent(WORD wType, WORD wCategory, - DWORD dwEventId) + DWORD dwEventId, + WORD wNumStrings, + WCHAR *lpStrings, + DWORD dwDataSize, + LPVOID lpRawData) { WCHAR szComputerName[MAX_COMPUTERNAME_LENGTH + 1]; DWORD dwComputerNameLength = MAX_COMPUTERNAME_LENGTH + 1; @@ -1086,10 +1090,10 @@ (LPCWSTR)szComputerName, 0, NULL, - 0, //wNumStrings, - NULL, //lpStrings, - 0, //dwDataSize, - NULL); //lpRawData); + wNumStrings, + lpStrings, + dwDataSize, + lpRawData); dwError = LogfWriteData(pEventSource->LogFile, recSize, logBuffer); if (!dwError)
13 years, 6 months
1
0
0
0
← Newer
1
...
33
34
35
36
37
38
39
...
52
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
Results per page:
10
25
50
100
200