ReactOS.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
List overview
Download
Ros-diffs
July 2013
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
ros-diffs@reactos.org
13 participants
199 discussions
Start a n
N
ew thread
[hbelusca] 59433: [CONSRV] - Fix some files' info-header text. - Move code of SrvSetConsoleWindowInfo to ConDrvSetConsoleWindowInfo. - Introduce the helper function GetScreenBufferSizeUnits to retr...
by hbelusca@svn.reactos.org
Author: hbelusca Date: Sat Jul 6 15:59:28 2013 New Revision: 59433 URL:
http://svn.reactos.org/svn/reactos?rev=59433&view=rev
Log: [CONSRV] - Fix some files' info-header text. - Move code of SrvSetConsoleWindowInfo to ConDrvSetConsoleWindowInfo. - Introduce the helper function GetScreenBufferSizeUnits to retrieve screen-buffer width/height units. Modified: trunk/reactos/win32ss/user/consrv/condrv/coninput.c trunk/reactos/win32ss/user/consrv/condrv/conoutput.c trunk/reactos/win32ss/user/consrv/condrv/graphics.c trunk/reactos/win32ss/user/consrv/condrv/text.c trunk/reactos/win32ss/user/consrv/conoutput.c trunk/reactos/win32ss/user/consrv/frontends/gui/guiterm.c Modified: trunk/reactos/win32ss/user/consrv/condrv/coninput.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/consrv/condrv…
============================================================================== --- trunk/reactos/win32ss/user/consrv/condrv/coninput.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/consrv/condrv/coninput.c [iso-8859-1] Sat Jul 6 15:59:28 2013 @@ -1,7 +1,7 @@ /* * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS Console Server DLL - * FILE: win32ss/user/consrv/coninput.c + * PROJECT: ReactOS Console Driver DLL + * FILE: win32ss/user/consrv/condrv/coninput.c * PURPOSE: Console Input functions * PROGRAMMERS: Jeffrey Morlan * Hermes Belusca-Maito (hermes.belusca(a)sfr.fr) @@ -200,7 +200,7 @@ } -/* PUBLIC SERVER APIS *********************************************************/ +/* PUBLIC DRIVER APIS *********************************************************/ NTSTATUS NTAPI ConDrvReadConsole(IN PCONSOLE Console, Modified: trunk/reactos/win32ss/user/consrv/condrv/conoutput.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/consrv/condrv…
============================================================================== --- trunk/reactos/win32ss/user/consrv/condrv/conoutput.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/consrv/condrv/conoutput.c [iso-8859-1] Sat Jul 6 15:59:28 2013 @@ -1,6 +1,6 @@ /* * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS Console Server DLL + * PROJECT: ReactOS Console Driver DLL * FILE: win32ss/user/consrv/condrv/conoutput.c * PURPOSE: General Console Output Functions * PROGRAMMERS: Jeffrey Morlan @@ -184,7 +184,7 @@ return (Console ? Console->ActiveBuffer : NULL); } -/* PUBLIC SERVER APIS *********************************************************/ +/* PUBLIC DRIVER APIS *********************************************************/ NTSTATUS NTAPI ConDrvInvalidateBitMapRect(IN PCONSOLE Console, Modified: trunk/reactos/win32ss/user/consrv/condrv/graphics.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/consrv/condrv…
============================================================================== --- trunk/reactos/win32ss/user/consrv/condrv/graphics.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/consrv/condrv/graphics.c [iso-8859-1] Sat Jul 6 15:59:28 2013 @@ -1,7 +1,7 @@ /* * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS Console Server DLL - * FILE: win32ss/user/consrv/graphics.c + * PROJECT: ReactOS Console Driver DLL + * FILE: win32ss/user/consrv/condrv/graphics.c * PURPOSE: Console Output Functions for graphics-mode screen-buffers * PROGRAMMERS: Hermes Belusca-Maito (hermes.belusca(a)sfr.fr) * Modified: trunk/reactos/win32ss/user/consrv/condrv/text.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/consrv/condrv…
============================================================================== --- trunk/reactos/win32ss/user/consrv/condrv/text.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/consrv/condrv/text.c [iso-8859-1] Sat Jul 6 15:59:28 2013 @@ -1,7 +1,7 @@ /* * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS Console Server DLL - * FILE: win32ss/user/consrv/text.c + * PROJECT: ReactOS Console Driver DLL + * FILE: win32ss/user/consrv/condrv/text.c * PURPOSE: Console Output Functions for text-mode screen-buffers * PROGRAMMERS: Jeffrey Morlan * Hermes Belusca-Maito (hermes.belusca(a)sfr.fr) @@ -592,7 +592,7 @@ } -/* PUBLIC SERVER APIS *********************************************************/ +/* PUBLIC DRIVER APIS *********************************************************/ NTSTATUS NTAPI ConDrvReadConsoleOutput(IN PCONSOLE Console, @@ -1299,4 +1299,48 @@ return STATUS_SUCCESS; } +NTSTATUS NTAPI +ConDrvSetConsoleWindowInfo(IN PCONSOLE Console, + IN PTEXTMODE_SCREEN_BUFFER Buffer, + IN BOOLEAN Absolute, + IN PSMALL_RECT WindowRect) +{ + SMALL_RECT CapturedWindowRect; + + if (Console == NULL || Buffer == NULL || WindowRect == NULL) + return STATUS_INVALID_PARAMETER; + + /* Validity check */ + ASSERT(Console == Buffer->Header.Console); + + CapturedWindowRect = *WindowRect; + + if (Absolute == FALSE) + { + /* Relative positions given. Transform them to absolute ones */ + CapturedWindowRect.Left += Buffer->ViewOrigin.X; + CapturedWindowRect.Top += Buffer->ViewOrigin.Y; + CapturedWindowRect.Right += Buffer->ViewOrigin.X + Buffer->ViewSize.X - 1; + CapturedWindowRect.Bottom += Buffer->ViewOrigin.Y + Buffer->ViewSize.Y - 1; + } + + /* See MSDN documentation on SetConsoleWindowInfo about the performed checks */ + if ( (CapturedWindowRect.Left < 0) || (CapturedWindowRect.Top < 0) || + (CapturedWindowRect.Right >= Buffer->ScreenBufferSize.X) || + (CapturedWindowRect.Bottom >= Buffer->ScreenBufferSize.Y) || + (CapturedWindowRect.Right <= CapturedWindowRect.Left) || + (CapturedWindowRect.Bottom <= CapturedWindowRect.Top) ) + { + return STATUS_INVALID_PARAMETER; + } + + Buffer->ViewOrigin.X = CapturedWindowRect.Left; + Buffer->ViewOrigin.Y = CapturedWindowRect.Top; + + Buffer->ViewSize.X = CapturedWindowRect.Right - CapturedWindowRect.Left + 1; + Buffer->ViewSize.Y = CapturedWindowRect.Bottom - CapturedWindowRect.Top + 1; + + return STATUS_SUCCESS; +} + /* EOF */ Modified: trunk/reactos/win32ss/user/consrv/conoutput.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/consrv/conout…
============================================================================== --- trunk/reactos/win32ss/user/consrv/conoutput.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/consrv/conoutput.c [iso-8859-1] Sat Jul 6 15:59:28 2013 @@ -756,56 +756,38 @@ return Status; } - - - - +NTSTATUS NTAPI +ConDrvSetConsoleWindowInfo(IN PCONSOLE Console, + IN PTEXTMODE_SCREEN_BUFFER Buffer, + IN BOOLEAN Absolute, + IN PSMALL_RECT WindowRect); CSR_API(SrvSetConsoleWindowInfo) { NTSTATUS Status; PCONSOLE_SETWINDOWINFO SetWindowInfoRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.SetWindowInfoRequest; - PCONSOLE_SCREEN_BUFFER Buff; - SMALL_RECT WindowRect = SetWindowInfoRequest->WindowRect; - - DPRINT("SrvSetConsoleWindowInfo(0x%08x, %d, {L%d, T%d, R%d, B%d}) called\n", + // PCONSOLE_SCREEN_BUFFER Buffer; + PTEXTMODE_SCREEN_BUFFER Buffer; + + DPRINT1("SrvSetConsoleWindowInfo(0x%08x, %d, {L%d, T%d, R%d, B%d}) called\n", SetWindowInfoRequest->OutputHandle, SetWindowInfoRequest->Absolute, - WindowRect.Left, WindowRect.Top, WindowRect.Right, WindowRect.Bottom); - + SetWindowInfoRequest->WindowRect.Left , + SetWindowInfoRequest->WindowRect.Top , + SetWindowInfoRequest->WindowRect.Right, + SetWindowInfoRequest->WindowRect.Bottom); + + // ConSrvGetScreenBuffer Status = ConSrvGetTextModeBuffer(ConsoleGetPerProcessData(CsrGetClientThread()->Process), SetWindowInfoRequest->OutputHandle, - &Buff, - GENERIC_READ, - TRUE); - if (!NT_SUCCESS(Status)) return Status; - - if (SetWindowInfoRequest->Absolute == FALSE) - { - /* Relative positions given. Transform them to absolute ones */ - WindowRect.Left += Buff->ViewOrigin.X; - WindowRect.Top += Buff->ViewOrigin.Y; - WindowRect.Right += Buff->ViewOrigin.X + Buff->ViewSize.X - 1; - WindowRect.Bottom += Buff->ViewOrigin.Y + Buff->ViewSize.Y - 1; - } - - /* See MSDN documentation on SetConsoleWindowInfo about the performed checks */ - if ( (WindowRect.Left < 0) || (WindowRect.Top < 0) || - (WindowRect.Right >= Buff->ScreenBufferSize.X) || - (WindowRect.Bottom >= Buff->ScreenBufferSize.Y) || - (WindowRect.Right <= WindowRect.Left) || - (WindowRect.Bottom <= WindowRect.Top) ) - { - ConSrvReleaseScreenBuffer(Buff, TRUE); - return STATUS_INVALID_PARAMETER; - } - - Buff->ViewOrigin.X = WindowRect.Left; - Buff->ViewOrigin.Y = WindowRect.Top; - - Buff->ViewSize.X = WindowRect.Right - WindowRect.Left + 1; - Buff->ViewSize.Y = WindowRect.Bottom - WindowRect.Top + 1; - - ConSrvReleaseScreenBuffer(Buff, TRUE); - return STATUS_SUCCESS; + &Buffer, GENERIC_READ, TRUE); + if (!NT_SUCCESS(Status)) return Status; + + Status = ConDrvSetConsoleWindowInfo(Buffer->Header.Console, + Buffer, + SetWindowInfoRequest->Absolute, + &SetWindowInfoRequest->WindowRect); + + ConSrvReleaseScreenBuffer(Buffer, TRUE); + return Status; } /* EOF */ Modified: trunk/reactos/win32ss/user/consrv/frontends/gui/guiterm.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/consrv/fronte…
============================================================================== --- trunk/reactos/win32ss/user/consrv/frontends/gui/guiterm.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/consrv/frontends/gui/guiterm.c [iso-8859-1] Sat Jul 6 15:59:28 2013 @@ -142,6 +142,32 @@ }; /* FUNCTIONS ******************************************************************/ + +static VOID +GetScreenBufferSizeUnits(IN PCONSOLE_SCREEN_BUFFER Buffer, + IN PGUI_CONSOLE_DATA GuiData, + OUT PUINT WidthUnit, + OUT PUINT HeightUnit) +{ + if (Buffer == NULL || GuiData == NULL || + WidthUnit == NULL || HeightUnit == NULL) + { + return; + } + + if (GetType(Buffer) == TEXTMODE_BUFFER) + { + *WidthUnit = GuiData->CharWidth ; + *HeightUnit = GuiData->CharHeight; + } + else /* if (GetType(Buffer) == GRAPHICS_BUFFER) */ + { + *WidthUnit = 1; + *HeightUnit = 1; + } +} + + static VOID GuiConsoleAppendMenuItems(HMENU hMenu, @@ -374,16 +400,7 @@ DWORD Width, Height; UINT WidthUnit, HeightUnit; - if (GetType(Buff) == TEXTMODE_BUFFER) - { - WidthUnit = GuiData->CharWidth ; - HeightUnit = GuiData->CharHeight; - } - else /* if (GetType(Buff) == GRAPHICS_BUFFER) */ - { - WidthUnit = 1; - HeightUnit = 1; - } + GetScreenBufferSizeUnits(Buff, GuiData, &WidthUnit, &HeightUnit); Width = Buff->ViewSize.X * WidthUnit + 2 * (GetSystemMetrics(SM_CXFRAME) + GetSystemMetrics(SM_CXEDGE)); @@ -576,16 +593,7 @@ PCONSOLE_SCREEN_BUFFER Buffer = ConDrvGetActiveScreenBuffer(Console); UINT WidthUnit, HeightUnit; - if (GetType(Buffer) == TEXTMODE_BUFFER) - { - WidthUnit = GuiData->CharWidth ; - HeightUnit = GuiData->CharHeight; - } - else /* if (GetType(Buffer) == GRAPHICS_BUFFER) */ - { - WidthUnit = 1; - HeightUnit = 1; - } + GetScreenBufferSizeUnits(Buffer, GuiData, &WidthUnit, &HeightUnit); Rect->left = (SmallRect->Left - Buffer->ViewOrigin.X) * WidthUnit ; Rect->top = (SmallRect->Top - Buffer->ViewOrigin.Y) * HeightUnit; @@ -1061,16 +1069,7 @@ COORD Coord; UINT WidthUnit, HeightUnit; - if (GetType(Buffer) == TEXTMODE_BUFFER) - { - WidthUnit = GuiData->CharWidth ; - HeightUnit = GuiData->CharHeight; - } - else /* if (GetType(Buffer) == GRAPHICS_BUFFER) */ - { - WidthUnit = 1; - HeightUnit = 1; - } + GetScreenBufferSizeUnits(Buffer, GuiData, &WidthUnit, &HeightUnit); Coord.X = Buffer->ViewOrigin.X + ((SHORT)LOWORD(lParam) / (int)WidthUnit ); Coord.Y = Buffer->ViewOrigin.Y + ((SHORT)HIWORD(lParam) / (int)HeightUnit); @@ -1400,16 +1399,7 @@ ActiveBuffer = ConDrvGetActiveScreenBuffer(Console); - if (GetType(ActiveBuffer) == TEXTMODE_BUFFER) - { - WidthUnit = GuiData->CharWidth ; - HeightUnit = GuiData->CharHeight; - } - else /* if (GetType(ActiveBuffer) == GRAPHICS_BUFFER) */ - { - WidthUnit = 1; - HeightUnit = 1; - } + GetScreenBufferSizeUnits(ActiveBuffer, GuiData, &WidthUnit, &HeightUnit); windx = CONGUI_MIN_WIDTH * WidthUnit + 2 * (GetSystemMetrics(SM_CXFRAME) + GetSystemMetrics(SM_CXEDGE)); windy = CONGUI_MIN_HEIGHT * HeightUnit + 2 * (GetSystemMetrics(SM_CYFRAME) + GetSystemMetrics(SM_CYEDGE)) + GetSystemMetrics(SM_CYCAPTION); @@ -1443,16 +1433,7 @@ DWORD windx, windy, charx, chary; UINT WidthUnit, HeightUnit; - if (GetType(Buff) == TEXTMODE_BUFFER) - { - WidthUnit = GuiData->CharWidth ; - HeightUnit = GuiData->CharHeight; - } - else /* if (GetType(Buff) == GRAPHICS_BUFFER) */ - { - WidthUnit = 1; - HeightUnit = 1; - } + GetScreenBufferSizeUnits(Buff, GuiData, &WidthUnit, &HeightUnit); GuiData->WindowSizeLock = TRUE; @@ -1615,16 +1596,7 @@ *pShowXY = sInfo.nPos; - if (GetType(Buff) == TEXTMODE_BUFFER) - { - WidthUnit = GuiData->CharWidth ; - HeightUnit = GuiData->CharHeight; - } - else /* if (GetType(Buff) == GRAPHICS_BUFFER) */ - { - WidthUnit = 1; - HeightUnit = 1; - } + GetScreenBufferSizeUnits(Buff, GuiData, &WidthUnit, &HeightUnit); ScrollWindowEx(GuiData->hWindow, (OldX - Buff->ViewOrigin.X) * WidthUnit , @@ -2684,16 +2656,7 @@ ActiveBuffer = ConDrvGetActiveScreenBuffer(GuiData->Console); if (ActiveBuffer) { - if (GetType(ActiveBuffer) == TEXTMODE_BUFFER) - { - WidthUnit = GuiData->CharWidth ; - HeightUnit = GuiData->CharHeight; - } - else /* if (GetType(ActiveBuffer) == GRAPHICS_BUFFER) */ - { - WidthUnit = 1; - HeightUnit = 1; - } + GetScreenBufferSizeUnits(ActiveBuffer, GuiData, &WidthUnit, &HeightUnit); } else {
11 years, 5 months
1
0
0
0
[ekohl] 59432: [SAMLIB] - Implement SamChangePasswordUser. - Remove useless casts.
by ekohl@svn.reactos.org
Author: ekohl Date: Sat Jul 6 10:28:18 2013 New Revision: 59432 URL:
http://svn.reactos.org/svn/reactos?rev=59432&view=rev
Log: [SAMLIB] - Implement SamChangePasswordUser. - Remove useless casts. Modified: trunk/reactos/dll/win32/samlib/samlib.c Modified: trunk/reactos/dll/win32/samlib/samlib.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/samlib/samlib.c?…
============================================================================== --- trunk/reactos/dll/win32/samlib/samlib.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/samlib/samlib.c [iso-8859-1] Sat Jul 6 10:28:18 2013 @@ -203,8 +203,95 @@ IN PUNICODE_STRING OldPassword, IN PUNICODE_STRING NewPassword) { - UNIMPLEMENTED; - return STATUS_NOT_IMPLEMENTED; + ENCRYPTED_NT_OWF_PASSWORD OldNtPassword; + ENCRYPTED_NT_OWF_PASSWORD NewNtPassword; + ENCRYPTED_LM_OWF_PASSWORD OldLmPassword; + ENCRYPTED_LM_OWF_PASSWORD NewLmPassword; + OEM_STRING LmPwdString; + CHAR LmPwdBuffer[15]; + BOOLEAN OldLmPasswordPresent = FALSE; + BOOLEAN NewLmPasswordPresent = FALSE; + NTSTATUS Status; + + /* Calculate the NT hash for the old password */ + Status = SystemFunction007(OldPassword, + (LPBYTE)&OldNtPassword); + if (!NT_SUCCESS(Status)) + { + TRACE("SystemFunction007 failed (Status 0x%08lx)\n", Status); + return Status; + } + + /* Calculate the NT hash for the new password */ + Status = SystemFunction007(NewPassword, + (LPBYTE)&NewNtPassword); + if (!NT_SUCCESS(Status)) + { + TRACE("SystemFunction007 failed (Status 0x%08lx)\n", Status); + return Status; + } + + /* Calculate the LM password and hash for the old password */ + LmPwdString.Length = 15; + LmPwdString.MaximumLength = 15; + LmPwdString.Buffer = LmPwdBuffer; + ZeroMemory(LmPwdString.Buffer, LmPwdString.MaximumLength); + + Status = RtlUpcaseUnicodeStringToOemString(&LmPwdString, + OldPassword, + FALSE); + if (NT_SUCCESS(Status)) + { + /* Calculate the LM hash value of the password */ + Status = SystemFunction006(LmPwdString.Buffer, + (LPSTR)&OldLmPassword); + if (NT_SUCCESS(Status)) + { + OldLmPasswordPresent = TRUE; + } + } + + /* Calculate the LM password and hash for the new password */ + LmPwdString.Length = 15; + LmPwdString.MaximumLength = 15; + LmPwdString.Buffer = LmPwdBuffer; + ZeroMemory(LmPwdString.Buffer, LmPwdString.MaximumLength); + + Status = RtlUpcaseUnicodeStringToOemString(&LmPwdString, + NewPassword, + FALSE); + if (NT_SUCCESS(Status)) + { + /* Calculate the LM hash value of the password */ + Status = SystemFunction006(LmPwdString.Buffer, + (LPSTR)&NewLmPassword); + if (NT_SUCCESS(Status)) + { + NewLmPasswordPresent = TRUE; + } + } + + RpcTryExcept + { + Status = SamrChangePasswordUser((SAMPR_HANDLE)UserHandle, + OldLmPasswordPresent && NewLmPasswordPresent, + &OldLmPassword, + &NewLmPassword, + TRUE, + &OldNtPassword, + &NewNtPassword, + FALSE, + NULL, + FALSE, + NULL); + } + RpcExcept(EXCEPTION_EXECUTE_HANDLER) + { + Status = I_RpcMapWin32Status(RpcExceptionCode()); + } + RpcEndExcept; + + return Status; } @@ -536,7 +623,7 @@ { Status = SamrEnumerateAliasesInDomain((SAMPR_HANDLE)DomainHandle, EnumerationContext, - (PSAMPR_ENUMERATION_BUFFER *)&EnumBuffer, + &EnumBuffer, PreferedMaximumLength, CountReturned); @@ -586,7 +673,7 @@ { Status = SamrEnumerateDomainsInSamServer((SAMPR_HANDLE)ServerHandle, EnumerationContext, - (PSAMPR_ENUMERATION_BUFFER *)&EnumBuffer, + &EnumBuffer, PreferedMaximumLength, CountReturned); @@ -634,7 +721,7 @@ { Status = SamrEnumerateGroupsInDomain((SAMPR_HANDLE)DomainHandle, EnumerationContext, - (PSAMPR_ENUMERATION_BUFFER *)&EnumBuffer, + &EnumBuffer, PreferedMaximumLength, CountReturned); if (EnumBuffer != NULL) @@ -681,7 +768,7 @@ Status = SamrEnumerateUsersInDomain((SAMPR_HANDLE)DomainHandle, EnumerationContext, UserAccountControl, - (PSAMPR_ENUMERATION_BUFFER *)&EnumBuffer, + &EnumBuffer, PreferedMaximumLength, CountReturned); if (EnumBuffer != NULL)
11 years, 5 months
1
0
0
0
[tfaber] 59431: [INCLUDE] - Properly declare and use DECLSPEC_CACHEALIGN. Patch by Samuel Serapión. CORE-7139 #resolve
by tfaber@svn.reactos.org
Author: tfaber Date: Sat Jul 6 10:11:21 2013 New Revision: 59431 URL:
http://svn.reactos.org/svn/reactos?rev=59431&view=rev
Log: [INCLUDE] - Properly declare and use DECLSPEC_CACHEALIGN. Patch by Samuel Serapión. CORE-7139 #resolve Modified: trunk/reactos/include/ddk/wdm.h trunk/reactos/include/psdk/ntdef.h trunk/reactos/include/xdk/extypes.h Modified: trunk/reactos/include/ddk/wdm.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/ddk/wdm.h?rev=5943…
============================================================================== --- trunk/reactos/include/ddk/wdm.h [iso-8859-1] (original) +++ trunk/reactos/include/ddk/wdm.h [iso-8859-1] Sat Jul 6 10:11:21 2013 @@ -1878,7 +1878,7 @@ #if !defined(_WIN64) && (defined(_NTDDK_) || defined(_NTIFS_) || defined(_NDIS_)) #define LOOKASIDE_ALIGN #else -#define LOOKASIDE_ALIGN /* FIXME: DECLSPEC_CACHEALIGN */ +#define LOOKASIDE_ALIGN DECLSPEC_CACHEALIGN #endif typedef struct _LOOKASIDE_LIST_EX *PLOOKASIDE_LIST_EX; @@ -8333,7 +8333,7 @@ #define HIGH_LEVEL 15 #define KI_USER_SHARED_DATA ((ULONG_PTR)(KADDRESS_BASE + 0xFFFE0000)) -extern volatile LARGE_INTEGER KeTickCount; +extern DECLSPEC_CACHEALIGN volatile LARGE_INTEGER KeTickCount; #define PAUSE_PROCESSOR __yield(); Modified: trunk/reactos/include/psdk/ntdef.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/psdk/ntdef.h?rev=5…
============================================================================== --- trunk/reactos/include/psdk/ntdef.h [iso-8859-1] (original) +++ trunk/reactos/include/psdk/ntdef.h [iso-8859-1] Sat Jul 6 10:11:21 2013 @@ -298,6 +298,18 @@ #define DECLSPEC_ALIGN(x) #endif #endif /* DECLSPEC_ALIGN */ + +#ifndef SYSTEM_CACHE_ALIGNMENT_SIZE +#if defined(_AMD64_) || defined(_X86_) +#define SYSTEM_CACHE_ALIGNMENT_SIZE 64 +#else +#define SYSTEM_CACHE_ALIGNMENT_SIZE 128 +#endif +#endif + +#ifndef DECLSPEC_CACHEALIGN +#define DECLSPEC_CACHEALIGN DECLSPEC_ALIGN(SYSTEM_CACHE_ALIGNMENT_SIZE) +#endif #ifndef DECLSPEC_SELECTANY #if (_MSC_VER >= 1100) || defined(__GNUC__) Modified: trunk/reactos/include/xdk/extypes.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/xdk/extypes.h?rev=…
============================================================================== --- trunk/reactos/include/xdk/extypes.h [iso-8859-1] (original) +++ trunk/reactos/include/xdk/extypes.h [iso-8859-1] Sat Jul 6 10:11:21 2013 @@ -51,7 +51,7 @@ #if !defined(_WIN64) && (defined(_NTDDK_) || defined(_NTIFS_) || defined(_NDIS_)) #define LOOKASIDE_ALIGN #else -#define LOOKASIDE_ALIGN /* FIXME: DECLSPEC_CACHEALIGN */ +#define LOOKASIDE_ALIGN DECLSPEC_CACHEALIGN #endif typedef struct _LOOKASIDE_LIST_EX *PLOOKASIDE_LIST_EX;
11 years, 5 months
1
0
0
0
[cgutman] 59430: [RTL8139] - Switch back to a 32K receive window, because WRAP doesn't work with a 64K window and our receive code depends on that functionality
by cgutman@svn.reactos.org
Author: cgutman Date: Fri Jul 5 08:34:05 2013 New Revision: 59430 URL:
http://svn.reactos.org/svn/reactos?rev=59430&view=rev
Log: [RTL8139] - Switch back to a 32K receive window, because WRAP doesn't work with a 64K window and our receive code depends on that functionality Modified: trunk/reactos/drivers/network/dd/rtl8139/nic.h Modified: trunk/reactos/drivers/network/dd/rtl8139/nic.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/dd/rtl8139…
============================================================================== --- trunk/reactos/drivers/network/dd/rtl8139/nic.h [iso-8859-1] (original) +++ trunk/reactos/drivers/network/dd/rtl8139/nic.h [iso-8859-1] Fri Jul 5 08:34:05 2013 @@ -12,8 +12,10 @@ #define RESOURCE_LIST_TAG 'Rltr' #define MAX_RESET_ATTEMPTS 25 -#define RECEIVE_BUFFER_SIZE (65536) -#define FULL_RECEIVE_BUFFER_SIZE (65536 + 16 + 2048) +#define RECEIVE_BUFFER_SIZE (32768) +// The full receive window requires 16 bytes of padding +// plus 2048 for receive overflows (because of WRAP) +#define FULL_RECEIVE_BUFFER_SIZE (32768 + 16 + 2048) #define RECV_CRC_LENGTH 4 #define MINIMUM_FRAME_SIZE 60 @@ -21,8 +23,8 @@ #define DRIVER_VERSION 1 -// 1/2 packet early RX, 512 byte FIFO threshold, 64K RX buffer, unlimited DMA bursts, WRAP -#define RC_VAL (0x800BF80) +// 1/2 packet early RX, 512 byte FIFO threshold, 32K RX buffer, unlimited DMA bursts, WRAP +#define RC_VAL (0x800B780) // 2048 byte DMA bursts #define TC_VAL (0x700)
11 years, 5 months
1
0
0
0
[cgutman] 59429: [RTL8139] - Fix receive stalling if more than 10 packets are in the receive window - Tune configuration to use larger DMA transfers and begin DMA earlier
by cgutman@svn.reactos.org
Author: cgutman Date: Fri Jul 5 08:11:18 2013 New Revision: 59429 URL:
http://svn.reactos.org/svn/reactos?rev=59429&view=rev
Log: [RTL8139] - Fix receive stalling if more than 10 packets are in the receive window - Tune configuration to use larger DMA transfers and begin DMA earlier Modified: trunk/reactos/drivers/network/dd/rtl8139/interrupt.c trunk/reactos/drivers/network/dd/rtl8139/nic.h Modified: trunk/reactos/drivers/network/dd/rtl8139/interrupt.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/dd/rtl8139…
============================================================================== --- trunk/reactos/drivers/network/dd/rtl8139/interrupt.c [iso-8859-1] (original) +++ trunk/reactos/drivers/network/dd/rtl8139/interrupt.c [iso-8859-1] Fri Jul 5 08:11:18 2013 @@ -78,7 +78,6 @@ ) { PRTL_ADAPTER adapter = (PRTL_ADAPTER)MiniportAdapterContext; - ULONG i; ULONG txStatus; UCHAR command; PPACKET_HEADER nicHeader; @@ -146,7 +145,7 @@ // if (adapter->InterruptPending & (R_I_RXOK | R_I_RXERR)) { - for (i = 0; i < MAX_RECEIVES_PER_INT; i++) + for (;;) { NdisRawReadPortUchar(adapter->IoBase + R_CMD, &command); if (command & R_CMD_RXEMPTY) @@ -200,6 +199,15 @@ adapter->ReceiveOffset += nicHeader->PacketLength + sizeof(PACKET_HEADER); adapter->ReceiveOffset = (adapter->ReceiveOffset + 3) & ~3; NdisRawWritePortUshort(adapter->IoBase + R_CAPR, adapter->ReceiveOffset - 0x10); + + if (adapter->InterruptPending & (R_I_RXOVRFLW | R_I_FIFOOVR)) + { + // + // We can only clear these interrupts once CAPR has been reset + // + NdisRawWritePortUshort(adapter->IoBase + R_IS, R_I_RXOVRFLW | R_I_FIFOOVR); + adapter->InterruptPending &= ~(R_I_RXOVRFLW | R_I_FIFOOVR); + } } NdisMEthIndicateReceiveComplete(adapter->MiniportAdapterHandle); Modified: trunk/reactos/drivers/network/dd/rtl8139/nic.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/dd/rtl8139…
============================================================================== --- trunk/reactos/drivers/network/dd/rtl8139/nic.h [iso-8859-1] (original) +++ trunk/reactos/drivers/network/dd/rtl8139/nic.h [iso-8859-1] Fri Jul 5 08:11:18 2013 @@ -12,9 +12,8 @@ #define RESOURCE_LIST_TAG 'Rltr' #define MAX_RESET_ATTEMPTS 25 -#define MAX_RECEIVES_PER_INT 10 -#define RECEIVE_BUFFER_SIZE (32768) -#define FULL_RECEIVE_BUFFER_SIZE (32768 + 16 + 2048) +#define RECEIVE_BUFFER_SIZE (65536) +#define FULL_RECEIVE_BUFFER_SIZE (65536 + 16 + 2048) #define RECV_CRC_LENGTH 4 #define MINIMUM_FRAME_SIZE 60 @@ -22,11 +21,11 @@ #define DRIVER_VERSION 1 -// 32K RX buffer, 512 byte DMA bursts -#define RC_VAL (0x0001680) - -// 1024 byte DMA bursts -#define TC_VAL (0x600) +// 1/2 packet early RX, 512 byte FIFO threshold, 64K RX buffer, unlimited DMA bursts, WRAP +#define RC_VAL (0x800BF80) + +// 2048 byte DMA bursts +#define TC_VAL (0x700) typedef struct _RTL_ADAPTER { NDIS_HANDLE MiniportAdapterHandle;
11 years, 5 months
1
0
0
0
[cgutman] 59428: [RTL8139] - Fix PCH in CMake file - Fix broken failure path in MiniportInitialize
by cgutman@svn.reactos.org
Author: cgutman Date: Fri Jul 5 05:48:08 2013 New Revision: 59428 URL:
http://svn.reactos.org/svn/reactos?rev=59428&view=rev
Log: [RTL8139] - Fix PCH in CMake file - Fix broken failure path in MiniportInitialize Modified: trunk/reactos/drivers/network/dd/rtl8139/CMakeLists.txt trunk/reactos/drivers/network/dd/rtl8139/ndis.c Modified: trunk/reactos/drivers/network/dd/rtl8139/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/dd/rtl8139…
============================================================================== --- trunk/reactos/drivers/network/dd/rtl8139/CMakeLists.txt [iso-8859-1] (original) +++ trunk/reactos/drivers/network/dd/rtl8139/CMakeLists.txt [iso-8859-1] Fri Jul 5 05:48:08 2013 @@ -12,7 +12,7 @@ rtl8139.rc) add_library(rtl8139 SHARED ${SOURCE}) -add_pch(rtl8139 pcnet.h) +add_pch(rtl8139 nic.h) set_module_type(rtl8139 kernelmodedriver) add_importlibs(rtl8139 ndis ntoskrnl hal) add_cd_file(TARGET rtl8139 DESTINATION reactos/system32/drivers FOR all) Modified: trunk/reactos/drivers/network/dd/rtl8139/ndis.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/dd/rtl8139…
============================================================================== --- trunk/reactos/drivers/network/dd/rtl8139/ndis.c [iso-8859-1] (original) +++ trunk/reactos/drivers/network/dd/rtl8139/ndis.c [iso-8859-1] Fri Jul 5 05:48:08 2013 @@ -356,6 +356,7 @@ if (adapter->ReceiveBuffer == NULL) { NDIS_DbgPrint(MIN_TRACE, ("Unable to allocate receive buffer\n")); + status = NDIS_STATUS_RESOURCES; goto Cleanup; } @@ -367,6 +368,7 @@ if (adapter->RuntTxBuffers == NULL) { NDIS_DbgPrint(MIN_TRACE, ("Unable to allocate runt TX buffer\n")); + status = NDIS_STATUS_RESOURCES; goto Cleanup; }
11 years, 5 months
1
0
0
0
[cgutman] 59427: [RTL8139] - Add an RTL8139 driver based on documentation on OSDev, our existing drivers, and some prior work by Z98 - It should fully work on emulated and real RTL8139 hardware (I ...
by cgutman@svn.reactos.org
Author: cgutman Date: Fri Jul 5 04:18:32 2013 New Revision: 59427 URL:
http://svn.reactos.org/svn/reactos?rev=59427&view=rev
Log: [RTL8139] - Add an RTL8139 driver based on documentation on OSDev, our existing drivers, and some prior work by Z98 - It should fully work on emulated and real RTL8139 hardware (I developed against QEMU's RTL8139) - It's not 100% complete (some reset and halt paths aren't done) but everything I tested worked (ping, dwnl, rapps, Firefox) Added: trunk/reactos/drivers/network/dd/rtl8139/CMakeLists.txt (with props) trunk/reactos/drivers/network/dd/rtl8139/debug.h (with props) trunk/reactos/drivers/network/dd/rtl8139/hardware.c (with props) trunk/reactos/drivers/network/dd/rtl8139/info.c (with props) trunk/reactos/drivers/network/dd/rtl8139/interrupt.c (with props) trunk/reactos/drivers/network/dd/rtl8139/ndis.c (with props) trunk/reactos/drivers/network/dd/rtl8139/nic.h (with props) trunk/reactos/drivers/network/dd/rtl8139/rtl8139.rc (with props) trunk/reactos/drivers/network/dd/rtl8139/rtlhw.h (with props) trunk/reactos/media/inf/netrtl.inf (with props) Removed: trunk/reactos/drivers/network/dd/rtl8139/include/ Modified: trunk/reactos/drivers/network/dd/CMakeLists.txt trunk/reactos/media/inf/CMakeLists.txt Modified: trunk/reactos/drivers/network/dd/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/dd/CMakeLi…
============================================================================== --- trunk/reactos/drivers/network/dd/CMakeLists.txt [iso-8859-1] (original) +++ trunk/reactos/drivers/network/dd/CMakeLists.txt [iso-8859-1] Fri Jul 5 04:18:32 2013 @@ -1,3 +1,4 @@ add_subdirectory(ne2000) add_subdirectory(pcnet) +add_subdirectory(rtl8139) Added: trunk/reactos/drivers/network/dd/rtl8139/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/dd/rtl8139…
============================================================================== --- trunk/reactos/drivers/network/dd/rtl8139/CMakeLists.txt (added) +++ trunk/reactos/drivers/network/dd/rtl8139/CMakeLists.txt [iso-8859-1] Fri Jul 5 04:18:32 2013 @@ -0,0 +1,18 @@ + +add_definitions( + -DNDIS50_MINIPORT + -DNDIS_MINIPORT_DRIVER + -DNDIS_LEGACY_MINIPORT) + +list(APPEND SOURCE + ndis.c + hardware.c + info.c + interrupt.c + rtl8139.rc) + +add_library(rtl8139 SHARED ${SOURCE}) +add_pch(rtl8139 pcnet.h) +set_module_type(rtl8139 kernelmodedriver) +add_importlibs(rtl8139 ndis ntoskrnl hal) +add_cd_file(TARGET rtl8139 DESTINATION reactos/system32/drivers FOR all) Propchange: trunk/reactos/drivers/network/dd/rtl8139/CMakeLists.txt ------------------------------------------------------------------------------ svn:eol-style = native Added: trunk/reactos/drivers/network/dd/rtl8139/debug.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/dd/rtl8139…
============================================================================== --- trunk/reactos/drivers/network/dd/rtl8139/debug.h (added) +++ trunk/reactos/drivers/network/dd/rtl8139/debug.h [iso-8859-1] Fri Jul 5 04:18:32 2013 @@ -0,0 +1,82 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS Novell Eagle 2000 driver + * FILE: include/debug.h + * PURPOSE: Debugging support macros + * DEFINES: DBG - Enable debug output + * NASSERT - Disable assertions + */ + +#pragma once + +#define NORMAL_MASK 0x000000FF +#define SPECIAL_MASK 0xFFFFFF00 +#define MIN_TRACE 0x00000001 +#define MID_TRACE 0x00000002 +#define MAX_TRACE 0x00000003 + +#define DEBUG_MEMORY 0x00000100 +#define DEBUG_ULTRA 0xFFFFFFFF + +#if DBG + +extern ULONG DebugTraceLevel; + +#ifdef _MSC_VER + +#define NDIS_DbgPrint(_t_, _x_) \ + if (((DebugTraceLevel & NORMAL_MASK) >= _t_) || \ + ((DebugTraceLevel & _t_) > NORMAL_MASK)) { \ + DbgPrint("(%s:%d) ", __FILE__, __LINE__); \ + DbgPrint _x_ ; \ + } + +#else /* _MSC_VER */ + +#define NDIS_DbgPrint(_t_, _x_) \ + if (((DebugTraceLevel & NORMAL_MASK) >= _t_) || \ + ((DebugTraceLevel & _t_) > NORMAL_MASK)) { \ + DbgPrint("(%s:%d)(%s) ", __FILE__, __LINE__, __FUNCTION__); \ + DbgPrint _x_ ; \ + } + +#endif /* _MSC_VER */ + + +#define ASSERT_IRQL(x) ASSERT(KeGetCurrentIrql() <= (x)) +#define ASSERT_IRQL_EQUAL(x) ASSERT(KeGetCurrentIrql() == (x)) + +#else /* DBG */ + +#define NDIS_DbgPrint(_t_, _x_) + +#define ASSERT_IRQL(x) +#define ASSERT_IRQL_EQUAL(x) +/* #define ASSERT(x) */ /* ndis.h */ + +#endif /* DBG */ + + +#define assert(x) ASSERT(x) +#define assert_irql(x) ASSERT_IRQL(x) + + +#ifdef _MSC_VER + +#define UNIMPLEMENTED \ + NDIS_DbgPrint(MIN_TRACE, ("The function at %s:%d is unimplemented, \ + but come back another day.\n", __FILE__, __LINE__)); + +#else /* _MSC_VER */ + +#define UNIMPLEMENTED \ + NDIS_DbgPrint(MIN_TRACE, ("%s at %s:%d is unimplemented, \ + but come back another day.\n", __FUNCTION__, __FILE__, __LINE__)); + +#endif /* _MSC_VER */ + + +#define CHECKPOINT \ + do { NDIS_DbgPrint(MIN_TRACE, ("%s:%d\n", __FILE__, __LINE__)); } while(0); + +/* EOF */ Propchange: trunk/reactos/drivers/network/dd/rtl8139/debug.h ------------------------------------------------------------------------------ svn:eol-style = native Added: trunk/reactos/drivers/network/dd/rtl8139/hardware.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/dd/rtl8139…
============================================================================== --- trunk/reactos/drivers/network/dd/rtl8139/hardware.c (added) +++ trunk/reactos/drivers/network/dd/rtl8139/hardware.c [iso-8859-1] Fri Jul 5 04:18:32 2013 @@ -0,0 +1,235 @@ +/* + * ReactOS Realtek 8139 Driver + * + * Copyright (C) 2013 Cameron Gutman + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + */ + +#include "nic.h" + +#define NDEBUG +#include <debug.h> + +NDIS_STATUS +NTAPI +NICPowerOn ( + IN PRTL_ADAPTER Adapter + ) +{ + // + // Send 0x00 to the CONFIG_1 register (0x52) to set the LWAKE + LWPTN to active high. + // This should essentially *power on* the device. + // -- OSDev Wiki + // + NdisRawWritePortUchar(Adapter->IoBase + R_CFG1, 0x00); + return NDIS_STATUS_SUCCESS; +} + +NDIS_STATUS +NTAPI +NICSoftReset ( + IN PRTL_ADAPTER Adapter + ) +{ + UCHAR commandReg; + UINT resetAttempts; + + // + // Sending 0x10 to the Command register (0x37) will send the RTL8139 into a software reset. + // Once that byte is sent, the RST bit must be checked to make sure that the chip has finished the reset. + // If the RST bit is high (1), then the reset is still in operation. + // -- OSDev Wiki + NdisRawWritePortUchar(Adapter->IoBase + R_CMD, B_CMD_RST); + + for (resetAttempts = 0; resetAttempts < MAX_RESET_ATTEMPTS; resetAttempts++) + { + NdisRawReadPortUchar(Adapter->IoBase + R_CMD, &commandReg); + + if (!(commandReg & B_CMD_RST)) + { + return NDIS_STATUS_SUCCESS; + } + + NdisMSleep(100); + } + + return NDIS_STATUS_FAILURE; +} + +NDIS_STATUS +NTAPI +NICRegisterReceiveBuffer ( + IN PRTL_ADAPTER Adapter + ) +{ + ASSERT(NdisGetPhysicalAddressHigh(Adapter->ReceiveBufferPa) == 0); + + NdisRawWritePortUlong(Adapter->IoBase + R_RXSA, Adapter->ReceiveBufferPa.LowPart); + + return NDIS_STATUS_SUCCESS; +} + +NDIS_STATUS +NTAPI +NICRemoveReceiveBuffer ( + IN PRTL_ADAPTER Adapter + ) +{ + NdisRawWritePortUlong(Adapter->IoBase + R_RXSA, 0); + return NDIS_STATUS_SUCCESS; +} + +NDIS_STATUS +NTAPI +NICEnableTxRx ( + IN PRTL_ADAPTER Adapter + ) +{ + NdisRawWritePortUchar(Adapter->IoBase + R_CMD, B_CMD_TXE | B_CMD_RXE); + + // + // TX and RX must be enabled before setting these + // + NdisRawWritePortUlong(Adapter->IoBase + R_RC, RC_VAL); + NdisRawWritePortUlong(Adapter->IoBase + R_TC, TC_VAL); + return NDIS_STATUS_SUCCESS; +} + +NDIS_STATUS +NTAPI +NICGetPermanentMacAddress ( + IN PRTL_ADAPTER Adapter, + OUT PUCHAR MacAddress + ) +{ + UINT i; + + for (i = 0; i < IEEE_802_ADDR_LENGTH; i++) + { + NdisRawReadPortUchar(Adapter->IoBase + R_MAC + i, &MacAddress[i]); + } + + return NDIS_STATUS_SUCCESS; +} + +NDIS_STATUS +NTAPI +NICApplyInterruptMask ( + IN PRTL_ADAPTER Adapter + ) +{ + NdisRawWritePortUshort(Adapter->IoBase + R_IM, Adapter->InterruptMask); + return NDIS_STATUS_SUCCESS; +} + +NDIS_STATUS +NTAPI +NICDisableInterrupts ( + IN PRTL_ADAPTER Adapter + ) +{ + NdisRawWritePortUshort(Adapter->IoBase + R_IM, 0); + return NDIS_STATUS_SUCCESS; +} + +USHORT +NTAPI +NICInterruptRecognized ( + IN PRTL_ADAPTER Adapter, + OUT PBOOLEAN InterruptRecognized + ) +{ + USHORT interruptStatus; + + NdisRawReadPortUshort(Adapter->IoBase + R_IS, &interruptStatus); + + *InterruptRecognized = (interruptStatus & Adapter->InterruptMask) != 0; + + return (interruptStatus & Adapter->InterruptMask); +} + +VOID +NTAPI +NICAcknowledgeInterrupts ( + IN PRTL_ADAPTER Adapter + ) +{ + NdisRawWritePortUshort(Adapter->IoBase + R_IS, Adapter->InterruptPending); +} + +VOID +NTAPI +NICUpdateLinkStatus ( + IN PRTL_ADAPTER Adapter + ) +{ + UCHAR mediaState; + + NdisRawReadPortUchar(Adapter->IoBase + R_MS, &mediaState); + Adapter->MediaState = (mediaState & R_MS_LINKDWN) ? NdisMediaStateDisconnected : + NdisMediaStateConnected; + Adapter->LinkSpeedMbps = (mediaState & R_MS_SPEED_10) ? 10 : 100; +} + +NDIS_STATUS +NTAPI +NICApplyPacketFilter ( + IN PRTL_ADAPTER Adapter + ) +{ + ULONG filterMask; + + filterMask = RC_VAL; + + if (Adapter->PacketFilter & NDIS_PACKET_TYPE_DIRECTED) + { + filterMask |= B_RC_APM; + } + + if (Adapter->PacketFilter & NDIS_PACKET_TYPE_MULTICAST) + { + filterMask |= B_RC_AM; + } + + if (Adapter->PacketFilter & NDIS_PACKET_TYPE_BROADCAST) + { + filterMask |= B_RC_AB; + } + + if (Adapter->PacketFilter & NDIS_PACKET_TYPE_PROMISCUOUS) + { + filterMask |= B_RC_AAP; + } + + NdisRawWritePortUlong(Adapter->IoBase + R_RC, filterMask); + + return NDIS_STATUS_SUCCESS; +} + +NDIS_STATUS +NTAPI +NICTransmitPacket ( + IN PRTL_ADAPTER Adapter, + IN UCHAR TxDesc, + IN ULONG PhysicalAddress, + IN ULONG Length + ) +{ + NdisRawWritePortUlong(Adapter->IoBase + R_TXSAD0 + (TxDesc * sizeof(ULONG)), PhysicalAddress); + NdisRawWritePortUlong(Adapter->IoBase + R_TXSTS0 + (TxDesc * sizeof(ULONG)), Length); + return NDIS_STATUS_SUCCESS; +} Propchange: trunk/reactos/drivers/network/dd/rtl8139/hardware.c ------------------------------------------------------------------------------ svn:eol-style = native Added: trunk/reactos/drivers/network/dd/rtl8139/info.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/dd/rtl8139…
============================================================================== --- trunk/reactos/drivers/network/dd/rtl8139/info.c (added) +++ trunk/reactos/drivers/network/dd/rtl8139/info.c [iso-8859-1] Fri Jul 5 04:18:32 2013 @@ -0,0 +1,394 @@ +/* + * ReactOS Realtek 8139 Driver + * + * Copyright (C) 2013 Cameron Gutman + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + */ + +#include "nic.h" + +#define NDEBUG +#include <debug.h> + +static ULONG SupportedOidList[] = +{ + OID_GEN_SUPPORTED_LIST, + OID_GEN_HARDWARE_STATUS, + OID_GEN_MEDIA_SUPPORTED, + OID_GEN_MEDIA_IN_USE, + OID_GEN_MAXIMUM_LOOKAHEAD, + OID_GEN_MAXIMUM_FRAME_SIZE, + OID_GEN_LINK_SPEED, + OID_GEN_TRANSMIT_BUFFER_SPACE, + OID_GEN_RECEIVE_BUFFER_SPACE, + OID_GEN_RECEIVE_BLOCK_SIZE, + OID_GEN_TRANSMIT_BLOCK_SIZE, + OID_GEN_VENDOR_ID, + OID_GEN_VENDOR_DESCRIPTION, + OID_GEN_VENDOR_DRIVER_VERSION, + OID_GEN_CURRENT_PACKET_FILTER, + OID_GEN_CURRENT_LOOKAHEAD, + OID_GEN_DRIVER_VERSION, + OID_GEN_MAXIMUM_TOTAL_SIZE, + OID_GEN_PROTOCOL_OPTIONS, + OID_GEN_MAC_OPTIONS, + OID_GEN_MEDIA_CONNECT_STATUS, + OID_GEN_MAXIMUM_SEND_PACKETS, + OID_GEN_XMIT_OK, + OID_GEN_RCV_OK, + OID_GEN_XMIT_ERROR, + OID_GEN_RCV_ERROR, + OID_GEN_RCV_NO_BUFFER, + OID_GEN_RCV_CRC_ERROR, + OID_802_3_PERMANENT_ADDRESS, + OID_802_3_CURRENT_ADDRESS, + OID_802_3_MULTICAST_LIST, + OID_802_3_MAXIMUM_LIST_SIZE, + OID_802_3_MAC_OPTIONS, + OID_802_3_RCV_ERROR_ALIGNMENT, + OID_802_3_XMIT_ONE_COLLISION, + OID_802_3_XMIT_MORE_COLLISIONS +}; + +NDIS_STATUS +NTAPI +MiniportQueryInformation ( + IN NDIS_HANDLE MiniportAdapterContext, + IN NDIS_OID Oid, + IN PVOID InformationBuffer, + IN ULONG InformationBufferLength, + OUT PULONG BytesWritten, + OUT PULONG BytesNeeded + ) +{ + PRTL_ADAPTER adapter = (PRTL_ADAPTER)MiniportAdapterContext; + ULONG genericUlong; + ULONG copyLength; + PVOID copySource; + NDIS_STATUS status; + + status = NDIS_STATUS_SUCCESS; + copySource = &genericUlong; + copyLength = sizeof(ULONG); + + NdisAcquireSpinLock(&adapter->Lock); + + switch (Oid) + { + case OID_GEN_SUPPORTED_LIST: + copySource = (PVOID)&SupportedOidList; + copyLength = sizeof(SupportedOidList); + break; + + case OID_GEN_CURRENT_PACKET_FILTER: + genericUlong = adapter->PacketFilter; + break; + + case OID_GEN_HARDWARE_STATUS: + genericUlong = (ULONG)NdisHardwareStatusReady; //FIXME + break; + + case OID_GEN_MEDIA_SUPPORTED: + case OID_GEN_MEDIA_IN_USE: + { + static const NDIS_MEDIUM medium = NdisMedium802_3; + copySource = (PVOID)&medium; + copyLength = sizeof(medium); + break; + } + + case OID_GEN_RECEIVE_BLOCK_SIZE: + case OID_GEN_TRANSMIT_BLOCK_SIZE: + case OID_GEN_CURRENT_LOOKAHEAD: + case OID_GEN_MAXIMUM_LOOKAHEAD: + case OID_GEN_MAXIMUM_FRAME_SIZE: + genericUlong = MAXIMUM_FRAME_SIZE - sizeof(ETH_HEADER); + break; + + case OID_GEN_LINK_SPEED: + genericUlong = adapter->LinkSpeedMbps * 1000; + break; + + case OID_GEN_TRANSMIT_BUFFER_SPACE: + genericUlong = MAXIMUM_FRAME_SIZE; + break; + + case OID_GEN_RECEIVE_BUFFER_SPACE: + genericUlong = RECEIVE_BUFFER_SIZE; + break; + + case OID_GEN_VENDOR_ID: + // + // The 3 bytes of the MAC address is the vendor ID + // + genericUlong = 0; + genericUlong |= (adapter->PermanentMacAddress[0] << 16); + genericUlong |= (adapter->PermanentMacAddress[1] << 8); + genericUlong |= (adapter->PermanentMacAddress[2] & 0xFF); + break; + + case OID_GEN_VENDOR_DESCRIPTION: + { + static UCHAR vendorDesc[] = "ReactOS Team"; + copySource = vendorDesc; + copyLength = sizeof(vendorDesc); + break; + } + + case OID_GEN_VENDOR_DRIVER_VERSION: + genericUlong = DRIVER_VERSION; + break; + + case OID_GEN_DRIVER_VERSION: + { + static const USHORT driverVersion = + (NDIS_MINIPORT_MAJOR_VERSION << 8) + NDIS_MINIPORT_MINOR_VERSION; + copySource = (PVOID)&driverVersion; + copyLength = sizeof(driverVersion); + break; + } + + case OID_GEN_MAXIMUM_TOTAL_SIZE: + genericUlong = MAXIMUM_FRAME_SIZE; + break; + + case OID_GEN_PROTOCOL_OPTIONS: + NDIS_DbgPrint(MIN_TRACE, ("OID_GEN_PROTOCOL_OPTIONS is unimplemented\n")); + status = NDIS_STATUS_NOT_SUPPORTED; + break; + + case OID_GEN_MAC_OPTIONS: + genericUlong = NDIS_MAC_OPTION_RECEIVE_SERIALIZED | + NDIS_MAC_OPTION_COPY_LOOKAHEAD_DATA | + NDIS_MAC_OPTION_TRANSFERS_NOT_PEND | + NDIS_MAC_OPTION_NO_LOOPBACK; + break; + + case OID_GEN_MEDIA_CONNECT_STATUS: + genericUlong = adapter->MediaState; + break; + + case OID_GEN_MAXIMUM_SEND_PACKETS: + genericUlong = 1; + break; + + case OID_802_3_CURRENT_ADDRESS: + copySource = adapter->CurrentMacAddress; + copyLength = IEEE_802_ADDR_LENGTH; + break; + + case OID_802_3_PERMANENT_ADDRESS: + copySource = adapter->PermanentMacAddress; + copyLength = IEEE_802_ADDR_LENGTH; + break; + + case OID_802_3_MAXIMUM_LIST_SIZE: + genericUlong = MAXIMUM_MULTICAST_ADDRESSES; + break; + + case OID_GEN_XMIT_OK: + genericUlong = adapter->TransmitOk; + break; + + case OID_GEN_RCV_OK: + genericUlong = adapter->ReceiveOk; + break; + + case OID_GEN_XMIT_ERROR: + genericUlong = adapter->TransmitError; + break; + + case OID_GEN_RCV_ERROR: + genericUlong = adapter->ReceiveError; + break; + + case OID_GEN_RCV_NO_BUFFER: + genericUlong = adapter->ReceiveNoBufferSpace; + break; + + case OID_GEN_RCV_CRC_ERROR: + genericUlong = adapter->ReceiveCrcError; + break; + + case OID_802_3_RCV_ERROR_ALIGNMENT: + genericUlong = adapter->ReceiveAlignmentError; + break; + + case OID_802_3_XMIT_ONE_COLLISION: + genericUlong = adapter->TransmitOneCollision; + break; + + case OID_802_3_XMIT_MORE_COLLISIONS: + genericUlong = adapter->TransmitMoreCollisions; + break; + + default: + NDIS_DbgPrint(MIN_TRACE, ("Unknown OID\n")); + status = NDIS_STATUS_NOT_SUPPORTED; + break; + } + + if (status == NDIS_STATUS_SUCCESS) + { + if (copyLength > InformationBufferLength) + { + *BytesNeeded = copyLength; + *BytesWritten = 0; + status = NDIS_STATUS_INVALID_LENGTH; + } + else + { + NdisMoveMemory(InformationBuffer, copySource, copyLength); + *BytesWritten = copyLength; + *BytesNeeded = copyLength; + } + } + else + { + *BytesWritten = 0; + *BytesNeeded = 0; + } + + NdisReleaseSpinLock(&adapter->Lock); + + NDIS_DbgPrint(MAX_TRACE, ("Query OID 0x%x: Completed with status 0x%x (%d, %d)\n", + Oid, status, *BytesWritten, *BytesNeeded)); + + return status; +} + +NDIS_STATUS +NTAPI +MiniportSetInformation ( + IN NDIS_HANDLE MiniportAdapterContext, + IN NDIS_OID Oid, + IN PVOID InformationBuffer, + IN ULONG InformationBufferLength, + OUT PULONG BytesRead, + OUT PULONG BytesNeeded + ) +{ + PRTL_ADAPTER adapter = (PRTL_ADAPTER)MiniportAdapterContext; + ULONG genericUlong; + NDIS_STATUS status; + + status = NDIS_STATUS_SUCCESS; + + NdisAcquireSpinLock(&adapter->Lock); + + switch (Oid) + { + case OID_GEN_CURRENT_PACKET_FILTER: + if (InformationBufferLength < sizeof(ULONG)) + { + *BytesRead = 0; + *BytesNeeded = sizeof(ULONG); + status = NDIS_STATUS_INVALID_LENGTH; + break; + } + + NdisMoveMemory(&genericUlong, InformationBuffer, sizeof(ULONG)); + + if (genericUlong & + (NDIS_PACKET_TYPE_ALL_FUNCTIONAL | + NDIS_PACKET_TYPE_FUNCTIONAL | + NDIS_PACKET_TYPE_GROUP | + NDIS_PACKET_TYPE_MAC_FRAME | + NDIS_PACKET_TYPE_SMT | + NDIS_PACKET_TYPE_SOURCE_ROUTING)) + { + *BytesRead = sizeof(ULONG); + *BytesNeeded = sizeof(ULONG); + status = NDIS_STATUS_NOT_SUPPORTED; + break; + } + + adapter->PacketFilter = genericUlong; + + status = NICApplyPacketFilter(adapter); + if (status != NDIS_STATUS_SUCCESS) + { + NDIS_DbgPrint(MIN_TRACE, ("Failed to apply new packet filter\n")); + break; + } + + break; + + case OID_GEN_CURRENT_LOOKAHEAD: + if (InformationBufferLength < sizeof(ULONG)) + { + *BytesRead = 0; + *BytesNeeded = sizeof(ULONG); + status = NDIS_STATUS_INVALID_LENGTH; + break; + } + + NdisMoveMemory(&genericUlong, InformationBuffer, sizeof(ULONG)); + + if (genericUlong > MAXIMUM_FRAME_SIZE - sizeof(ETH_HEADER)) + { + status = NDIS_STATUS_INVALID_DATA; + } + else + { + // Ignore this... + } + + break; + + case OID_802_3_MULTICAST_LIST: + if (InformationBufferLength % IEEE_802_ADDR_LENGTH) + { + *BytesRead = 0; + *BytesNeeded = InformationBufferLength + (InformationBufferLength % IEEE_802_ADDR_LENGTH); + status = NDIS_STATUS_INVALID_LENGTH; + break; + } + + if (InformationBufferLength / 6 > MAXIMUM_MULTICAST_ADDRESSES) + { + *BytesNeeded = MAXIMUM_MULTICAST_ADDRESSES * IEEE_802_ADDR_LENGTH; + *BytesRead = 0; + status = NDIS_STATUS_INVALID_LENGTH; + break; + } + + NdisMoveMemory(adapter->MulticastList, InformationBuffer, InformationBufferLength); + + // FIXME: Write to device + + break; + + default: + NDIS_DbgPrint(MIN_TRACE, ("Unknown OID\n")); + status = NDIS_STATUS_NOT_SUPPORTED; + *BytesRead = 0; + *BytesNeeded = 0; + break; + } + + if (status == NDIS_STATUS_SUCCESS) + { + *BytesRead = InformationBufferLength; + *BytesNeeded = 0; + } + + NdisReleaseSpinLock(&adapter->Lock); + + return status; +} + Propchange: trunk/reactos/drivers/network/dd/rtl8139/info.c ------------------------------------------------------------------------------ svn:eol-style = native Added: trunk/reactos/drivers/network/dd/rtl8139/interrupt.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/dd/rtl8139…
============================================================================== --- trunk/reactos/drivers/network/dd/rtl8139/interrupt.c (added) +++ trunk/reactos/drivers/network/dd/rtl8139/interrupt.c [iso-8859-1] Fri Jul 5 04:18:32 2013 @@ -0,0 +1,210 @@ +/* + * ReactOS Realtek 8139 Driver + * + * Copyright (C) 2013 Cameron Gutman + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + */ + +#include "nic.h" + +#define NDEBUG +#include <debug.h> + +VOID +NTAPI +MiniportISR ( + OUT PBOOLEAN InterruptRecognized, + OUT PBOOLEAN QueueMiniportHandleInterrupt, + IN NDIS_HANDLE MiniportAdapterContext + ) +{ + PRTL_ADAPTER adapter = (PRTL_ADAPTER)MiniportAdapterContext; + ULONG csConfig; + + // + // FIXME: We need to synchronize with this ISR for changes to InterruptPending, + // LinkChange, MediaState, and LinkSpeedMbps. We can get away with IRQL + // synchronization on non-SMP machines because we run a DIRQL here. + // + + adapter->InterruptPending |= NICInterruptRecognized(adapter, InterruptRecognized); + if (!(*InterruptRecognized)) + { + // + // This is not ours. + // + *QueueMiniportHandleInterrupt = FALSE; + return; + } + + // + // We have to check for a special link change interrupt before acknowledging + // + if (adapter->InterruptPending & R_I_RXUNDRUN) + { + NdisRawReadPortUlong(adapter->IoBase + R_CSCFG, &csConfig); + if (csConfig & R_CSCR_LINKCHNG) + { + adapter->LinkChange = TRUE; + NICUpdateLinkStatus(adapter); + } + } + + // + // Acknowledge the interrupt and mark the events pending service + // + NICAcknowledgeInterrupts(adapter); + *QueueMiniportHandleInterrupt = TRUE; +} + +VOID +NTAPI +MiniportHandleInterrupt ( + IN NDIS_HANDLE MiniportAdapterContext + ) +{ + PRTL_ADAPTER adapter = (PRTL_ADAPTER)MiniportAdapterContext; + ULONG i; + ULONG txStatus; + UCHAR command; + PPACKET_HEADER nicHeader; + PETH_HEADER ethHeader; + + NdisDprAcquireSpinLock(&adapter->Lock); + + NDIS_DbgPrint(MAX_TRACE, ("Interrupts pending: 0x%x\n", adapter->InterruptPending)); + + // + // Handle a link change + // + if (adapter->LinkChange) + { + NdisDprReleaseSpinLock(&adapter->Lock); + NdisMIndicateStatus(adapter->MiniportAdapterHandle, + adapter->MediaState == NdisMediaStateConnected ? + NDIS_STATUS_MEDIA_CONNECT : NDIS_STATUS_MEDIA_DISCONNECT, + NULL, + 0); + NdisMIndicateStatusComplete(adapter->MiniportAdapterHandle); + NdisDprAcquireSpinLock(&adapter->Lock); + adapter->LinkChange = FALSE; + } + + // + // Handle a TX interrupt + // + if (adapter->InterruptPending & (R_I_TXOK | R_I_TXERR)) + { + while (adapter->TxFull || adapter->DirtyTxDesc != adapter->CurrentTxDesc) + { + NdisRawReadPortUlong(adapter->IoBase + R_TXSTS0 + + (adapter->DirtyTxDesc * sizeof(ULONG)), &txStatus); + + if (!(txStatus & (R_TXS_STATOK | R_TXS_UNDERRUN | R_TXS_ABORTED))) + { + // + // Not sent yet + // + break; + } + + NDIS_DbgPrint(MAX_TRACE, ("Transmission for desc %d complete: 0x%x\n", + adapter->DirtyTxDesc, txStatus)); + + if (txStatus & R_TXS_STATOK) + { + adapter->TransmitOk++; + } + else + { + adapter->TransmitError++; + } + + adapter->DirtyTxDesc++; + adapter->DirtyTxDesc %= TX_DESC_COUNT; + adapter->InterruptPending &= ~(R_I_TXOK | R_I_TXERR); + adapter->TxFull = FALSE; + } + } + + // + // Handle a good RX interrupt + // + if (adapter->InterruptPending & (R_I_RXOK | R_I_RXERR)) + { + for (i = 0; i < MAX_RECEIVES_PER_INT; i++) + { + NdisRawReadPortUchar(adapter->IoBase + R_CMD, &command); + if (command & R_CMD_RXEMPTY) + { + // + // The buffer is empty + // + adapter->InterruptPending &= ~(R_I_RXOK | R_I_RXERR); + break; + } + + adapter->ReceiveOffset %= RECEIVE_BUFFER_SIZE; + + NDIS_DbgPrint(MAX_TRACE, ("Looking for a packet at offset 0x%x\n", + adapter->ReceiveOffset)); + nicHeader = (PPACKET_HEADER)(adapter->ReceiveBuffer + adapter->ReceiveOffset); + if (!(nicHeader->Status & RSR_ROK)) + { + // + // Receive failed + // + NDIS_DbgPrint(MIN_TRACE, ("Receive failed: 0x%x\n", nicHeader->Status)); + + if (nicHeader->Status & RSR_FAE) + { + adapter->ReceiveAlignmentError++; + } + else if (nicHeader->Status & RSR_CRC) + { + adapter->ReceiveCrcError++; + } + adapter->ReceiveError++; + + goto NextPacket; + } + + NDIS_DbgPrint(MAX_TRACE, ("Indicating %d byte packet to NDIS\n", + nicHeader->PacketLength - RECV_CRC_LENGTH)); + + ethHeader = (PETH_HEADER)(nicHeader + 1); + NdisMEthIndicateReceive(adapter->MiniportAdapterHandle, + NULL, + (PVOID)(ethHeader), + sizeof(ETH_HEADER), + (PVOID)(ethHeader + 1), + nicHeader->PacketLength - sizeof(ETH_HEADER) - RECV_CRC_LENGTH, + nicHeader->PacketLength - sizeof(ETH_HEADER) - RECV_CRC_LENGTH); + adapter->ReceiveOk++; + + NextPacket: + adapter->ReceiveOffset += nicHeader->PacketLength + sizeof(PACKET_HEADER); + adapter->ReceiveOffset = (adapter->ReceiveOffset + 3) & ~3; + NdisRawWritePortUshort(adapter->IoBase + R_CAPR, adapter->ReceiveOffset - 0x10); + } + + NdisMEthIndicateReceiveComplete(adapter->MiniportAdapterHandle); + } + + NdisDprReleaseSpinLock(&adapter->Lock); +} + Propchange: trunk/reactos/drivers/network/dd/rtl8139/interrupt.c ------------------------------------------------------------------------------ svn:eol-style = native Added: trunk/reactos/drivers/network/dd/rtl8139/ndis.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/dd/rtl8139…
============================================================================== --- trunk/reactos/drivers/network/dd/rtl8139/ndis.c (added) +++ trunk/reactos/drivers/network/dd/rtl8139/ndis.c [iso-8859-1] Fri Jul 5 04:18:32 2013 @@ -0,0 +1,525 @@ +/* + * ReactOS Realtek 8139 Driver + * + * Copyright (C) 2013 Cameron Gutman + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + */ + +#include "nic.h" + +#define NDEBUG +#include <debug.h> + +ULONG DebugTraceLevel = MIN_TRACE; + +NDIS_STATUS +NTAPI +MiniportReset ( + OUT PBOOLEAN AddressingReset, + IN NDIS_HANDLE MiniportAdapterContext + ) +{ + *AddressingReset = FALSE; + return NDIS_STATUS_FAILURE; +} + +NDIS_STATUS +NTAPI +MiniportSend ( + IN NDIS_HANDLE MiniportAdapterContext, + IN PNDIS_PACKET Packet, + IN UINT Flags + ) +{ + PRTL_ADAPTER adapter = (PRTL_ADAPTER)MiniportAdapterContext; + NDIS_STATUS status; + PSCATTER_GATHER_LIST sgList = NDIS_PER_PACKET_INFO_FROM_PACKET(Packet, + ScatterGatherListPacketInfo); + ULONG transmitLength; + ULONG transmitBuffer; + PNDIS_BUFFER firstBuffer; + PVOID firstBufferVa; + UINT firstBufferLength, totalBufferLength; + PUCHAR runtBuffer; + + ASSERT(sgList != NULL); + + ASSERT(sgList->NumberOfElements == 1); + ASSERT(sgList->Elements[0].Address.HighPart == 0); + ASSERT((sgList->Elements[0].Address.LowPart & 3) == 0); + ASSERT(sgList->Elements[0].Length <= MAXIMUM_FRAME_SIZE); + + NDIS_DbgPrint(MAX_TRACE, ("Sending %d byte packet\n", sgList->Elements[0].Length)); + + NdisAcquireSpinLock(&adapter->Lock); + + if (adapter->TxFull) + { + NDIS_DbgPrint(MIN_TRACE, ("All TX descriptors are full\n")); + NdisReleaseSpinLock(&adapter->Lock); + return NDIS_STATUS_RESOURCES; + } + + NDIS_DbgPrint(MAX_TRACE, ("Sending packet on TX desc %d\n", adapter->CurrentTxDesc)); + + // + // If this is a runt, we need to pad it manually for the RTL8139 + // + if (sgList->Elements[0].Length < MINIMUM_FRAME_SIZE) + { + transmitLength = MINIMUM_FRAME_SIZE; + transmitBuffer = adapter->RuntTxBuffersPa.LowPart + + (MINIMUM_FRAME_SIZE * adapter->CurrentTxDesc); + + NdisGetFirstBufferFromPacketSafe(Packet, + &firstBuffer, + &firstBufferVa, + &firstBufferLength, + &totalBufferLength, + NormalPagePriority); + if (firstBufferVa == NULL) + { + NDIS_DbgPrint(MIN_TRACE, ("Unable to get buffer from packet\n")); + NdisReleaseSpinLock(&adapter->Lock); + return NDIS_STATUS_RESOURCES; + } + + ASSERT(firstBufferLength == totalBufferLength); + + runtBuffer = adapter->RuntTxBuffers + (MINIMUM_FRAME_SIZE * adapter->CurrentTxDesc); + RtlCopyMemory(runtBuffer, firstBufferVa, firstBufferLength); + RtlFillMemory(runtBuffer + firstBufferLength, MINIMUM_FRAME_SIZE - firstBufferLength, 0x00); + } + else + { + transmitLength = sgList->Elements[0].Length; + transmitBuffer = sgList->Elements[0].Address.LowPart; + } + + status = NICTransmitPacket(adapter, adapter->CurrentTxDesc, transmitBuffer, transmitLength); + if (status != NDIS_STATUS_SUCCESS) + { + NDIS_DbgPrint(MIN_TRACE, ("Transmit packet failed\n")); + NdisReleaseSpinLock(&adapter->Lock); + return status; + } + + adapter->CurrentTxDesc++; + adapter->CurrentTxDesc %= TX_DESC_COUNT; + + if (adapter->CurrentTxDesc == adapter->DirtyTxDesc) + { + NDIS_DbgPrint(MID_TRACE, ("All TX descriptors are full now\n")); + adapter->TxFull = TRUE; + } + + NdisReleaseSpinLock(&adapter->Lock); + + return NDIS_STATUS_SUCCESS; +} + +VOID +NTAPI +MiniportHalt ( + IN NDIS_HANDLE MiniportAdapterContext + ) +{ + PRTL_ADAPTER adapter = (PRTL_ADAPTER)MiniportAdapterContext; + + ASSERT(adapter != NULL); + + // + // Interrupts need to stop first + // + if (adapter->InterruptRegistered != FALSE) + { + NdisMDeregisterInterrupt(&adapter->Interrupt); + } + + // + // If we have a mapped IO port range, we can talk to the NIC + // + if (adapter->IoBase != NULL) + { + if (adapter->ReceiveBuffer != NULL) + { + // + // Disassociate our shared buffer before freeing it to avoid + // NIC-induced memory corruption + // + NICRemoveReceiveBuffer(adapter); + + NdisMFreeSharedMemory(adapter->MiniportAdapterHandle, + adapter->ReceiveBufferLength, + FALSE, + adapter->ReceiveBuffer, + adapter->ReceiveBufferPa); + } + + if (adapter->RuntTxBuffers != NULL) + { + NdisMFreeSharedMemory(adapter->MiniportAdapterHandle, + MINIMUM_FRAME_SIZE * TX_DESC_COUNT, + FALSE, + adapter->RuntTxBuffers, + adapter->RuntTxBuffersPa); + } + + // + // Unregister the IO range + // + NdisMDeregisterIoPortRange(adapter->MiniportAdapterHandle, + adapter->IoRangeStart, + adapter->IoRangeLength, + adapter->IoBase); + } + + // + // Destroy the adapter context + // + NdisFreeMemory(adapter, sizeof(*adapter), 0); +} + +NDIS_STATUS +NTAPI +MiniportInitialize ( + OUT PNDIS_STATUS OpenErrorStatus, + OUT PUINT SelectedMediumIndex, + IN PNDIS_MEDIUM MediumArray, + IN UINT MediumArraySize, + IN NDIS_HANDLE MiniportAdapterHandle, + IN NDIS_HANDLE WrapperConfigurationContext + ) +{ + PRTL_ADAPTER adapter; + NDIS_STATUS status; + UINT i; + PNDIS_RESOURCE_LIST resourceList; + UINT resourceListSize; + + // + // Make sure the medium is supported + // + for (i = 0; i < MediumArraySize; i++) + { + if (MediumArray[i] == NdisMedium802_3) + { + *SelectedMediumIndex = i; + break; + } + } + + if (i == MediumArraySize) + { + NDIS_DbgPrint(MIN_TRACE, ("802.3 medium was not found in the medium array\n")); + return NDIS_STATUS_UNSUPPORTED_MEDIA; + } + + // + // Allocate our adapter context + // + status = NdisAllocateMemoryWithTag((PVOID*)&adapter, + sizeof(*adapter), + ADAPTER_TAG); + if (status != NDIS_STATUS_SUCCESS) + { + NDIS_DbgPrint(MIN_TRACE, ("Failed to allocate adapter context\n")); + return NDIS_STATUS_RESOURCES; + } + + RtlZeroMemory(adapter, sizeof(*adapter)); + adapter->MiniportAdapterHandle = MiniportAdapterHandle; + NdisAllocateSpinLock(&adapter->Lock); + + // + // Notify NDIS of some characteristics of our NIC + // + NdisMSetAttributesEx(MiniportAdapterHandle, + adapter, + 0, + NDIS_ATTRIBUTE_BUS_MASTER, + NdisInterfacePci); + + // + // Get our resources for IRQ and IO base information + // + resourceList = NULL; + resourceListSize = 0; + NdisMQueryAdapterResources(&status, + WrapperConfigurationContext, + resourceList, + &resourceListSize); + if (status != NDIS_STATUS_RESOURCES) + { + NDIS_DbgPrint(MIN_TRACE, ("Unexpected failure of NdisMQueryAdapterResources #1\n")); + status = NDIS_STATUS_FAILURE; + goto Cleanup; + } + + status = NdisAllocateMemoryWithTag((PVOID*)&resourceList, + resourceListSize, + RESOURCE_LIST_TAG); + if (status != NDIS_STATUS_SUCCESS) + { + NDIS_DbgPrint(MIN_TRACE, ("Failed to allocate resource list\n")); + goto Cleanup; + } + + NdisMQueryAdapterResources(&status, + WrapperConfigurationContext, + resourceList, + &resourceListSize); + if (status != NDIS_STATUS_SUCCESS) + { + NDIS_DbgPrint(MIN_TRACE, ("Unexpected failure of NdisMQueryAdapterResources #2\n")); + goto Cleanup; + } + + ASSERT(resourceList->Version == 1); + ASSERT(resourceList->Revision == 1); + + for (i = 0; i < resourceList->Count; i++) + { + switch (resourceList->PartialDescriptors[i].Type) + { + case CmResourceTypePort: + ASSERT(adapter->IoRangeStart == 0); + + ASSERT(resourceList->PartialDescriptors[i].u.Port.Start.HighPart == 0); + + adapter->IoRangeStart = resourceList->PartialDescriptors[i].u.Port.Start.LowPart; + adapter->IoRangeLength = resourceList->PartialDescriptors[i].u.Port.Length; + + NDIS_DbgPrint(MID_TRACE, ("I/O port range is %p to %p\n", + adapter->IoRangeStart, adapter->IoRangeStart + adapter->IoRangeLength)); + break; + + case CmResourceTypeInterrupt: + ASSERT(adapter->InterruptVector == 0); + ASSERT(adapter->InterruptLevel == 0); + + adapter->InterruptVector = resourceList->PartialDescriptors[i].u.Interrupt.Vector; + adapter->InterruptLevel = resourceList->PartialDescriptors[i].u.Interrupt.Level; + adapter->InterruptShared = (resourceList->PartialDescriptors[i].ShareDisposition == CmResourceShareShared); + adapter->InterruptFlags = resourceList->PartialDescriptors[i].Flags; + + NDIS_DbgPrint(MID_TRACE, ("IRQ vector is %d\n", adapter->InterruptVector)); + break; + + default: + NDIS_DbgPrint(MIN_TRACE, ("Unrecognized resource type: 0x%x\n", resourceList->PartialDescriptors[i].Type)); + break; + } + } + + NdisFreeMemory(resourceList, resourceListSize, 0); + resourceList = NULL; + + if (adapter->IoRangeStart == 0 || adapter->InterruptVector == 0) + { + NDIS_DbgPrint(MIN_TRACE, ("Adapter didn't receive enough resources\n")); + goto Cleanup; + } + + // + // Allocate the DMA resources + // + status = NdisMInitializeScatterGatherDma(MiniportAdapterHandle, + FALSE, // RTL8139 only supports 32-bit addresses + MAXIMUM_FRAME_SIZE); + if (status != NDIS_STATUS_SUCCESS) + { + NDIS_DbgPrint(MIN_TRACE, ("Unable to configure DMA\n")); + goto Cleanup; + } + + adapter->ReceiveBufferLength = FULL_RECEIVE_BUFFER_SIZE; + NdisMAllocateSharedMemory(MiniportAdapterHandle, + adapter->ReceiveBufferLength, + FALSE, + (PVOID*)&adapter->ReceiveBuffer, + &adapter->ReceiveBufferPa); + if (adapter->ReceiveBuffer == NULL) + { + NDIS_DbgPrint(MIN_TRACE, ("Unable to allocate receive buffer\n")); + goto Cleanup; + } + + NdisMAllocateSharedMemory(MiniportAdapterHandle, + MINIMUM_FRAME_SIZE * TX_DESC_COUNT, + FALSE, + (PVOID*)&adapter->RuntTxBuffers, + &adapter->RuntTxBuffersPa); + if (adapter->RuntTxBuffers == NULL) + { + NDIS_DbgPrint(MIN_TRACE, ("Unable to allocate runt TX buffer\n")); + goto Cleanup; + } + + // + // Register the I/O port range and configure the NIC + // + status = NdisMRegisterIoPortRange((PVOID*)&adapter->IoBase, + MiniportAdapterHandle, + adapter->IoRangeStart, + adapter->IoRangeLength); + if (status != NDIS_STATUS_SUCCESS) + { + NDIS_DbgPrint(MIN_TRACE, ("Unable to register IO port range (0x%x)\n", status)); + goto Cleanup; + } + + // + // Adapter setup + // + status = NICPowerOn(adapter); + if (status != NDIS_STATUS_SUCCESS) + { + NDIS_DbgPrint(MIN_TRACE, ("Unable to power on NIC (0x%x)\n", status)); + goto Cleanup; + } + + status = NICSoftReset(adapter); + if (status != NDIS_STATUS_SUCCESS) + { + NDIS_DbgPrint(MIN_TRACE, ("Unable to reset the NIC (0x%x)\n", status)); + goto Cleanup; + } + + status = NICGetPermanentMacAddress(adapter, adapter->PermanentMacAddress); + if (status != NDIS_STATUS_SUCCESS) + { + NDIS_DbgPrint(MIN_TRACE, ("Unable to get the fixed MAC address (0x%x)\n", status)); + goto Cleanup; + } + + RtlCopyMemory(adapter->CurrentMacAddress, adapter->PermanentMacAddress, IEEE_802_ADDR_LENGTH); + + // + // Update link state and speed + // + NICUpdateLinkStatus(adapter); + + status = NICRegisterReceiveBuffer(adapter); + if (status != NDIS_STATUS_SUCCESS) + { + NDIS_DbgPrint(MIN_TRACE, ("Unable to setup receive buffer (0x%x)\n", status)); + goto Cleanup; + } + + // + // We're ready to handle interrupts now + // + status = NdisMRegisterInterrupt(&adapter->Interrupt, + MiniportAdapterHandle, + adapter->InterruptVector, + adapter->InterruptLevel, + TRUE, // We always want ISR calls + adapter->InterruptShared, + (adapter->InterruptFlags & CM_RESOURCE_INTERRUPT_LATCHED) ? + NdisInterruptLatched : NdisInterruptLevelSensitive); + if (status != NDIS_STATUS_SUCCESS) + { + NDIS_DbgPrint(MIN_TRACE, ("Unable to register interrupt (0x%x)\n", status)); + goto Cleanup; + } + + adapter->InterruptRegistered = TRUE; + + // + // Enable interrupts on the NIC + // + adapter->InterruptMask = DEFAULT_INTERRUPT_MASK; + status = NICApplyInterruptMask(adapter); + if (status != NDIS_STATUS_SUCCESS) + { + NDIS_DbgPrint(MIN_TRACE, ("Unable to apply interrupt mask (0x%x)\n", status)); + goto Cleanup; + } + + // + // Turn on TX and RX now + // + status = NICEnableTxRx(adapter); + if (status != NDIS_STATUS_SUCCESS) + { + NDIS_DbgPrint(MIN_TRACE, ("Unable to enable TX and RX (0x%x)\n", status)); + goto Cleanup; + } + + return NDIS_STATUS_SUCCESS; + +Cleanup: + if (resourceList != NULL) + { + NdisFreeMemory(resourceList, resourceListSize, 0); + } + if (adapter != NULL) + { + MiniportHalt(adapter); + } + + return status; +} + +NTSTATUS +NTAPI +DriverEntry ( + IN PDRIVER_OBJECT DriverObject, + IN PUNICODE_STRING RegistryPath + ) +{ + NDIS_HANDLE wrapperHandle; + NDIS_MINIPORT_CHARACTERISTICS characteristics; + NDIS_STATUS status; + + RtlZeroMemory(&characteristics, sizeof(characteristics)); + characteristics.MajorNdisVersion = NDIS_MINIPORT_MAJOR_VERSION; + characteristics.MinorNdisVersion = NDIS_MINIPORT_MINOR_VERSION; + characteristics.CheckForHangHandler = NULL; + characteristics.DisableInterruptHandler = NULL; + characteristics.EnableInterruptHandler = NULL; + characteristics.HaltHandler = MiniportHalt; + characteristics.HandleInterruptHandler = MiniportHandleInterrupt; + characteristics.InitializeHandler = MiniportInitialize; + characteristics.ISRHandler = MiniportISR; + characteristics.QueryInformationHandler = MiniportQueryInformation; + characteristics.ReconfigureHandler = NULL; + characteristics.ResetHandler = MiniportReset; + characteristics.SendHandler = MiniportSend; + characteristics.SetInformationHandler = MiniportSetInformation; + characteristics.TransferDataHandler = NULL; + characteristics.ReturnPacketHandler = NULL; + characteristics.SendPacketsHandler = NULL; + characteristics.AllocateCompleteHandler = NULL; + + NdisMInitializeWrapper(&wrapperHandle, DriverObject, RegistryPath, NULL); + if (!wrapperHandle) + { + return NDIS_STATUS_FAILURE; + } + + status = NdisMRegisterMiniport(wrapperHandle, &characteristics, sizeof(characteristics)); + if (status != NDIS_STATUS_SUCCESS) + { + NdisTerminateWrapper(wrapperHandle, 0); + return NDIS_STATUS_FAILURE; + } + + return NDIS_STATUS_SUCCESS; +} + Propchange: trunk/reactos/drivers/network/dd/rtl8139/ndis.c ------------------------------------------------------------------------------ svn:eol-style = native Added: trunk/reactos/drivers/network/dd/rtl8139/nic.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/dd/rtl8139…
============================================================================== --- trunk/reactos/drivers/network/dd/rtl8139/nic.h (added) +++ trunk/reactos/drivers/network/dd/rtl8139/nic.h [iso-8859-1] Fri Jul 5 04:18:32 2013 @@ -0,0 +1,204 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS Realtek 8139 driver + * FILE: rtl8139.h + * PURPOSE: RTL8139 driver definitions + */ + +#include <ndis.h> +#include <rtlhw.h> + +#define ADAPTER_TAG 'Altr' +#define RESOURCE_LIST_TAG 'Rltr' + +#define MAX_RESET_ATTEMPTS 25 +#define MAX_RECEIVES_PER_INT 10 +#define RECEIVE_BUFFER_SIZE (32768) +#define FULL_RECEIVE_BUFFER_SIZE (32768 + 16 + 2048) +#define RECV_CRC_LENGTH 4 + +#define MINIMUM_FRAME_SIZE 60 +#define MAXIMUM_FRAME_SIZE 1514 + +#define DRIVER_VERSION 1 + +// 32K RX buffer, 512 byte DMA bursts +#define RC_VAL (0x0001680) + +// 1024 byte DMA bursts +#define TC_VAL (0x600) + +typedef struct _RTL_ADAPTER { + NDIS_HANDLE MiniportAdapterHandle; + NDIS_SPIN_LOCK Lock; + + ULONG IoRangeStart; + ULONG IoRangeLength; + + ULONG InterruptVector; + ULONG InterruptLevel; + BOOLEAN InterruptShared; + ULONG InterruptFlags; + + PUCHAR IoBase; + NDIS_MINIPORT_INTERRUPT Interrupt; + BOOLEAN InterruptRegistered; + + UCHAR PermanentMacAddress[IEEE_802_ADDR_LENGTH]; + UCHAR CurrentMacAddress[IEEE_802_ADDR_LENGTH]; + struct { + UCHAR MacAddress[IEEE_802_ADDR_LENGTH]; + } MulticastList[MAXIMUM_MULTICAST_ADDRESSES]; + + ULONG ReceiveBufferLength; + PUCHAR ReceiveBuffer; + NDIS_PHYSICAL_ADDRESS ReceiveBufferPa; + USHORT ReceiveOffset; + + ULONG LinkSpeedMbps; + ULONG MediaState; + BOOLEAN LinkChange; + + ULONG PacketFilter; + + USHORT InterruptMask; + USHORT InterruptPending; + + UCHAR DirtyTxDesc; + UCHAR CurrentTxDesc; + BOOLEAN TxFull; + PUCHAR RuntTxBuffers; + NDIS_PHYSICAL_ADDRESS RuntTxBuffersPa; + + ULONG ReceiveOk; + ULONG TransmitOk; + ULONG ReceiveError; + ULONG TransmitError; + ULONG ReceiveNoBufferSpace; + ULONG ReceiveCrcError; + ULONG ReceiveAlignmentError; + ULONG TransmitOneCollision; + ULONG TransmitMoreCollisions; + +} RTL_ADAPTER, *PRTL_ADAPTER; + +NDIS_STATUS +NTAPI +NICPowerOn ( + IN PRTL_ADAPTER Adapter + ); + +NDIS_STATUS +NTAPI +NICSoftReset ( + IN PRTL_ADAPTER Adapter + ); + +NDIS_STATUS +NTAPI +NICRegisterReceiveBuffer ( + IN PRTL_ADAPTER Adapter + ); + +NDIS_STATUS +NTAPI +NICRemoveReceiveBuffer ( + IN PRTL_ADAPTER Adapter + ); + +NDIS_STATUS +NTAPI +NICEnableTxRx ( + IN PRTL_ADAPTER Adapter + ); + +NDIS_STATUS +NTAPI +NICGetPermanentMacAddress ( + IN PRTL_ADAPTER Adapter, + OUT PUCHAR MacAddress + ); + +NDIS_STATUS +NTAPI +NICApplyPacketFilter ( + IN PRTL_ADAPTER Adapter + ); + +NDIS_STATUS +NTAPI +NICApplyInterruptMask ( + IN PRTL_ADAPTER Adapter + ); + +NDIS_STATUS +NTAPI +NICDisableInterrupts ( + IN PRTL_ADAPTER Adapter + ); + +USHORT +NTAPI +NICInterruptRecognized ( + IN PRTL_ADAPTER Adapter, + OUT PBOOLEAN InterruptRecognized + ); + +VOID +NTAPI +NICAcknowledgeInterrupts ( + IN PRTL_ADAPTER Adapter + ); + +VOID +NTAPI +NICUpdateLinkStatus ( + IN PRTL_ADAPTER Adapter + ); + +NDIS_STATUS +NTAPI +NICTransmitPacket ( + IN PRTL_ADAPTER Adapter, + IN UCHAR TxDesc, + IN ULONG PhysicalAddress, + IN ULONG Length + ); + +NDIS_STATUS +NTAPI +MiniportSetInformation ( + IN NDIS_HANDLE MiniportAdapterContext, + IN NDIS_OID Oid, + IN PVOID InformationBuffer, + IN ULONG InformationBufferLength, + OUT PULONG BytesRead, + OUT PULONG BytesNeeded + ); + +NDIS_STATUS +NTAPI +MiniportQueryInformation ( + IN NDIS_HANDLE MiniportAdapterContext, + IN NDIS_OID Oid, + IN PVOID InformationBuffer, + IN ULONG InformationBufferLength, + OUT PULONG BytesWritten, + OUT PULONG BytesNeeded + ); + +VOID +NTAPI +MiniportISR ( + OUT PBOOLEAN InterruptRecognized, + OUT PBOOLEAN QueueMiniportHandleInterrupt, + IN NDIS_HANDLE MiniportAdapterContext + ); + +VOID +NTAPI +MiniportHandleInterrupt ( + IN NDIS_HANDLE MiniportAdapterContext + ); + +/* EOF */ Propchange: trunk/reactos/drivers/network/dd/rtl8139/nic.h ------------------------------------------------------------------------------ svn:eol-style = native Added: trunk/reactos/drivers/network/dd/rtl8139/rtl8139.rc URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/dd/rtl8139…
============================================================================== --- trunk/reactos/drivers/network/dd/rtl8139/rtl8139.rc (added) +++ trunk/reactos/drivers/network/dd/rtl8139/rtl8139.rc [iso-8859-1] Fri Jul 5 04:18:32 2013 @@ -0,0 +1,6 @@ + +#define REACTOS_VERSION_DLL +#define REACTOS_STR_FILE_DESCRIPTION "Realtek 8139 Ethernet Driver\0" +#define REACTOS_STR_INTERNAL_NAME "rtl8139\0" +#define REACTOS_STR_ORIGINAL_FILENAME "rtl8139.sys\0" +#include <reactos/version.rc> Propchange: trunk/reactos/drivers/network/dd/rtl8139/rtl8139.rc ------------------------------------------------------------------------------ svn:eol-style = native Added: trunk/reactos/drivers/network/dd/rtl8139/rtlhw.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/dd/rtl8139…
============================================================================== --- trunk/reactos/drivers/network/dd/rtl8139/rtlhw.h (added) +++ trunk/reactos/drivers/network/dd/rtl8139/rtlhw.h [iso-8859-1] Fri Jul 5 04:18:32 2013 @@ -0,0 +1,169 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS RTL8139 Driver + * FILE: rtlhw.h + * PURPOSE: 8139 NIC definitions + */ + +#pragma once + +#define MAXIMUM_MULTICAST_ADDRESSES 8 +#define DEFAULT_INTERRUPT_MASK (R_I_RXOK | R_I_RXERR | R_I_TXOK | \ + R_I_TXERR | R_I_RXOVRFLW | R_I_RXUNDRUN | \ + R_I_FIFOOVR | R_I_PCSTMOUT | R_I_PCIERR) +#define TX_DESC_COUNT 4 + +//Register addresses +#define R_MAC 0x00 //MAC address uses bytes 0-5, 6 and 7 are reserved +#define R_MCAST0 0x08 //Multicast registers +#define R_MCAST1 0x09 //Multicast registers +#define R_MCAST2 0x0A +#define R_MCAST3 0x0B +#define R_MCAST4 0x0C +#define R_MCAST5 0x0D +#define R_MCAST6 0x0E +#define R_MCAST7 0x0F +#define R_TXSTS0 0x10 //TX status, 0x10-0x13, 4 bytes +#define R_TXSTS1 0x14 +#define R_TXSTS2 0x18 +#define R_TXSTS3 0x1C +#define R_TXSAD0 0x20 //TX start address of descriptor 0 +#define R_TXSAD1 0x24 +#define R_TXSAD2 0x28 +#define R_TXSAD3 0x2C +#define R_RXSA 0x30 //RX buffer start address +#define R_ERXBC 0x34 //Early RX byte count register +#define R_ERXSTS 0x36 //Early RX status register + +#define R_TXS_HOSTOWNS 0x00002000 //Driver still owns the buffer +#define R_TXS_UNDERRUN 0x00004000 //TX underrun +#define R_TXS_STATOK 0x00008000 //Successful TX +#define R_TXS_OOW 0x20000000 //Out of window +#define R_TXS_ABORTED 0x40000000 //TX aborted +#define R_TXS_CARLOST 0x80000000 //Carrier lost + +#define R_CMD 0x37 //Command register +#define R_CMD_RXEMPTY 0x01 //Receive buffer empty +#define B_CMD_TXE 0x04 //Enable TX +#define B_CMD_RXE 0x08 //Enable RX +#define B_CMD_RST 0x10 //Reset bit + +#define R_CAPR 0x38 //Current address of packet read +#define R_CBA 0x3A //Current buffer address +#define R_IM 0x3C //Interrupt mask register +#define R_IS 0x3E //Interrupt status register +#define R_TC 0x40 //Transmit configuration register + +#define R_I_RXOK 0x0001 //Receive OK +#define R_I_RXERR 0x0002 //Receive error +#define R_I_TXOK 0x0004 //Transmit OK +#define R_I_TXERR 0x0008 //Trasmit error +#define R_I_RXOVRFLW 0x0010 //Receive overflow +#define R_I_RXUNDRUN 0x0020 //Receive underrun +#define R_I_FIFOOVR 0x0040 //FIFO overflow +#define R_I_PCSTMOUT 0x4000 //PCS timeout +#define R_I_PCIERR 0x8000 //PCI error + +#define R_RC 0x44 //Receive configuration register +#define B_RC_AAP 0x01 //Accept all packets +#define B_RC_APM 0x02 //Accept packets sent to device MAC +#define B_RC_AM 0x04 //Accept multicast packets +#define B_RC_AB 0x08 //Accept broadcast packets +#define B_RC_AR 0x10 //Accept runt (smaller than 64bytes) packets + +#define R_TCTR 0x48 //Timer counter register +#define R_MPC 0x4C //Missed packet counter +#define R_9346CR 0x50 //93C46 command register +#define R_CFG0 0x51 //Configuration register 0 +#define R_CFG1 0x52 +#define R_TINTR 0x54 //Timer interrupt register +#define R_MS 0x58 //Media status register + +#define R_MS_LINKDWN 0x04 //Link is down +#define R_MS_SPEED_10 0x08 //Media is at 10mbps + +#define R_CFG3 0x59 //Configuration register 3 +#define R_CFG4 0x5A //Configuration register 4 +#define R_MINTS 0x5C //Multiple interrupt select +#define R_PCIID 0x5E //PCI Revision ID = 0x10 +#define R_DTSTS 0x60 //TX status of all descriptors +#define R_BMC 0x62 //Basic mode control register +#define R_BMSTS 0x64 //Basic mode status register +#define R_ANA 0x66 //Auto-negotiation advertisement +#define R_ANLP 0x68 //Auto-negotiation link partner +#define R_ANEX 0x6A //Auto-negotiation expansion +#define R_DCTR 0x6C //Disconnect counter +#define R_FCSCTR 0x6E //False carrier sense counter +#define R_NWT 0x70 //N-way test register +#define R_RXERRCTR 0x72 //RX error counter +#define R_CSCFG 0x74 //CS configuration register + +#define R_CSCR_LINKOK 0x00400 //Link up +#define R_CSCR_LINKCHNG 0x00800 //Link changed + +#define R_PHYP1 0x78 //PHY parameter 1 +#define R_TWP 0x7C //Twister parameter +#define R_PHYP2 0x80 //PHY parameter 2 +#define R_PCRC0 0x84 //Power management CRC for wakeup frame 0 +#define R_PCRC1 0x85 +#define R_PCRC2 0x86 +#define R_PCRC3 0x87 +#define R_PCRC4 0x88 +#define R_PCRC5 0x89 +#define R_PCRC6 0x8A +#define R_PCRC7 0x8B +#define R_WAKE0 0x8C //Power management wakeup frame 0 +#define R_WAKE1 0x94 +#define R_WAKE2 0x9C +#define R_WAKE3 0xA4 +#define R_WAKE4 0xAC +#define R_WAKE5 0xB4 +#define R_WAKE6 0xBC +#define R_WAKE7 0xC4 +#define R_LSBCRC0 0xCC //LSB of the mask byte of wakeup frame 0 within offset 12 to 75 +#define R_LSBCRC1 0xCD +#define R_LSBCRC2 0xCE +#define R_LSBCRC3 0xCF +#define R_LSBCRC4 0xD0 +#define R_LSBCRC5 0xD1 +#define R_LSBCRC6 0xD2 +#define R_LSBCRC7 0xD3 +#define R_CFG5 0xD8 //Configuration register 5 + +//EEPROM Control Bytes +#define EE_DATA_READ 0x01 //Chip data out +#define EE_DATA_WRITE 0x02 //Chip data in +#define EE_SHIFT_CLK 0x04 //Chip shift clock +#define EE_CS 0x08 //Chip select +#define EE_ENB 0x88 //Chip enable + + +//EEPROM Commands +#define EE_READ_CMD 0x06 + +#define RSR_MAR 0x8000 //Mulicast receive +#define RSR_PAM 0x4000 //Physical address match (directed packet) +#define RSR_BAR 0x2000 //Broadcast receive +#define RSR_ISE 0x0020 //Invalid symbol +#define RSR_RUNT 0x0010 //Runt packet +#define RSR_LONG 0x0008 //Long packet +#define RSR_CRC 0x0004 //CRC error +#define RSR_FAE 0x0002 //Frame alignment error +#define RSR_ROK 0x0001 //Receive OK + +/* NIC prepended structure to a received packet */ +typedef struct _PACKET_HEADER { + USHORT Status; /* See RSR_* constants */ + USHORT PacketLength; /* Length of packet NOT including this header */ +} PACKET_HEADER, *PPACKET_HEADER; + +#define IEEE_802_ADDR_LENGTH 6 + +/* Ethernet frame header */ +typedef struct _ETH_HEADER { + UCHAR Destination[IEEE_802_ADDR_LENGTH]; + UCHAR Source[IEEE_802_ADDR_LENGTH]; + USHORT PayloadType; +} ETH_HEADER, *PETH_HEADER; + +/* EOF */ Propchange: trunk/reactos/drivers/network/dd/rtl8139/rtlhw.h ------------------------------------------------------------------------------ svn:eol-style = native Modified: trunk/reactos/media/inf/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/media/inf/CMakeLists.txt?r…
============================================================================== --- trunk/reactos/media/inf/CMakeLists.txt [iso-8859-1] (original) +++ trunk/reactos/media/inf/CMakeLists.txt [iso-8859-1] Fri Jul 5 04:18:32 2013 @@ -27,6 +27,7 @@ NET_NIC.inf netamd.inf netisa.inf + netrtl.inf netrtpnt.inf nettcpip.inf ports.inf Added: trunk/reactos/media/inf/netrtl.inf URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/media/inf/netrtl.inf?rev=5…
============================================================================== Binary file - no diff available. Propchange: trunk/reactos/media/inf/netrtl.inf ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream
11 years, 5 months
1
0
0
0
[cgutman] 59426: [NDIS] - Callers to NdisMInitializeScatterGatherDma always support 32-bit DMA addresses
by cgutman@svn.reactos.org
Author: cgutman Date: Fri Jul 5 04:14:56 2013 New Revision: 59426 URL:
http://svn.reactos.org/svn/reactos?rev=59426&view=rev
Log: [NDIS] - Callers to NdisMInitializeScatterGatherDma always support 32-bit DMA addresses Modified: trunk/reactos/drivers/network/ndis/ndis/io.c Modified: trunk/reactos/drivers/network/ndis/ndis/io.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/ndis/ndis/…
============================================================================== --- trunk/reactos/drivers/network/ndis/ndis/io.c [iso-8859-1] (original) +++ trunk/reactos/drivers/network/ndis/ndis/io.c [iso-8859-1] Fri Jul 5 04:14:56 2013 @@ -1192,7 +1192,7 @@ DeviceDesc.Version = DEVICE_DESCRIPTION_VERSION; DeviceDesc.Master = TRUE; DeviceDesc.ScatterGather = TRUE; - DeviceDesc.Dma32BitAddresses = !Dma64BitAddresses; + DeviceDesc.Dma32BitAddresses = TRUE; // All callers support 32-bit addresses DeviceDesc.Dma64BitAddresses = Dma64BitAddresses; DeviceDesc.BusNumber = Adapter->NdisMiniportBlock.BusNumber; DeviceDesc.InterfaceType = Adapter->NdisMiniportBlock.BusType;
11 years, 5 months
1
0
0
0
[aandrejevic] 59425: [NTVDM] Improve vertical refresh performance. Properly synchronize access to the framebuffer.
by aandrejevic@svn.reactos.org
Author: aandrejevic Date: Fri Jul 5 01:31:50 2013 New Revision: 59425 URL:
http://svn.reactos.org/svn/reactos?rev=59425&view=rev
Log: [NTVDM] Improve vertical refresh performance. Properly synchronize access to the framebuffer. Modified: branches/ntvdm/subsystems/ntvdm/bios.c branches/ntvdm/subsystems/ntvdm/bios.h branches/ntvdm/subsystems/ntvdm/emulator.c branches/ntvdm/subsystems/ntvdm/ntvdm.c Modified: branches/ntvdm/subsystems/ntvdm/bios.c URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/subsystems/ntvdm/bios.c?r…
============================================================================== --- branches/ntvdm/subsystems/ntvdm/bios.c [iso-8859-1] (original) +++ branches/ntvdm/subsystems/ntvdm/bios.c [iso-8859-1] Fri Jul 5 01:31:50 2013 @@ -22,11 +22,16 @@ static BOOLEAN BiosKbdBufferEmpty = TRUE; static DWORD BiosTickCount = 0; static BOOLEAN BiosPassedMidnight = FALSE; -static HANDLE BiosConsoleInput, BiosConsoleOutput; +static HANDLE BiosConsoleInput = INVALID_HANDLE_VALUE; +static HANDLE BiosConsoleOutput = INVALID_HANDLE_VALUE; static BYTE CurrentVideoMode = BIOS_DEFAULT_VIDEO_MODE; static BYTE CurrentVideoPage = 0; static HANDLE ConsoleBuffers[BIOS_MAX_PAGES] = { NULL }; static LPVOID ConsoleFramebuffers[BIOS_MAX_PAGES] = { NULL }; +static HANDLE ConsoleMutexes[BIOS_MAX_PAGES] = { NULL }; +static BOOLEAN VideoNeedsUpdate = TRUE; +static SMALL_RECT UpdateRectangle = { 0, 0, 0, 0 }; +static CONSOLE_SCREEN_BUFFER_INFO BiosSavedBufferInfo; static VIDEO_MODE VideoModes[] = { /* Width | Height | Text | Colors | Gray | Pages | Segment */ @@ -54,14 +59,39 @@ /* PRIVATE FUNCTIONS **********************************************************/ +static INT BiosColorNumberToBits(DWORD Colors) +{ + INT i; + + /* Find the index of the highest-order bit */ + for (i = 31; i >= 0; i--) if (Colors & (1 << i)) break; + + /* Special case for zero */ + if (i == 0) i = 32; + + return i; +} + static COORD BiosVideoAddressToCoord(ULONG Address) { COORD Result = {0, 0}; - - Result.X = ((Address - (VideoModes[CurrentVideoMode].Segment << 4)) >> 1) - % VideoModes[CurrentVideoMode].Width; - Result.Y = ((Address - (VideoModes[CurrentVideoMode].Segment << 4)) >> 1) - / VideoModes[CurrentVideoMode].Width; + INT BitsPerPixel; + DWORD Offset = Address - (VideoModes[CurrentVideoMode].Segment << 4); + + if (VideoModes[CurrentVideoMode].Text) + { + Result.X = (Offset / sizeof(WORD)) % VideoModes[CurrentVideoMode].Width; + Result.Y = (Offset / sizeof(WORD)) / VideoModes[CurrentVideoMode].Width; + } + else + { + BitsPerPixel = BiosColorNumberToBits(VideoModes[CurrentVideoMode].Colors); + + Result.X = ((Offset * 8) / BitsPerPixel) + % VideoModes[CurrentVideoMode].Width; + Result.Y = ((Offset * 8) / BitsPerPixel) + / VideoModes[CurrentVideoMode].Width; + } return Result; } @@ -130,6 +160,7 @@ for (i = 0; i < VideoModes[CurrentVideoMode].Pages; i++) { if (ConsoleBuffers[i] != NULL) CloseHandle(ConsoleBuffers[i]); + if (!VideoModes[CurrentVideoMode].Text) CloseHandle(ConsoleMutexes[i]); } if (VideoModes[ModeNumber].Text) @@ -182,14 +213,7 @@ BitmapInfo->bmiHeader.biHeight = VideoModes[ModeNumber].Height; BitmapInfo->bmiHeader.biPlanes = 1; BitmapInfo->bmiHeader.biCompression = BI_RGB; - - /* Calculate the number of color bits */ - for (i = 31; i >= 0; i--) - { - if (VideoModes[ModeNumber].Colors & (1 << i)) break; - } - if (i == 0) i = 32; - BitmapInfo->bmiHeader.biBitCount = i; + BitmapInfo->bmiHeader.biBitCount = BiosColorNumberToBits(VideoModes[ModeNumber].Colors); /* Calculate the image size */ BitmapInfo->bmiHeader.biSizeImage = BitmapInfo->bmiHeader.biWidth @@ -220,8 +244,9 @@ CONSOLE_GRAPHICS_BUFFER, &GraphicsBufferInfo); - /* Save the framebuffer address */ + /* Save the framebuffer address and mutex */ ConsoleFramebuffers[i] = GraphicsBufferInfo.lpBitMap; + ConsoleMutexes[i] = GraphicsBufferInfo.hMutex; } /* Free the bitmap information */ @@ -244,22 +269,21 @@ inline VOID BiosVerticalRefresh() { - SMALL_RECT Region; - /* Ignore if we're in text mode */ if (VideoModes[CurrentVideoMode].Text) return; - /* Fill the rectangle structure */ - Region.Left = Region.Top = 0; - Region.Right = VideoModes[CurrentVideoMode].Width; - Region.Bottom = VideoModes[CurrentVideoMode].Height; + /* Ignore if there's nothing to update */ + if (!VideoNeedsUpdate) return; /* Redraw the screen */ InvalidateConsoleDIBits(ConsoleBuffers[CurrentVideoPage], - &Region); -} - -BOOLEAN BiosInitialize(HANDLE ConsoleInput, HANDLE ConsoleOutput) + &UpdateRectangle); + + /* Clear the update flag */ + VideoNeedsUpdate = FALSE; +} + +BOOLEAN BiosInitialize() { INT i; WORD Offset = 0; @@ -290,15 +314,41 @@ BiosCode[Offset++] = 0xCF; // iret } - /* Set global console I/O handles */ - BiosConsoleInput = ConsoleInput; - BiosConsoleOutput = ConsoleOutput; - + /* Get the input and output handles to the real console */ + BiosConsoleInput = CreateFile(TEXT("CONIN$"), + GENERIC_READ | GENERIC_WRITE, + FILE_SHARE_READ | FILE_SHARE_WRITE, + NULL, + OPEN_EXISTING, + 0, + NULL); + + BiosConsoleOutput = CreateFile(TEXT("CONOUT$"), + GENERIC_READ | GENERIC_WRITE, + FILE_SHARE_READ | FILE_SHARE_WRITE, + NULL, + OPEN_EXISTING, + 0, + NULL); + + /* Make sure it was successful */ + if ((BiosConsoleInput == INVALID_HANDLE_VALUE) + || (BiosConsoleOutput == INVALID_HANDLE_VALUE)) + { + return FALSE; + } + + /* Save the console screen buffer information */ + if (!GetConsoleScreenBufferInfo(BiosConsoleOutput, &BiosSavedBufferInfo)) + { + return FALSE; + } + /* Set the default video mode */ BiosSetVideoMode(BIOS_DEFAULT_VIDEO_MODE); /* Set the console input mode */ - SetConsoleMode(ConsoleInput, ENABLE_MOUSE_INPUT | ENABLE_PROCESSED_INPUT); + SetConsoleMode(BiosConsoleInput, ENABLE_MOUSE_INPUT | ENABLE_PROCESSED_INPUT); /* Initialize the PIC */ PicWriteCommand(PIC_MASTER_CMD, PIC_ICW1 | PIC_ICW1_ICW4); @@ -325,6 +375,28 @@ PitWriteData(0, 0x00); return TRUE; +} + +VOID BiosCleanup() +{ + INT i; + + /* Restore the old screen buffer */ + SetConsoleActiveScreenBuffer(BiosConsoleOutput); + + /* Restore the screen buffer size */ + SetConsoleScreenBufferSize(BiosConsoleOutput, BiosSavedBufferInfo.dwSize); + + /* Free the buffers */ + for (i = 0; i < VideoModes[CurrentVideoMode].Pages; i++) + { + if (ConsoleBuffers[i] != NULL) CloseHandle(ConsoleBuffers[i]); + if (!VideoModes[CurrentVideoMode].Text) CloseHandle(ConsoleMutexes[i]); + } + + /* Close the console handles */ + if (BiosConsoleInput != INVALID_HANDLE_VALUE) CloseHandle(BiosConsoleInput); + if (BiosConsoleOutput != INVALID_HANDLE_VALUE) CloseHandle(BiosConsoleOutput); } VOID BiosUpdateConsole(ULONG StartAddress, ULONG EndAddress) @@ -367,11 +439,40 @@ } else { + /* Wait for the mutex object */ + WaitForSingleObject(ConsoleMutexes[CurrentVideoPage], INFINITE); + /* Copy the data to the framebuffer */ RtlCopyMemory((LPVOID)((ULONG_PTR)ConsoleFramebuffers[CurrentVideoPage] + StartAddress - BiosGetVideoMemoryStart()), (LPVOID)((ULONG_PTR)BaseAddress + StartAddress), EndAddress - StartAddress); + + /* Release the mutex */ + ReleaseMutex(ConsoleMutexes[CurrentVideoPage]); + + /* Check if this is the first time the rectangle is updated */ + if (!VideoNeedsUpdate) + { + UpdateRectangle.Left = UpdateRectangle.Top = (SHORT)0x7FFF; + UpdateRectangle.Right = UpdateRectangle.Bottom = (SHORT)0x8000; + } + + /* Expand the update rectangle */ + for (i = StartAddress; i < EndAddress; i++) + { + /* Get the coordinates */ + Coordinates = BiosVideoAddressToCoord(i); + + /* Expand the rectangle to include the point */ + UpdateRectangle.Left = min(UpdateRectangle.Left, Coordinates.X); + UpdateRectangle.Right = max(UpdateRectangle.Right, Coordinates.X); + UpdateRectangle.Top = min(UpdateRectangle.Top, Coordinates.Y); + UpdateRectangle.Bottom = max(UpdateRectangle.Bottom, Coordinates.Y); + } + + /* Set the update flag */ + VideoNeedsUpdate = TRUE; } } @@ -415,11 +516,17 @@ } else { + /* Wait for the mutex object */ + WaitForSingleObject(ConsoleMutexes[CurrentVideoPage], INFINITE); + /* Copy the data to the emulator memory */ RtlCopyMemory((LPVOID)((ULONG_PTR)BaseAddress + StartAddress), (LPVOID)((ULONG_PTR)ConsoleFramebuffers[CurrentVideoPage] + StartAddress - BiosGetVideoMemoryStart()), EndAddress - StartAddress); + + /* Release the mutex */ + ReleaseMutex(ConsoleMutexes[CurrentVideoPage]); } } @@ -736,6 +843,12 @@ } } +VOID BiosSystemTimerInterrupt() +{ + /* Increase the system tick count */ + BiosTickCount++; +} + VOID BiosEquipmentService() { /* Return the equipment list */ @@ -749,11 +862,8 @@ /* PIT IRQ */ case 0: { - /* Increase the system tick count */ - BiosTickCount++; - /* Perform the system timer interrupt */ - EmulatorInterrupt(0x1C); + EmulatorInterrupt(BIOS_SYS_TIMER_INTERRUPT); break; } Modified: branches/ntvdm/subsystems/ntvdm/bios.h URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/subsystems/ntvdm/bios.h?r…
============================================================================== --- branches/ntvdm/subsystems/ntvdm/bios.h [iso-8859-1] (original) +++ branches/ntvdm/subsystems/ntvdm/bios.h [iso-8859-1] Fri Jul 5 01:31:50 2013 @@ -25,6 +25,7 @@ #define BIOS_EQUIPMENT_INTERRUPT 0x11 #define BIOS_KBD_INTERRUPT 0x16 #define BIOS_TIME_INTERRUPT 0x1A +#define BIOS_SYS_TIMER_INTERRUPT 0x1C #define CONSOLE_FONT_HEIGHT 8 #define BIOS_KBD_BUFFER_SIZE 256 #define BIOS_EQUIPMENT_LIST 0x3C // HACK: Disable FPU for now @@ -46,6 +47,7 @@ /* FUNCTIONS ******************************************************************/ BOOLEAN BiosInitialize(); +VOID BiosCleanup(); VOID BiosUpdateConsole(ULONG StartAddress, ULONG EndAddress); VOID BiosUpdateVideoMemory(ULONG StartAddress, ULONG EndAddress); inline DWORD BiosGetVideoMemoryStart(); @@ -57,5 +59,6 @@ VOID BiosKeyboardService(); VOID BiosTimeService(); VOID BiosHandleIrq(BYTE IrqNumber); +VOID BiosSystemTimerInterrupt(); #endif Modified: branches/ntvdm/subsystems/ntvdm/emulator.c URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/subsystems/ntvdm/emulator…
============================================================================== --- branches/ntvdm/subsystems/ntvdm/emulator.c [iso-8859-1] (original) +++ branches/ntvdm/subsystems/ntvdm/emulator.c [iso-8859-1] Fri Jul 5 01:31:50 2013 @@ -234,6 +234,12 @@ BiosTimeService(); break; } + case BIOS_SYS_TIMER_INTERRUPT: + { + /* BIOS timer update */ + BiosSystemTimerInterrupt(); + break; + } case 0x20: { DosInt20h(CodeSegment); Modified: branches/ntvdm/subsystems/ntvdm/ntvdm.c URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/subsystems/ntvdm/ntvdm.c?…
============================================================================== --- branches/ntvdm/subsystems/ntvdm/ntvdm.c [iso-8859-1] (original) +++ branches/ntvdm/subsystems/ntvdm/ntvdm.c [iso-8859-1] Fri Jul 5 01:31:50 2013 @@ -76,43 +76,9 @@ DWORD LastVerticalRefresh = GetTickCount(); LARGE_INTEGER Frequency, LastTimerTick, Counter; LONGLONG TimerTicks; - HANDLE ConsoleInput = INVALID_HANDLE_VALUE; - HANDLE ConsoleOutput = INVALID_HANDLE_VALUE; - CONSOLE_SCREEN_BUFFER_INFO SavedBufferInfo; /* Set the handler routine */ SetConsoleCtrlHandler(ConsoleCtrlHandler, TRUE); - - /* Get the input and output handles to the real console */ - ConsoleInput = CreateFile(TEXT("CONIN$"), - GENERIC_READ | GENERIC_WRITE, - FILE_SHARE_READ | FILE_SHARE_WRITE, - NULL, - OPEN_EXISTING, - 0, - NULL); - - ConsoleOutput = CreateFile(TEXT("CONOUT$"), - GENERIC_READ | GENERIC_WRITE, - FILE_SHARE_READ | FILE_SHARE_WRITE, - NULL, - OPEN_EXISTING, - 0, - NULL); - - if ((ConsoleInput == INVALID_HANDLE_VALUE) - || (ConsoleOutput == INVALID_HANDLE_VALUE)) - { - wprintf(L"FATAL: Could not get handles to the console\n"); - goto Cleanup; - } - - /* Save the console screen buffer information */ - if (!GetConsoleScreenBufferInfo(ConsoleOutput, &SavedBufferInfo)) - { - wprintf(L"FATAL: Could not save the console screen buffer information\n"); - goto Cleanup; - } /* The DOS command line must be ASCII */ WideCharToMultiByte(CP_ACP, 0, GetCommandLine(), -1, CommandLine, 128, NULL, NULL); @@ -131,7 +97,7 @@ } /* Initialize the system BIOS */ - if (!BiosInitialize(ConsoleInput, ConsoleOutput)) + if (!BiosInitialize()) { wprintf(L"FATAL: Failed to initialize the VDM BIOS.\n"); goto Cleanup; @@ -201,17 +167,8 @@ } Cleanup: - /* Restore the old screen buffer */ - SetConsoleActiveScreenBuffer(ConsoleOutput); - - /* Restore the screen buffer size */ - SetConsoleScreenBufferSize(ConsoleOutput, SavedBufferInfo.dwSize); - + BiosCleanup(); EmulatorCleanup(); - - /* Close the console handles */ - if (ConsoleInput != INVALID_HANDLE_VALUE) CloseHandle(ConsoleInput); - if (ConsoleOutput != INVALID_HANDLE_VALUE) CloseHandle(ConsoleOutput); return 0; }
11 years, 5 months
1
0
0
0
[aandrejevic] 59424: [NTVDM] Implement BIOS video mode setting. Fix bugs in video memory access emulation.
by aandrejevic@svn.reactos.org
Author: aandrejevic Date: Fri Jul 5 00:08:18 2013 New Revision: 59424 URL:
http://svn.reactos.org/svn/reactos?rev=59424&view=rev
Log: [NTVDM] Implement BIOS video mode setting. Fix bugs in video memory access emulation. Modified: branches/ntvdm/subsystems/ntvdm/bios.c branches/ntvdm/subsystems/ntvdm/bios.h branches/ntvdm/subsystems/ntvdm/emulator.c branches/ntvdm/subsystems/ntvdm/ntvdm.c Modified: branches/ntvdm/subsystems/ntvdm/bios.c URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/subsystems/ntvdm/bios.c?r…
============================================================================== --- branches/ntvdm/subsystems/ntvdm/bios.c [iso-8859-1] (original) +++ branches/ntvdm/subsystems/ntvdm/bios.c [iso-8859-1] Fri Jul 5 00:08:18 2013 @@ -22,6 +22,35 @@ static BOOLEAN BiosKbdBufferEmpty = TRUE; static DWORD BiosTickCount = 0; static BOOLEAN BiosPassedMidnight = FALSE; +static HANDLE BiosConsoleInput, BiosConsoleOutput; +static BYTE CurrentVideoMode = BIOS_DEFAULT_VIDEO_MODE; +static BYTE CurrentVideoPage = 0; +static HANDLE ConsoleBuffers[BIOS_MAX_PAGES] = { NULL }; +static LPVOID ConsoleFramebuffers[BIOS_MAX_PAGES] = { NULL }; +static VIDEO_MODE VideoModes[] = +{ + /* Width | Height | Text | Colors | Gray | Pages | Segment */ + { 40, 25, TRUE, 16, TRUE, 8, 0xB800}, /* Mode 00h */ + { 40, 25, TRUE, 16, FALSE, 8, 0xB800}, /* Mode 01h */ + { 80, 25, TRUE, 16, TRUE, 8, 0xB800}, /* Mode 02h */ + { 80, 25, TRUE, 16, FALSE, 8, 0xB800}, /* Mode 03h */ + { 320, 200, FALSE, 4, FALSE, 4, 0xB800}, /* Mode 04h */ + { 320, 200, FALSE, 4, TRUE, 4, 0xB800}, /* Mode 05h */ + { 640, 200, FALSE, 2, FALSE, 2, 0xB800}, /* Mode 06h */ + { 80, 25, TRUE, 3, FALSE, 1, 0xB000}, /* Mode 07h */ + { 0, 0, FALSE, 0, FALSE, 0, 0x0000}, /* Mode 08h - not used */ + { 0, 0, FALSE, 0, FALSE, 0, 0x0000}, /* Mode 09h - not used */ + { 0, 0, FALSE, 0, FALSE, 0, 0x0000}, /* Mode 0Ah - not used */ + { 0, 0, FALSE, 0, FALSE, 0, 0x0000}, /* Mode 0Bh - not used */ + { 0, 0, FALSE, 0, FALSE, 0, 0x0000}, /* Mode 0Ch - not used */ + { 320, 200, FALSE, 16, FALSE, 8, 0xA000}, /* Mode 0Dh */ + { 640, 200, FALSE, 16, FALSE, 4, 0xA000}, /* Mode 0Eh */ + { 640, 350, FALSE, 3, FALSE, 2, 0xA000}, /* Mode 0Fh */ + { 640, 350, FALSE, 4, FALSE, 2, 0xA000}, /* Mode 10h */ + { 640, 480, FALSE, 2, FALSE, 1, 0xA000}, /* Mode 11h */ + { 640, 480, FALSE, 16, FALSE, 1, 0xA000}, /* Mode 12h */ + { 640, 480, FALSE, 256, FALSE, 1, 0xA000} /* Mode 13h */ +}; /* PRIVATE FUNCTIONS **********************************************************/ @@ -29,8 +58,10 @@ { COORD Result = {0, 0}; - Result.X = ((Address - CONSOLE_VIDEO_MEM_START) >> 1) % CONSOLE_WIDTH; - Result.Y = ((Address - CONSOLE_VIDEO_MEM_START) >> 1) / CONSOLE_WIDTH; + Result.X = ((Address - (VideoModes[CurrentVideoMode].Segment << 4)) >> 1) + % VideoModes[CurrentVideoMode].Width; + Result.Y = ((Address - (VideoModes[CurrentVideoMode].Segment << 4)) >> 1) + / VideoModes[CurrentVideoMode].Width; return Result; } @@ -78,13 +109,160 @@ /* PUBLIC FUNCTIONS ***********************************************************/ -BOOLEAN BiosInitialize() +BYTE BiosGetVideoMode() +{ + return CurrentVideoMode; +} + +BOOLEAN BiosSetVideoMode(BYTE ModeNumber) +{ + INT i; + COORD Coord; + CONSOLE_GRAPHICS_BUFFER_INFO GraphicsBufferInfo; + LPBITMAPINFO BitmapInfo; + LPWORD PaletteIndex; + + /* Make sure this is a valid video mode */ + if (ModeNumber > BIOS_MAX_VIDEO_MODE) return FALSE; + if (VideoModes[ModeNumber].Pages == 0) return FALSE; + + /* Free the current buffers */ + for (i = 0; i < VideoModes[CurrentVideoMode].Pages; i++) + { + if (ConsoleBuffers[i] != NULL) CloseHandle(ConsoleBuffers[i]); + } + + if (VideoModes[ModeNumber].Text) + { + /* Page 0 is CONOUT$ */ + ConsoleBuffers[0] = CreateFile(TEXT("CONOUT$"), + GENERIC_READ | GENERIC_WRITE, + FILE_SHARE_READ | FILE_SHARE_WRITE, + NULL, + OPEN_EXISTING, + 0, + NULL); + + /* Set the current page to page 0 */ + CurrentVideoPage = 0; + + /* Create console buffers for other pages */ + for (i = 1; i < VideoModes[ModeNumber].Pages; i++) + { + ConsoleBuffers[i] = CreateConsoleScreenBuffer(GENERIC_READ | GENERIC_WRITE, + FILE_SHARE_READ | FILE_SHARE_WRITE, + NULL, + CONSOLE_TEXTMODE_BUFFER, + NULL); + } + + /* Set the size for the buffers */ + for (i = 0; i < VideoModes[ModeNumber].Pages; i++) + { + Coord.X = VideoModes[ModeNumber].Width; + Coord.Y = VideoModes[ModeNumber].Height; + + SetConsoleScreenBufferSize(ConsoleBuffers[i], Coord); + } + } + else + { + /* Allocate a bitmap info structure */ + BitmapInfo = (LPBITMAPINFO)HeapAlloc(GetProcessHeap(), + HEAP_ZERO_MEMORY, + sizeof(BITMAPINFOHEADER) + + VideoModes[ModeNumber].Colors + * sizeof(WORD)); + if (BitmapInfo == NULL) return FALSE; + + /* Fill the bitmap info header */ + ZeroMemory(&BitmapInfo->bmiHeader, sizeof(BITMAPINFOHEADER)); + BitmapInfo->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); + BitmapInfo->bmiHeader.biWidth = VideoModes[ModeNumber].Width; + BitmapInfo->bmiHeader.biHeight = VideoModes[ModeNumber].Height; + BitmapInfo->bmiHeader.biPlanes = 1; + BitmapInfo->bmiHeader.biCompression = BI_RGB; + + /* Calculate the number of color bits */ + for (i = 31; i >= 0; i--) + { + if (VideoModes[ModeNumber].Colors & (1 << i)) break; + } + if (i == 0) i = 32; + BitmapInfo->bmiHeader.biBitCount = i; + + /* Calculate the image size */ + BitmapInfo->bmiHeader.biSizeImage = BitmapInfo->bmiHeader.biWidth + * BitmapInfo->bmiHeader.biHeight + * (BitmapInfo->bmiHeader.biBitCount >> 3); + + /* Fill the palette data */ + PaletteIndex = (LPWORD)((ULONG_PTR)BitmapInfo + sizeof(BITMAPINFOHEADER)); + for (i = 0; i < VideoModes[ModeNumber].Colors; i++) + { + PaletteIndex[i] = i; + } + + /* Create a console buffer for each page */ + for (i = 0; i < VideoModes[ModeNumber].Pages; i++) + { + /* Fill the console graphics buffer info */ + GraphicsBufferInfo.dwBitMapInfoLength = sizeof(BITMAPINFOHEADER) + + VideoModes[ModeNumber].Colors + * sizeof(WORD); + GraphicsBufferInfo.lpBitMapInfo = BitmapInfo; + GraphicsBufferInfo.dwUsage = DIB_PAL_COLORS; + + /* Create the buffer */ + ConsoleBuffers[i] = CreateConsoleScreenBuffer(GENERIC_READ | GENERIC_WRITE, + FILE_SHARE_READ | FILE_SHARE_WRITE, + NULL, + CONSOLE_GRAPHICS_BUFFER, + &GraphicsBufferInfo); + + /* Save the framebuffer address */ + ConsoleFramebuffers[i] = GraphicsBufferInfo.lpBitMap; + } + + /* Free the bitmap information */ + HeapFree(GetProcessHeap(), 0, BitmapInfo); + } + + /* Set the active page console buffer */ + SetConsoleActiveScreenBuffer(ConsoleBuffers[CurrentVideoPage]); + + /* Update the mode number */ + CurrentVideoMode = ModeNumber; + + return TRUE; +} + +inline DWORD BiosGetVideoMemoryStart() +{ + return (VideoModes[CurrentVideoMode].Segment << 4); +} + +inline VOID BiosVerticalRefresh() +{ + SMALL_RECT Region; + + /* Ignore if we're in text mode */ + if (VideoModes[CurrentVideoMode].Text) return; + + /* Fill the rectangle structure */ + Region.Left = Region.Top = 0; + Region.Right = VideoModes[CurrentVideoMode].Width; + Region.Bottom = VideoModes[CurrentVideoMode].Height; + + /* Redraw the screen */ + InvalidateConsoleDIBits(ConsoleBuffers[CurrentVideoPage], + &Region); +} + +BOOLEAN BiosInitialize(HANDLE ConsoleInput, HANDLE ConsoleOutput) { INT i; WORD Offset = 0; - COORD Size = { CONSOLE_WIDTH, CONSOLE_HEIGHT}; - HANDLE ConsoleInput = GetStdHandle(STD_INPUT_HANDLE); - HANDLE ConsoleOutput = GetStdHandle(STD_OUTPUT_HANDLE); LPWORD IntVecTable = (LPWORD)((ULONG_PTR)BaseAddress); LPBYTE BiosCode = (LPBYTE)((ULONG_PTR)BaseAddress + TO_LINEAR(BIOS_SEGMENT, 0)); @@ -112,8 +290,12 @@ BiosCode[Offset++] = 0xCF; // iret } - /* Set the console buffer size */ - if (!SetConsoleScreenBufferSize(ConsoleOutput, Size)) return FALSE; + /* Set global console I/O handles */ + BiosConsoleInput = ConsoleInput; + BiosConsoleOutput = ConsoleOutput; + + /* Set the default video mode */ + BiosSetVideoMode(BIOS_DEFAULT_VIDEO_MODE); /* Set the console input mode */ SetConsoleMode(ConsoleInput, ENABLE_MOUSE_INPUT | ENABLE_PROCESSED_INPUT); @@ -153,27 +335,43 @@ COORD UnitSize = { 1, 1 }; CHAR_INFO Character; SMALL_RECT Rect; - HANDLE ConsoleOutput = GetStdHandle(STD_OUTPUT_HANDLE); /* Start from the character address */ StartAddress &= ~1; - /* Loop through all the addresses */ - for (i = StartAddress; i < EndAddress; i += 2) - { - /* Get the coordinates */ - Coordinates = BiosVideoAddressToCoord(i); - - /* Fill the rectangle structure */ - Rect.Left = Coordinates.X; - Rect.Top = Coordinates.Y; - - /* Fill the character data */ - Character.Char.AsciiChar = *((PCHAR)((ULONG_PTR)BaseAddress + i)); - Character.Attributes = *((PBYTE)((ULONG_PTR)BaseAddress + i + 1)); - - /* Write the character */ - WriteConsoleOutputA(ConsoleOutput, &Character, UnitSize, Origin, &Rect); + if (VideoModes[CurrentVideoMode].Text) + { + /* Loop through all the addresses */ + for (i = StartAddress; i < EndAddress; i += 2) + { + /* Get the coordinates */ + Coordinates = BiosVideoAddressToCoord(i); + + /* Fill the rectangle structure */ + Rect.Left = Coordinates.X; + Rect.Top = Coordinates.Y; + Rect.Right = Rect.Left; + Rect.Bottom = Rect.Top; + + /* Fill the character data */ + Character.Char.AsciiChar = *((PCHAR)((ULONG_PTR)BaseAddress + i)); + Character.Attributes = *((PBYTE)((ULONG_PTR)BaseAddress + i + 1)); + + /* Write the character */ + WriteConsoleOutputA(BiosConsoleOutput, + &Character, + UnitSize, + Origin, + &Rect); + } + } + else + { + /* Copy the data to the framebuffer */ + RtlCopyMemory((LPVOID)((ULONG_PTR)ConsoleFramebuffers[CurrentVideoPage] + + StartAddress - BiosGetVideoMemoryStart()), + (LPVOID)((ULONG_PTR)BaseAddress + StartAddress), + EndAddress - StartAddress); } } @@ -183,35 +381,45 @@ COORD Coordinates; WORD Attribute; DWORD CharsWritten; - HANDLE ConsoleOutput = GetStdHandle(STD_OUTPUT_HANDLE); - - /* Loop through all the addresses */ - for (i = StartAddress; i < EndAddress; i++) - { - /* Get the coordinates */ - Coordinates = BiosVideoAddressToCoord(i); - - /* Check if this is a character byte or an attribute byte */ - if ((i - CONSOLE_VIDEO_MEM_START) % 2 == 0) - { - /* This is a regular character */ - ReadConsoleOutputCharacterA(ConsoleOutput, - (LPSTR)((ULONG_PTR)BaseAddress + i), - sizeof(CHAR), - Coordinates, - &CharsWritten); - } - else - { - /* This is an attribute */ - ReadConsoleOutputAttribute(ConsoleOutput, - &Attribute, - sizeof(CHAR), - Coordinates, - &CharsWritten); - - *(PCHAR)((ULONG_PTR)BaseAddress + i) = LOBYTE(Attribute); - } + + if (VideoModes[CurrentVideoMode].Text) + { + /* Loop through all the addresses */ + for (i = StartAddress; i < EndAddress; i++) + { + /* Get the coordinates */ + Coordinates = BiosVideoAddressToCoord(i); + + /* Check if this is a character byte or an attribute byte */ + if ((i - (VideoModes[CurrentVideoMode].Segment << 4)) % 2 == 0) + { + /* This is a regular character */ + ReadConsoleOutputCharacterA(BiosConsoleOutput, + (LPSTR)((ULONG_PTR)BaseAddress + i), + sizeof(CHAR), + Coordinates, + &CharsWritten); + } + else + { + /* This is an attribute */ + ReadConsoleOutputAttribute(BiosConsoleOutput, + &Attribute, + sizeof(CHAR), + Coordinates, + &CharsWritten); + + *(PCHAR)((ULONG_PTR)BaseAddress + i) = LOBYTE(Attribute); + } + } + } + else + { + /* Copy the data to the emulator memory */ + RtlCopyMemory((LPVOID)((ULONG_PTR)BaseAddress + StartAddress), + (LPVOID)((ULONG_PTR)ConsoleFramebuffers[CurrentVideoPage] + + StartAddress - BiosGetVideoMemoryStart()), + EndAddress - StartAddress); } } @@ -231,7 +439,6 @@ WORD BiosGetCharacter() { WORD CharacterData; - HANDLE ConsoleInput = GetStdHandle(STD_INPUT_HANDLE); INPUT_RECORD InputRecord; DWORD Count; @@ -247,10 +454,10 @@ while (TRUE) { /* Wait for a console event */ - WaitForSingleObject(ConsoleInput, INFINITE); + WaitForSingleObject(BiosConsoleInput, INFINITE); /* Read the event, and make sure it's a keypress */ - if (!ReadConsoleInput(ConsoleInput, &InputRecord, 1, &Count)) continue; + if (!ReadConsoleInput(BiosConsoleInput, &InputRecord, 1, &Count)) continue; if (InputRecord.EventType != KEY_EVENT) continue; if (!InputRecord.Event.KeyEvent.bKeyDown) continue; @@ -267,7 +474,6 @@ VOID BiosVideoService() { - HANDLE ConsoleOutput = GetStdHandle(STD_OUTPUT_HANDLE); INT CursorHeight; BOOLEAN Invisible = FALSE; COORD Position; @@ -282,6 +488,13 @@ switch (HIBYTE(Eax)) { + /* Set Video Mode */ + case 0x00: + { + BiosSetVideoMode(LOBYTE(Eax)); + break; + } + /* Set Text-Mode Cursor Shape */ case 0x01: { @@ -294,7 +507,7 @@ /* Set the cursor */ CursorInfo.dwSize = (CursorHeight * 100) / CONSOLE_FONT_HEIGHT; CursorInfo.bVisible = !Invisible; - SetConsoleCursorInfo(ConsoleOutput, &CursorInfo); + SetConsoleCursorInfo(BiosConsoleOutput, &CursorInfo); break; } @@ -305,7 +518,7 @@ Position.X = LOBYTE(Edx); Position.Y = HIBYTE(Edx); - SetConsoleCursorPosition(ConsoleOutput, Position); + SetConsoleCursorPosition(BiosConsoleOutput, Position); break; } @@ -315,8 +528,8 @@ INT StartLine; /* Retrieve the data */ - GetConsoleCursorInfo(ConsoleOutput, &CursorInfo); - GetConsoleScreenBufferInfo(ConsoleOutput, &ScreenBufferInfo); + GetConsoleCursorInfo(BiosConsoleOutput, &CursorInfo); + GetConsoleScreenBufferInfo(BiosConsoleOutput, &ScreenBufferInfo); /* Find the first line */ StartLine = 32 - ((CursorInfo.dwSize * 32) / 100); @@ -344,7 +557,7 @@ if (HIBYTE(Eax) == 0x06) Position.Y = Rect.Top - LOBYTE(Eax); else Position.Y = Rect.Top + LOBYTE(Eax); - ScrollConsoleScreenBuffer(ConsoleOutput, + ScrollConsoleScreenBuffer(BiosConsoleOutput, &Rect, &Rect, Position, @@ -358,14 +571,14 @@ COORD BufferSize = { 1, 1 }, Origin = { 0, 0 }; /* Get the cursor position */ - GetConsoleScreenBufferInfo(ConsoleOutput, &ScreenBufferInfo); + GetConsoleScreenBufferInfo(BiosConsoleOutput, &ScreenBufferInfo); /* Read at cursor position */ Rect.Left = ScreenBufferInfo.dwCursorPosition.X; Rect.Top = ScreenBufferInfo.dwCursorPosition.Y; /* Read the console output */ - ReadConsoleOutput(ConsoleOutput, &Character, BufferSize, Origin, &Rect); + ReadConsoleOutput(BiosConsoleOutput, &Character, BufferSize, Origin, &Rect); /* Return the result */ EmulatorSetRegister(EMULATOR_REG_AX, @@ -381,17 +594,17 @@ DWORD CharsWritten; /* Get the cursor position */ - GetConsoleScreenBufferInfo(ConsoleOutput, &ScreenBufferInfo); + GetConsoleScreenBufferInfo(BiosConsoleOutput, &ScreenBufferInfo); /* Write the attribute to the output */ - FillConsoleOutputAttribute(ConsoleOutput, + FillConsoleOutputAttribute(BiosConsoleOutput, LOBYTE(Ebx), LOWORD(Ecx), ScreenBufferInfo.dwCursorPosition, &CharsWritten); /* Write the character to the output */ - FillConsoleOutputCharacterA(ConsoleOutput, + FillConsoleOutputCharacterA(BiosConsoleOutput, LOBYTE(Eax), LOWORD(Ecx), ScreenBufferInfo.dwCursorPosition, @@ -406,10 +619,10 @@ DWORD CharsWritten; /* Get the cursor position */ - GetConsoleScreenBufferInfo(ConsoleOutput, &ScreenBufferInfo); + GetConsoleScreenBufferInfo(BiosConsoleOutput, &ScreenBufferInfo); /* Write the character to the output */ - FillConsoleOutputCharacterA(ConsoleOutput, + FillConsoleOutputCharacterA(BiosConsoleOutput, LOBYTE(Eax), LOWORD(Ecx), ScreenBufferInfo.dwCursorPosition, @@ -418,11 +631,14 @@ break; } + /* Get Current Video Mode */ case 0x0F: { - /* Return just text mode information, for now */ - EmulatorSetRegister(EMULATOR_REG_AX, 0x5003); - EmulatorSetRegister(EMULATOR_REG_BX, 0x0000); + EmulatorSetRegister(EMULATOR_REG_AX, + (VideoModes[CurrentVideoMode].Width << 8) + | CurrentVideoMode); + EmulatorSetRegister(EMULATOR_REG_BX, + (CurrentVideoPage << 8) | LOBYTE(Ebx)); break; } Modified: branches/ntvdm/subsystems/ntvdm/bios.h URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/subsystems/ntvdm/bios.h?r…
============================================================================== --- branches/ntvdm/subsystems/ntvdm/bios.h [iso-8859-1] (original) +++ branches/ntvdm/subsystems/ntvdm/bios.h [iso-8859-1] Fri Jul 5 00:08:18 2013 @@ -15,7 +15,6 @@ /* DEFINES ********************************************************************/ -#define CONSOLE_VIDEO_MEM_START 0xB8000 #define CONSOLE_VIDEO_MEM_END 0xBFFFF #define ROM_AREA_START 0xC0000 #define ROM_AREA_END 0xFFFFF @@ -26,17 +25,31 @@ #define BIOS_EQUIPMENT_INTERRUPT 0x11 #define BIOS_KBD_INTERRUPT 0x16 #define BIOS_TIME_INTERRUPT 0x1A -#define CONSOLE_WIDTH 80 -#define CONSOLE_HEIGHT 25 #define CONSOLE_FONT_HEIGHT 8 #define BIOS_KBD_BUFFER_SIZE 256 #define BIOS_EQUIPMENT_LIST 0x3C // HACK: Disable FPU for now +#define BIOS_DEFAULT_VIDEO_MODE 0x03 +#define BIOS_MAX_PAGES 8 +#define BIOS_MAX_VIDEO_MODE 0x13 + +typedef struct +{ + DWORD Width; + DWORD Height; + BOOLEAN Text; + DWORD Colors; + BOOLEAN Gray; + BYTE Pages; + WORD Segment; +} VIDEO_MODE; /* FUNCTIONS ******************************************************************/ BOOLEAN BiosInitialize(); VOID BiosUpdateConsole(ULONG StartAddress, ULONG EndAddress); VOID BiosUpdateVideoMemory(ULONG StartAddress, ULONG EndAddress); +inline DWORD BiosGetVideoMemoryStart(); +inline VOID BiosVerticalRefresh(); WORD BiosPeekCharacter(); WORD BiosGetCharacter(); VOID BiosVideoService(); Modified: branches/ntvdm/subsystems/ntvdm/emulator.c URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/subsystems/ntvdm/emulator…
============================================================================== --- branches/ntvdm/subsystems/ntvdm/emulator.c [iso-8859-1] (original) +++ branches/ntvdm/subsystems/ntvdm/emulator.c [iso-8859-1] Fri Jul 5 00:08:18 2013 @@ -32,11 +32,11 @@ if ((Address + Size) >= MAX_ADDRESS) return; /* Are we reading some of the console video memory? */ - if (((Address + Size) >= CONSOLE_VIDEO_MEM_START) + if (((Address + Size) >= BiosGetVideoMemoryStart()) && (Address < CONSOLE_VIDEO_MEM_END)) { /* Call the VDM BIOS to update the video memory */ - BiosUpdateVideoMemory(max(Address, CONSOLE_VIDEO_MEM_START), + BiosUpdateVideoMemory(max(Address, BiosGetVideoMemoryStart()), min(Address + Size, CONSOLE_VIDEO_MEM_END)); } @@ -59,11 +59,11 @@ RtlCopyMemory((LPVOID)((ULONG_PTR)BaseAddress + Address), Buffer, Size); /* Check if we modified the console video memory */ - if (((Address + Size) >= CONSOLE_VIDEO_MEM_START) + if (((Address + Size) >= BiosGetVideoMemoryStart()) && (Address < CONSOLE_VIDEO_MEM_END)) { /* Call the VDM BIOS to update the screen */ - BiosUpdateConsole(max(Address, CONSOLE_VIDEO_MEM_START), + BiosUpdateConsole(max(Address, BiosGetVideoMemoryStart()), min(Address + Size, CONSOLE_VIDEO_MEM_END)); } } Modified: branches/ntvdm/subsystems/ntvdm/ntvdm.c URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/subsystems/ntvdm/ntvdm.c?…
============================================================================== --- branches/ntvdm/subsystems/ntvdm/ntvdm.c [iso-8859-1] (original) +++ branches/ntvdm/subsystems/ntvdm/ntvdm.c [iso-8859-1] Fri Jul 5 00:08:18 2013 @@ -73,19 +73,54 @@ DWORD LastTickCount = GetTickCount(); DWORD Cycles = 0; DWORD LastCyclePrintout = GetTickCount(); + DWORD LastVerticalRefresh = GetTickCount(); LARGE_INTEGER Frequency, LastTimerTick, Counter; LONGLONG TimerTicks; + HANDLE ConsoleInput = INVALID_HANDLE_VALUE; + HANDLE ConsoleOutput = INVALID_HANDLE_VALUE; + CONSOLE_SCREEN_BUFFER_INFO SavedBufferInfo; /* Set the handler routine */ SetConsoleCtrlHandler(ConsoleCtrlHandler, TRUE); + /* Get the input and output handles to the real console */ + ConsoleInput = CreateFile(TEXT("CONIN$"), + GENERIC_READ | GENERIC_WRITE, + FILE_SHARE_READ | FILE_SHARE_WRITE, + NULL, + OPEN_EXISTING, + 0, + NULL); + + ConsoleOutput = CreateFile(TEXT("CONOUT$"), + GENERIC_READ | GENERIC_WRITE, + FILE_SHARE_READ | FILE_SHARE_WRITE, + NULL, + OPEN_EXISTING, + 0, + NULL); + + if ((ConsoleInput == INVALID_HANDLE_VALUE) + || (ConsoleOutput == INVALID_HANDLE_VALUE)) + { + wprintf(L"FATAL: Could not get handles to the console\n"); + goto Cleanup; + } + + /* Save the console screen buffer information */ + if (!GetConsoleScreenBufferInfo(ConsoleOutput, &SavedBufferInfo)) + { + wprintf(L"FATAL: Could not save the console screen buffer information\n"); + goto Cleanup; + } + /* The DOS command line must be ASCII */ WideCharToMultiByte(CP_ACP, 0, GetCommandLine(), -1, CommandLine, 128, NULL, NULL); if (!EmulatorInitialize()) { wprintf(L"FATAL: Failed to initialize the CPU emulator\n"); - return 1; + goto Cleanup; } /* Initialize the performance counter (needed for hardware timers) */ @@ -96,7 +131,7 @@ } /* Initialize the system BIOS */ - if (!BiosInitialize()) + if (!BiosInitialize(ConsoleInput, ConsoleOutput)) { wprintf(L"FATAL: Failed to initialize the VDM BIOS.\n"); goto Cleanup; @@ -142,6 +177,13 @@ CheckForInputEvents(); LastTickCount = CurrentTickCount; } + + /* Check for vertical refresh */ + if ((CurrentTickCount - LastVerticalRefresh) >= 16) + { + BiosVerticalRefresh(); + LastVerticalRefresh = CurrentTickCount; + } /* Continue CPU emulation */ for (i = 0; (i < STEPS_PER_CYCLE) && VdmRunning; i++) @@ -159,7 +201,17 @@ } Cleanup: + /* Restore the old screen buffer */ + SetConsoleActiveScreenBuffer(ConsoleOutput); + + /* Restore the screen buffer size */ + SetConsoleScreenBufferSize(ConsoleOutput, SavedBufferInfo.dwSize); + EmulatorCleanup(); + + /* Close the console handles */ + if (ConsoleInput != INVALID_HANDLE_VALUE) CloseHandle(ConsoleInput); + if (ConsoleOutput != INVALID_HANDLE_VALUE) CloseHandle(ConsoleOutput); return 0; }
11 years, 5 months
1
0
0
0
← Newer
1
...
15
16
17
18
19
20
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
Results per page:
10
25
50
100
200