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
November 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
16 participants
348 discussions
Start a n
N
ew thread
[aandrejevic] 60989: [FAST486] Fix previous fix.
by aandrejevic@svn.reactos.org
Author: aandrejevic Date: Thu Nov 14 03:03:23 2013 New Revision: 60989 URL:
http://svn.reactos.org/svn/reactos?rev=60989&view=rev
Log: [FAST486] Fix previous fix. Modified: branches/ntvdm/lib/fast486/opcodes.c Modified: branches/ntvdm/lib/fast486/opcodes.c URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/lib/fast486/opcodes.c?rev…
============================================================================== --- branches/ntvdm/lib/fast486/opcodes.c [iso-8859-1] (original) +++ branches/ntvdm/lib/fast486/opcodes.c [iso-8859-1] Thu Nov 14 03:03:23 2013 @@ -5890,12 +5890,12 @@ if (OperandSize) { State->GeneralRegs[FAST486_REG_ECX].Long = 0; - State->GeneralRegs[FAST486_REG_ESI].Long += Count - 1; + State->GeneralRegs[FAST486_REG_ESI].Long += (Count - 1) * DataSize; } else { State->GeneralRegs[FAST486_REG_ECX].LowWord = 0; - State->GeneralRegs[FAST486_REG_ESI].LowWord += Count - 1; + State->GeneralRegs[FAST486_REG_ESI].LowWord += (Count - 1) * DataSize; } }
11 years, 1 month
1
0
0
0
[aandrejevic] 60988: [FAST486] Update the register values in REP LODS.
by aandrejevic@svn.reactos.org
Author: aandrejevic Date: Thu Nov 14 02:54:20 2013 New Revision: 60988 URL:
http://svn.reactos.org/svn/reactos?rev=60988&view=rev
Log: [FAST486] Update the register values in REP LODS. Modified: branches/ntvdm/lib/fast486/opcodes.c Modified: branches/ntvdm/lib/fast486/opcodes.c URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/lib/fast486/opcodes.c?rev…
============================================================================== --- branches/ntvdm/lib/fast486/opcodes.c [iso-8859-1] (original) +++ branches/ntvdm/lib/fast486/opcodes.c [iso-8859-1] Thu Nov 14 02:54:20 2013 @@ -5885,6 +5885,18 @@ if (AddressSize) State->GeneralRegs[FAST486_REG_ESI].Long -= (Count - 1) * DataSize; else State->GeneralRegs[FAST486_REG_ESI].LowWord -= (Count - 1) * DataSize; } + + /* Update registers */ + if (OperandSize) + { + State->GeneralRegs[FAST486_REG_ECX].Long = 0; + State->GeneralRegs[FAST486_REG_ESI].Long += Count - 1; + } + else + { + State->GeneralRegs[FAST486_REG_ECX].LowWord = 0; + State->GeneralRegs[FAST486_REG_ESI].LowWord += Count - 1; + } } /* Read from the source operand */
11 years, 1 month
1
0
0
0
[aandrejevic] 60987: [FAST486] Fix the BSF and BSR instructions. Partially fix SHLD and SHRD.
by aandrejevic@svn.reactos.org
Author: aandrejevic Date: Thu Nov 14 02:39:54 2013 New Revision: 60987 URL:
http://svn.reactos.org/svn/reactos?rev=60987&view=rev
Log: [FAST486] Fix the BSF and BSR instructions. Partially fix SHLD and SHRD. Modified: branches/ntvdm/lib/fast486/extraops.c Modified: branches/ntvdm/lib/fast486/extraops.c URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/lib/fast486/extraops.c?re…
============================================================================== --- branches/ntvdm/lib/fast486/extraops.c [iso-8859-1] (original) +++ branches/ntvdm/lib/fast486/extraops.c [iso-8859-1] Thu Nov 14 02:39:54 2013 @@ -669,6 +669,7 @@ else { USHORT Source, Destination, Result; + ULONG DoubleSource; if (!Fast486ReadModrmWordOperands(State, &ModRegRm, &Source, &Destination)) { @@ -676,8 +677,10 @@ return FALSE; } + DoubleSource = Source | (Source << 16); + /* Calculate the result */ - Result = (Destination << Count) | (Source >> (16 - Count)); + Result = (Destination << Count) | (DoubleSource >> (32 - Count)); /* Update flags */ State->Flags.Cf = (Destination >> (16 - Count)) & 1; @@ -880,6 +883,8 @@ /* Calculate the result */ Result = (Destination >> Count) | (Source << (16 - Count)); + + if (Count >= 16) Result |= (ULONG)(Source | (Source << 16)) >> (Count - 16); /* Update flags */ State->Flags.Cf = (Result >> (Count - 1)) & 1; @@ -1535,16 +1540,14 @@ } } - /* Clear ZF */ - State->Flags.Zf = FALSE; + /* Set ZF */ + State->Flags.Zf = (Value == 0); + if (State->Flags.Zf) return TRUE; for (i = 0; i < DataSize; i++) { if(Value & (1 << i)) { - /* Set ZF */ - State->Flags.Zf = TRUE; - /* Save the bit number */ BitNumber = i; @@ -1553,24 +1556,21 @@ } } - if (State->Flags.Zf) - { - /* Write back the result */ - if (OperandSize) - { - if (!Fast486WriteModrmDwordOperands(State, &ModRegRm, TRUE, BitNumber)) - { - /* Exception occurred */ - return FALSE; - } - } - else - { - if (!Fast486WriteModrmWordOperands(State, &ModRegRm, TRUE, LOWORD(BitNumber))) - { - /* Exception occurred */ - return FALSE; - } + /* Write back the result */ + if (OperandSize) + { + if (!Fast486WriteModrmDwordOperands(State, &ModRegRm, TRUE, BitNumber)) + { + /* Exception occurred */ + return FALSE; + } + } + else + { + if (!Fast486WriteModrmWordOperands(State, &ModRegRm, TRUE, LOWORD(BitNumber))) + { + /* Exception occurred */ + return FALSE; } } @@ -1625,16 +1625,14 @@ } } - /* Clear ZF */ - State->Flags.Zf = FALSE; + /* Set ZF according to the value */ + State->Flags.Zf = (Value == 0); + if (State->Flags.Zf) return TRUE; for (i = DataSize - 1; i >= 0; i--) { if(Value & (1 << i)) { - /* Set ZF */ - State->Flags.Zf = TRUE; - /* Save the bit number */ BitNumber = i; @@ -1643,24 +1641,21 @@ } } - if (State->Flags.Zf) - { - /* Write back the result */ - if (OperandSize) - { - if (!Fast486WriteModrmDwordOperands(State, &ModRegRm, TRUE, BitNumber)) - { - /* Exception occurred */ - return FALSE; - } - } - else - { - if (!Fast486WriteModrmWordOperands(State, &ModRegRm, TRUE, LOWORD(BitNumber))) - { - /* Exception occurred */ - return FALSE; - } + /* Write back the result */ + if (OperandSize) + { + if (!Fast486WriteModrmDwordOperands(State, &ModRegRm, TRUE, BitNumber)) + { + /* Exception occurred */ + return FALSE; + } + } + else + { + if (!Fast486WriteModrmWordOperands(State, &ModRegRm, TRUE, LOWORD(BitNumber))) + { + /* Exception occurred */ + return FALSE; } }
11 years, 1 month
1
0
0
0
[tkreuzer] 60986: [NTDDVDEO] Add some missing definitions
by tkreuzer@svn.reactos.org
Author: tkreuzer Date: Wed Nov 13 23:31:36 2013 New Revision: 60986 URL:
http://svn.reactos.org/svn/reactos?rev=60986&view=rev
Log: [NTDDVDEO] Add some missing definitions Modified: trunk/reactos/include/psdk/ntddvdeo.h Modified: trunk/reactos/include/psdk/ntddvdeo.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/psdk/ntddvdeo.h?re…
============================================================================== --- trunk/reactos/include/psdk/ntddvdeo.h [iso-8859-1] (original) +++ trunk/reactos/include/psdk/ntddvdeo.h [iso-8859-1] Wed Nov 13 23:31:36 2013 @@ -20,8 +20,13 @@ * */ -#ifndef _NTDDVDEO_ +#pragma once #define _NTDDVDEO_ + +DEFINE_GUID(GUID_DEVINTERFACE_DISPLAY_ADAPTER, \ + 0x5b45201d, 0xf2f2, 0x4f3b, 0x85, 0xbb, 0x30, 0xff, 0x1f, 0x95, 0x35, 0x99); + +#ifndef GUID_DEFS_ONLY #ifdef __cplusplus extern "C" { @@ -32,12 +37,10 @@ #define DD_FULLSCREEN_VIDEO_DEVICE_NAME L"\\Device\\FSVideo" -DEFINE_GUID(GUID_DEVINTERFACE_DISPLAY_ADAPTER, \ - 0x5b45201d, 0xf2f2, 0x4f3b, 0x85, 0xbb, 0x30, 0xff, 0x1f, 0x95, 0x35, 0x99); #define IOCTL_VIDEO_ENABLE_VDM \ CTL_CODE(FILE_DEVICE_VIDEO, 0x00, METHOD_BUFFERED, FILE_ANY_ACCESS) - + #define IOCTL_VIDEO_DISABLE_VDM \ CTL_CODE(FILE_DEVICE_VIDEO, 0x01, METHOD_BUFFERED, FILE_ANY_ACCESS) @@ -179,13 +182,91 @@ #define IOCTL_VIDEO_UNSHARE_VIDEO_MEMORY \ CTL_CODE(FILE_DEVICE_VIDEO, 0x11e, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define IOCTL_VIDEO_SET_COLOR_LUT_DATA \ + CTL_CODE(FILE_DEVICE_VIDEO, 0x11f, METHOD_BUFFERED, FILE_ANY_ACCESS) + #define IOCTL_VIDEO_VALIDATE_CHILD_STATE_CONFIGURATION \ CTL_CODE(FILE_DEVICE_VIDEO, 0x121, METHOD_BUFFERED, FILE_ANY_ACCESS) - +#define IOCTL_VIDEO_SET_BANK_POSITION \ + CTL_CODE(FILE_DEVICE_VIDEO, 0x124, METHOD_BUFFERED, FILE_ANY_ACCESS) + +#define IOCTL_VIDEO_QUERY_SUPPORTED_BRIGHTNESS \ + CTL_CODE(FILE_DEVICE_VIDEO, 0x125, METHOD_BUFFERED, FILE_ANY_ACCESS) + +#define IOCTL_VIDEO_QUERY_DISPLAY_BRIGHTNESS \ + CTL_CODE(FILE_DEVICE_VIDEO, 0x126, METHOD_BUFFERED, FILE_ANY_ACCESS) + +#define IOCTL_VIDEO_SET_DISPLAY_BRIGHTNESS \ + CTL_CODE(FILE_DEVICE_VIDEO, 0x127, METHOD_BUFFERED, FILE_ANY_ACCESS) + +typedef struct _VIDEO_VDM { + HANDLE ProcessHandle; +} VIDEO_VDM, *PVIDEO_VDM; + +typedef struct _VIDEO_REGISTER_VDM { + ULONG MinimumStateSize; +} VIDEO_REGISTER_VDM, *PVIDEO_REGISTER_VDM; + +typedef struct tagVIDEO_MONITOR_DEVICE { + ULONG flag; + ULONG HwID; + BOOLEAN Internal; +} VIDEO_MONITOR_DEVICE, *PVIDEO_MONITOR_DEVICE; + +typedef struct tagVIDEO_MONITOR_DESCRIPTOR { + ULONG DescriptorSize; + UCHAR Descriptor[1]; +} VIDEO_MONITOR_DESCRIPTOR, *PVIDEO_MONITOR_DESCRIPTOR; + +typedef enum _VIDEO_WIN32K_CALLBACKS_PARAMS_TYPE { + VideoPowerNotifyCallout = 1, + VideoDisplaySwitchCallout, + VideoEnumChildPdoNotifyCallout, + VideoFindAdapterCallout, + VideoWakeupCallout, + VideoChangeDisplaySettingsCallout, + VideoPnpNotifyCallout, + VideoDxgkDisplaySwitchCallout, + VideoDxgkMonitorEventCallout, + VideoDxgkFindAdapterTdrCallout +} VIDEO_WIN32K_CALLBACKS_PARAMS_TYPE; + +#define DXGK_WIN32K_PARAM_FLAG_UPDATEREGISTRY 1 +#define DXGK_WIN32K_PARAM_FLAG_MODESWITCH 2 +#define DXGK_WIN32K_PARAM_FLAG_DISABLEVIEW 4 + +typedef struct _DXGK_WIN32K_PARAM_DATA +{ + PVOID PathsArray; + PVOID ModesArray; + ULONG NumPathArrayElements; + ULONG NumModeArrayElements; + ULONG SDCFlags; +} DXGK_WIN32K_PARAM_DATA, *PDXGK_WIN32K_PARAM_DATA; + +typedef struct _VIDEO_WIN32K_CALLBACKS_PARAMS { + VIDEO_WIN32K_CALLBACKS_PARAMS_TYPE CalloutType; + PVOID PhysDisp; + ULONG_PTR Param; + LONG Status; +} VIDEO_WIN32K_CALLBACKS_PARAMS, *PVIDEO_WIN32K_CALLBACKS_PARAMS; + +typedef +VOID +(*PVIDEO_WIN32K_CALLOUT)( + _In_ PVOID Params); + +typedef struct _VIDEO_WIN32K_CALLBACKS { + IN PVOID PhysDisp; + IN PVIDEO_WIN32K_CALLOUT Callout; + OUT ULONG bACPI; + OUT HANDLE pPhysDeviceObject; + OUT ULONG DualviewFlags; +} VIDEO_WIN32K_CALLBACKS, *PVIDEO_WIN32K_CALLBACKS; typedef struct _VIDEO_MEMORY { - PVOID RequestedVirtualAddress; + PVOID RequestedVirtualAddress; } VIDEO_MEMORY, *PVIDEO_MEMORY; typedef struct _VIDEO_MEMORY_INFORMATION { @@ -482,4 +563,4 @@ } #endif -#endif /* _NTDDVDEO_ */ +#endif /* GUID_DEFS_ONLY */
11 years, 1 month
1
0
0
0
[aandrejevic] 60985: [FAST486] Fix previous fix.
by aandrejevic@svn.reactos.org
Author: aandrejevic Date: Wed Nov 13 22:34:38 2013 New Revision: 60985 URL:
http://svn.reactos.org/svn/reactos?rev=60985&view=rev
Log: [FAST486] Fix previous fix. Modified: branches/ntvdm/lib/fast486/opgroups.c Modified: branches/ntvdm/lib/fast486/opgroups.c URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/lib/fast486/opgroups.c?re…
============================================================================== --- branches/ntvdm/lib/fast486/opgroups.c [iso-8859-1] (original) +++ branches/ntvdm/lib/fast486/opgroups.c [iso-8859-1] Wed Nov 13 22:34:38 2013 @@ -496,8 +496,8 @@ if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm)) { /* Exception occurred - restore SP */ - if (OperandSize) State->GeneralRegs[FAST486_REG_ESP].Long += sizeof(ULONG); - else State->GeneralRegs[FAST486_REG_ESP].LowWord += sizeof(USHORT); + if (OperandSize) State->GeneralRegs[FAST486_REG_ESP].Long -= sizeof(ULONG); + else State->GeneralRegs[FAST486_REG_ESP].LowWord -= sizeof(USHORT); return FALSE; }
11 years, 1 month
1
0
0
0
[aandrejevic] 60984: [FAST486] XADD: Fix the order of operations. POP <modrm>: The value must be popped from the stack before parsing the Mod-Reg-R/M, because of the "POP DWORD [ESP]" case.
by aandrejevic@svn.reactos.org
Author: aandrejevic Date: Wed Nov 13 22:33:37 2013 New Revision: 60984 URL:
http://svn.reactos.org/svn/reactos?rev=60984&view=rev
Log: [FAST486] XADD: Fix the order of operations. POP <modrm>: The value must be popped from the stack before parsing the Mod-Reg-R/M, because of the "POP DWORD [ESP]" case. Modified: branches/ntvdm/lib/fast486/common.inl branches/ntvdm/lib/fast486/extraops.c branches/ntvdm/lib/fast486/opgroups.c Modified: branches/ntvdm/lib/fast486/common.inl URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/lib/fast486/common.inl?re…
============================================================================== --- branches/ntvdm/lib/fast486/common.inl [iso-8859-1] (original) +++ branches/ntvdm/lib/fast486/common.inl [iso-8859-1] Wed Nov 13 22:33:37 2013 @@ -326,7 +326,7 @@ BOOLEAN Size = State->SegmentRegs[FAST486_REG_SS].Size; /* The OPSIZE prefix toggles the size */ - if (State->PrefixFlags & FAST486_PREFIX_OPSIZE) Size = !Size; + TOGGLE_OPSIZE(Size); if (Size) { Modified: branches/ntvdm/lib/fast486/extraops.c URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/lib/fast486/extraops.c?re…
============================================================================== --- branches/ntvdm/lib/fast486/extraops.c [iso-8859-1] (original) +++ branches/ntvdm/lib/fast486/extraops.c [iso-8859-1] Wed Nov 13 22:33:37 2013 @@ -2032,15 +2032,15 @@ State->Flags.Sf = ((Result & SIGN_FLAG_LONG) != 0); State->Flags.Pf = Fast486CalculateParity(Result); + /* Write the old value of the destination to the source */ + if (!Fast486WriteModrmDwordOperands(State, &ModRegRm, TRUE, Destination)) + { + /* Exception occurred */ + return FALSE; + } + /* Write the sum to the destination */ if (!Fast486WriteModrmDwordOperands(State, &ModRegRm, FALSE, Result)) - { - /* Exception occurred */ - return FALSE; - } - - /* Write the old value of the destination to the source */ - if (!Fast486WriteModrmDwordOperands(State, &ModRegRm, TRUE, Destination)) { /* Exception occurred */ return FALSE; @@ -2071,15 +2071,15 @@ State->Flags.Sf = ((Result & SIGN_FLAG_WORD) != 0); State->Flags.Pf = Fast486CalculateParity(Result); + /* Write the old value of the destination to the source */ + if (!Fast486WriteModrmWordOperands(State, &ModRegRm, TRUE, Destination)) + { + /* Exception occurred */ + return FALSE; + } + /* Write the sum to the destination */ if (!Fast486WriteModrmWordOperands(State, &ModRegRm, FALSE, Result)) - { - /* Exception occurred */ - return FALSE; - } - - /* Write the old value of the destination to the source */ - if (!Fast486WriteModrmWordOperands(State, &ModRegRm, TRUE, Destination)) { /* Exception occurred */ return FALSE; Modified: branches/ntvdm/lib/fast486/opgroups.c URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/lib/fast486/opgroups.c?re…
============================================================================== --- branches/ntvdm/lib/fast486/opgroups.c [iso-8859-1] (original) +++ branches/ntvdm/lib/fast486/opgroups.c [iso-8859-1] Wed Nov 13 22:33:37 2013 @@ -486,9 +486,19 @@ TOGGLE_OPSIZE(OperandSize); TOGGLE_ADSIZE(AddressSize); + /* Pop a value from the stack - this must be done first */ + if (!Fast486StackPop(State, &Value)) + { + /* Exception occurred */ + return FALSE; + } + if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm)) { - /* Exception occurred */ + /* Exception occurred - restore SP */ + if (OperandSize) State->GeneralRegs[FAST486_REG_ESP].Long += sizeof(ULONG); + else State->GeneralRegs[FAST486_REG_ESP].LowWord += sizeof(USHORT); + return FALSE; } @@ -496,13 +506,6 @@ { /* Invalid */ Fast486Exception(State, FAST486_EXCEPTION_UD); - return FALSE; - } - - /* Pop a value from the stack */ - if (!Fast486StackPop(State, &Value)) - { - /* Exception occurred */ return FALSE; }
11 years, 1 month
1
0
0
0
[tfaber] 60983: [NTOS:MM] - Fix bugcheck and unreadable DPRINTs in failure case of MiResolveImageReferences CORE-7571 #resolve
by tfaber@svn.reactos.org
Author: tfaber Date: Wed Nov 13 22:07:54 2013 New Revision: 60983 URL:
http://svn.reactos.org/svn/reactos?rev=60983&view=rev
Log: [NTOS:MM] - Fix bugcheck and unreadable DPRINTs in failure case of MiResolveImageReferences CORE-7571 #resolve Modified: trunk/reactos/ntoskrnl/mm/ARM3/sysldr.c Modified: trunk/reactos/ntoskrnl/mm/ARM3/sysldr.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/ARM3/sysldr.c?…
============================================================================== --- trunk/reactos/ntoskrnl/mm/ARM3/sysldr.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/mm/ARM3/sysldr.c [iso-8859-1] Wed Nov 13 22:07:54 2013 @@ -1167,23 +1167,17 @@ goto Failure; } - /* Setup the base length and copy it */ - DllName.Length = ImageFileDirectory->Length; - RtlCopyMemory(DllName.Buffer, - ImageFileDirectory->Buffer, - ImageFileDirectory->Length); - - /* Now add the import name and null-terminate it */ + /* Add the import name to the base directory */ + RtlCopyUnicodeString(&DllName, ImageFileDirectory); RtlAppendUnicodeStringToString(&DllName, &NameString); - DllName.Buffer[DllName.Length / sizeof(WCHAR)] = UNICODE_NULL; /* Load the image */ Status = MmLoadSystemImage(&DllName, NamePrefix, NULL, FALSE, - (PVOID)&DllEntry, + (PVOID *)&DllEntry, &DllBase); /* win32k / GDI drivers can also import from system32 folder */ @@ -1207,25 +1201,19 @@ goto Failure; } - /* Copy the image directory */ - RtlCopyMemory(DllName.Buffer, - ImageFileDirectory->Buffer, - ImageFileDirectory->Length); - DllName.Length = ImageFileDirectory->Length; - - /* Append 'drivers\' folder name */ + /* Copy image directory and append 'drivers\' folder name */ + RtlCopyUnicodeString(&DllName, ImageFileDirectory); RtlAppendUnicodeStringToString(&DllName, &DriversFolderName); - /* Now add the import name and null-terminate it */ + /* Now add the import name */ RtlAppendUnicodeStringToString(&DllName, &NameString); - DllName.Buffer[DllName.Length / sizeof(WCHAR)] = UNICODE_NULL; /* Try once again to load the image */ Status = MmLoadSystemImage(&DllName, NamePrefix, NULL, FALSE, - (PVOID)&DllEntry, + (PVOID *)&DllEntry, &DllBase); } @@ -1236,11 +1224,12 @@ *(PULONG)MissingDriver |= 1; *MissingApi = NULL; + DPRINT1("Failed to load dependency: %wZ\n", &DllName); + /* Don't free the name */ DllName.Buffer = NULL; /* Cleanup and return */ - DPRINT1("Failed to load dependency: %wZ\n", &DllName); goto Failure; } @@ -1402,10 +1391,7 @@ Failure: /* Cleanup and return */ - if (NameString.Buffer != NULL) - { - ExFreePoolWithTag(NameString.Buffer, TAG_LDR_WSTR); - } + RtlFreeUnicodeString(&NameString); if (LoadedImports) { @@ -3217,14 +3203,14 @@ BOOLEAN NeedToFreeString = FALSE; /* If the lowest bit is set to 1, this is a hint that we need to free */ - if (*(ULONG_PTR*)MissingDriverName & 1) + if (*(ULONG_PTR*)&MissingDriverName & 1) { NeedToFreeString = TRUE; - *(ULONG_PTR*)MissingDriverName &= ~1; + *(ULONG_PTR*)&MissingDriverName &= ~1; } DPRINT1("MiResolveImageReferences failed with status 0x%x\n", Status); - DPRINT1(" Missing driver '%ws', missing API '%s'\n", + DPRINT1(" Missing driver '%ls', missing API '%s'\n", MissingDriverName, MissingApiName); if (NeedToFreeString)
11 years, 1 month
1
0
0
0
[tkreuzer] 60982: [VIDEOPRT][FORMATTING] Apply proper indentation.
by tkreuzer@svn.reactos.org
Author: tkreuzer Date: Wed Nov 13 21:32:16 2013 New Revision: 60982 URL:
http://svn.reactos.org/svn/reactos?rev=60982&view=rev
Log: [VIDEOPRT][FORMATTING] Apply proper indentation. Modified: trunk/reactos/win32ss/drivers/videoprt/videoprt.c Modified: trunk/reactos/win32ss/drivers/videoprt/videoprt.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/drivers/videoprt/v…
============================================================================== --- trunk/reactos/win32ss/drivers/videoprt/videoprt.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/drivers/videoprt/videoprt.c [iso-8859-1] Wed Nov 13 21:32:16 2013 @@ -30,774 +30,759 @@ /* PRIVATE FUNCTIONS **********************************************************/ -ULONG NTAPI +ULONG +NTAPI DriverEntry( - IN PVOID Context1, - IN PVOID Context2) -{ - return STATUS_SUCCESS; -} - -PVOID NTAPI + IN PVOID Context1, + IN PVOID Context2) +{ + return STATUS_SUCCESS; +} + +PVOID +NTAPI IntVideoPortImageDirectoryEntryToData( - PVOID BaseAddress, - ULONG Directory) -{ - PIMAGE_NT_HEADERS NtHeader; - ULONG Va; - - NtHeader = RtlImageNtHeader(BaseAddress); - if (NtHeader == NULL) - return NULL; - - if (Directory >= NtHeader->OptionalHeader.NumberOfRvaAndSizes) - return NULL; - - Va = NtHeader->OptionalHeader.DataDirectory[Directory].VirtualAddress; - if (Va == 0) - return NULL; - - return (PVOID)((ULONG_PTR)BaseAddress + Va); -} - -VOID NTAPI + PVOID BaseAddress, + ULONG Directory) +{ + PIMAGE_NT_HEADERS NtHeader; + ULONG Va; + + NtHeader = RtlImageNtHeader(BaseAddress); + if (NtHeader == NULL) + return NULL; + + if (Directory >= NtHeader->OptionalHeader.NumberOfRvaAndSizes) + return NULL; + + Va = NtHeader->OptionalHeader.DataDirectory[Directory].VirtualAddress; + if (Va == 0) + return NULL; + + return (PVOID)((ULONG_PTR)BaseAddress + Va); +} + +VOID +NTAPI IntVideoPortDeferredRoutine( - IN PKDPC Dpc, - IN PVOID DeferredContext, - IN PVOID SystemArgument1, - IN PVOID SystemArgument2) -{ - PVOID HwDeviceExtension = - &((PVIDEO_PORT_DEVICE_EXTENSION)DeferredContext)->MiniPortDeviceExtension; - ((PMINIPORT_DPC_ROUTINE)SystemArgument1)(HwDeviceExtension, SystemArgument2); -} - + IN PKDPC Dpc, + IN PVOID DeferredContext, + IN PVOID SystemArgument1, + IN PVOID SystemArgument2) +{ + PVOID HwDeviceExtension = + &((PVIDEO_PORT_DEVICE_EXTENSION)DeferredContext)->MiniPortDeviceExtension; + ((PMINIPORT_DPC_ROUTINE)SystemArgument1)(HwDeviceExtension, SystemArgument2); +} + +static NTSTATUS IntCreateRegistryPath( - IN PCUNICODE_STRING DriverRegistryPath, - OUT PUNICODE_STRING DeviceRegistryPath) -{ - static WCHAR RegistryMachineSystem[] = L"\\REGISTRY\\MACHINE\\SYSTEM\\"; - static WCHAR CurrentControlSet[] = L"CURRENTCONTROLSET\\"; - static WCHAR ControlSet[] = L"CONTROLSET"; - static WCHAR Insert1[] = L"Hardware Profiles\\Current\\System\\CurrentControlSet\\"; - static WCHAR Insert2[] = L"\\Device0"; - BOOLEAN Valid; - UNICODE_STRING AfterControlSet; - - AfterControlSet = *DriverRegistryPath; - /* Check if path begins with \\REGISTRY\\MACHINE\\SYSTEM\\ */ - Valid = (DriverRegistryPath->Length > sizeof(RegistryMachineSystem) && - 0 == _wcsnicmp(DriverRegistryPath->Buffer, RegistryMachineSystem, - wcslen(RegistryMachineSystem))); - if (Valid) - { - AfterControlSet.Buffer += wcslen(RegistryMachineSystem); - AfterControlSet.Length -= sizeof(RegistryMachineSystem) - sizeof(UNICODE_NULL); - - /* Check if path contains CURRENTCONTROLSET */ - if (AfterControlSet.Length > sizeof(CurrentControlSet) && - 0 == _wcsnicmp(AfterControlSet.Buffer, CurrentControlSet, wcslen(CurrentControlSet))) - { - AfterControlSet.Buffer += wcslen(CurrentControlSet); - AfterControlSet.Length -= sizeof(CurrentControlSet) - sizeof(UNICODE_NULL); - } - /* Check if path contains CONTROLSETnum */ - else if (AfterControlSet.Length > sizeof(ControlSet) && - 0 == _wcsnicmp(AfterControlSet.Buffer, ControlSet, wcslen(ControlSet))) - { - AfterControlSet.Buffer += wcslen(ControlSet); - AfterControlSet.Length -= sizeof(ControlSet) - sizeof(UNICODE_NULL); - while (AfterControlSet.Length > 0 && - *AfterControlSet.Buffer >= L'0' && - *AfterControlSet.Buffer <= L'9') - { + IN PCUNICODE_STRING DriverRegistryPath, + OUT PUNICODE_STRING DeviceRegistryPath) +{ + static WCHAR RegistryMachineSystem[] = L"\\REGISTRY\\MACHINE\\SYSTEM\\"; + static WCHAR CurrentControlSet[] = L"CURRENTCONTROLSET\\"; + static WCHAR ControlSet[] = L"CONTROLSET"; + static WCHAR Insert1[] = L"Hardware Profiles\\Current\\System\\CurrentControlSet\\"; + static WCHAR Insert2[] = L"\\Device0"; + BOOLEAN Valid; + UNICODE_STRING AfterControlSet; + + AfterControlSet = *DriverRegistryPath; + + /* Check if path begins with \\REGISTRY\\MACHINE\\SYSTEM\\ */ + Valid = (DriverRegistryPath->Length > sizeof(RegistryMachineSystem) && + 0 == _wcsnicmp(DriverRegistryPath->Buffer, RegistryMachineSystem, + wcslen(RegistryMachineSystem))); + if (Valid) + { + AfterControlSet.Buffer += wcslen(RegistryMachineSystem); + AfterControlSet.Length -= sizeof(RegistryMachineSystem) - sizeof(UNICODE_NULL); + + /* Check if path contains CURRENTCONTROLSET */ + if (AfterControlSet.Length > sizeof(CurrentControlSet) && + 0 == _wcsnicmp(AfterControlSet.Buffer, CurrentControlSet, wcslen(CurrentControlSet))) + { + AfterControlSet.Buffer += wcslen(CurrentControlSet); + AfterControlSet.Length -= sizeof(CurrentControlSet) - sizeof(UNICODE_NULL); + } + /* Check if path contains CONTROLSETnum */ + else if (AfterControlSet.Length > sizeof(ControlSet) && + 0 == _wcsnicmp(AfterControlSet.Buffer, ControlSet, wcslen(ControlSet))) + { + AfterControlSet.Buffer += wcslen(ControlSet); + AfterControlSet.Length -= sizeof(ControlSet) - sizeof(UNICODE_NULL); + while (AfterControlSet.Length > 0 && + *AfterControlSet.Buffer >= L'0' && + *AfterControlSet.Buffer <= L'9') + { + AfterControlSet.Buffer++; + AfterControlSet.Length -= sizeof(WCHAR); + } + + Valid = (AfterControlSet.Length > 0 && L'\\' == *AfterControlSet.Buffer); AfterControlSet.Buffer++; AfterControlSet.Length -= sizeof(WCHAR); - } - Valid = (AfterControlSet.Length > 0 && L'\\' == *AfterControlSet.Buffer); - AfterControlSet.Buffer++; - AfterControlSet.Length -= sizeof(WCHAR); - AfterControlSet.MaximumLength = AfterControlSet.Length; - } - else - { - Valid = FALSE; - } - } - - if (Valid) - { - DeviceRegistryPath->MaximumLength = DriverRegistryPath->Length + sizeof(Insert1) + sizeof(Insert2); - DeviceRegistryPath->Buffer = ExAllocatePoolWithTag(PagedPool, - DeviceRegistryPath->MaximumLength, - TAG_VIDEO_PORT); - if (DeviceRegistryPath->Buffer != NULL) - { - /* Build device path */ - wcsncpy(DeviceRegistryPath->Buffer, - DriverRegistryPath->Buffer, - AfterControlSet.Buffer - DriverRegistryPath->Buffer); - DeviceRegistryPath->Length = (AfterControlSet.Buffer - DriverRegistryPath->Buffer) * sizeof(WCHAR); - RtlAppendUnicodeToString(DeviceRegistryPath, Insert1); - RtlAppendUnicodeStringToString(DeviceRegistryPath, &AfterControlSet); - RtlAppendUnicodeToString(DeviceRegistryPath, Insert2); - - /* Check if registry key exists */ - Valid = NT_SUCCESS(RtlCheckRegistryKey(RTL_REGISTRY_ABSOLUTE, DeviceRegistryPath->Buffer)); - - if (!Valid) - ExFreePoolWithTag(DeviceRegistryPath->Buffer, TAG_VIDEO_PORT); - } - else - { - Valid = FALSE; - } - } - else - { - WARN_(VIDEOPRT, "Unparsable registry path %wZ", DriverRegistryPath); - } - - /* If path doesn't point to *ControlSet*, use DriverRegistryPath directly */ - if (!Valid) - { - DeviceRegistryPath->MaximumLength = DriverRegistryPath->Length + sizeof(Insert2); - DeviceRegistryPath->Buffer = ExAllocatePoolWithTag( - NonPagedPool, - DeviceRegistryPath->MaximumLength, - TAG_VIDEO_PORT); - - if (!DeviceRegistryPath->Buffer) - return STATUS_NO_MEMORY; - - RtlCopyUnicodeString(DeviceRegistryPath, DriverRegistryPath); - RtlAppendUnicodeToString(DeviceRegistryPath, Insert2); - } - - return STATUS_SUCCESS; -} - -NTSTATUS NTAPI + AfterControlSet.MaximumLength = AfterControlSet.Length; + } + else + { + Valid = FALSE; + } + } + + if (Valid) + { + DeviceRegistryPath->MaximumLength = DriverRegistryPath->Length + sizeof(Insert1) + sizeof(Insert2); + DeviceRegistryPath->Buffer = ExAllocatePoolWithTag(PagedPool, + DeviceRegistryPath->MaximumLength, + TAG_VIDEO_PORT); + if (DeviceRegistryPath->Buffer != NULL) + { + /* Build device path */ + wcsncpy(DeviceRegistryPath->Buffer, + DriverRegistryPath->Buffer, + AfterControlSet.Buffer - DriverRegistryPath->Buffer); + DeviceRegistryPath->Length = (AfterControlSet.Buffer - DriverRegistryPath->Buffer) * sizeof(WCHAR); + RtlAppendUnicodeToString(DeviceRegistryPath, Insert1); + RtlAppendUnicodeStringToString(DeviceRegistryPath, &AfterControlSet); + RtlAppendUnicodeToString(DeviceRegistryPath, Insert2); + + /* Check if registry key exists */ + Valid = NT_SUCCESS(RtlCheckRegistryKey(RTL_REGISTRY_ABSOLUTE, DeviceRegistryPath->Buffer)); + + if (!Valid) + ExFreePoolWithTag(DeviceRegistryPath->Buffer, TAG_VIDEO_PORT); + } + else + { + Valid = FALSE; + } + } + else + { + WARN_(VIDEOPRT, "Unparsable registry path %wZ", DriverRegistryPath); + } + + /* If path doesn't point to *ControlSet*, use DriverRegistryPath directly */ + if (!Valid) + { + DeviceRegistryPath->MaximumLength = DriverRegistryPath->Length + sizeof(Insert2); + DeviceRegistryPath->Buffer = ExAllocatePoolWithTag(NonPagedPool, + DeviceRegistryPath->MaximumLength, + TAG_VIDEO_PORT); + + if (!DeviceRegistryPath->Buffer) + return STATUS_NO_MEMORY; + + RtlCopyUnicodeString(DeviceRegistryPath, DriverRegistryPath); + RtlAppendUnicodeToString(DeviceRegistryPath, Insert2); + } + + return STATUS_SUCCESS; +} + +NTSTATUS +NTAPI IntVideoPortCreateAdapterDeviceObject( - IN PDRIVER_OBJECT DriverObject, - IN PVIDEO_PORT_DRIVER_EXTENSION DriverExtension, - IN PDEVICE_OBJECT PhysicalDeviceObject, - OUT PDEVICE_OBJECT *DeviceObject OPTIONAL) -{ - PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension; - ULONG DeviceNumber; - ULONG PciSlotNumber; - PCI_SLOT_NUMBER SlotNumber; - ULONG Size; - NTSTATUS Status; - WCHAR DeviceBuffer[20]; - UNICODE_STRING DeviceName; - PDEVICE_OBJECT DeviceObject_; - - if (DeviceObject == NULL) - DeviceObject = &DeviceObject_; - - /* - * Find the first free device number that can be used for video device - * object names and symlinks. - */ - - DeviceNumber = VideoPortDeviceNumber; - if (DeviceNumber == 0xFFFFFFFF) - { - WARN_(VIDEOPRT, "Can't find free device number\n"); - return STATUS_UNSUCCESSFUL; - } - - /* - * Create the device object. - */ - - /* Create a unicode device name. */ - swprintf(DeviceBuffer, L"\\Device\\Video%lu", DeviceNumber); - RtlInitUnicodeString(&DeviceName, DeviceBuffer); - - INFO_(VIDEOPRT, "HwDeviceExtension size is: 0x%x\n", - DriverExtension->InitializationData.HwDeviceExtensionSize); - - /* Create the device object. */ - Status = IoCreateDevice( - DriverObject, - sizeof(VIDEO_PORT_DEVICE_EXTENSION) + - DriverExtension->InitializationData.HwDeviceExtensionSize, - &DeviceName, - FILE_DEVICE_VIDEO, - 0, - TRUE, - DeviceObject); - - if (!NT_SUCCESS(Status)) - { - WARN_(VIDEOPRT, "IoCreateDevice call failed with status 0x%08x\n", Status); - return Status; - } - - /* - * Set the buffering strategy here. If you change this, remember - * to change VidDispatchDeviceControl too. - */ - - (*DeviceObject)->Flags |= DO_BUFFERED_IO; - - /* - * Initialize device extension. - */ - - DeviceExtension = (PVIDEO_PORT_DEVICE_EXTENSION)((*DeviceObject)->DeviceExtension); - DeviceExtension->Common.Fdo = TRUE; - DeviceExtension->DeviceNumber = DeviceNumber; - DeviceExtension->DriverObject = DriverObject; - DeviceExtension->PhysicalDeviceObject = PhysicalDeviceObject; - DeviceExtension->FunctionalDeviceObject = *DeviceObject; - DeviceExtension->DriverExtension = DriverExtension; - - InitializeListHead(&DeviceExtension->ChildDeviceList); - - /* - * Get the registry path associated with this driver. - */ - - Status = IntCreateRegistryPath( - &DriverExtension->RegistryPath, - &DeviceExtension->RegistryPath); - if (!NT_SUCCESS(Status)) - { - WARN_(VIDEOPRT, "IntCreateRegistryPath() call failed with status 0x%08x\n", Status); - IoDeleteDevice(*DeviceObject); - *DeviceObject = NULL; - return Status; - } - - if (PhysicalDeviceObject != NULL) - { - /* Get bus number from the upper level bus driver. */ - Size = sizeof(ULONG); - Status = IoGetDeviceProperty( - PhysicalDeviceObject, - DevicePropertyBusNumber, - Size, - &DeviceExtension->SystemIoBusNumber, - &Size); - if (!NT_SUCCESS(Status)) - { - WARN_(VIDEOPRT, "Couldn't get an information from bus driver. We will try to\n" - "use legacy detection method, but even that doesn't mean that\n" - "it will work.\n"); - DeviceExtension->PhysicalDeviceObject = NULL; - } - } - - DeviceExtension->AdapterInterfaceType = - DriverExtension->InitializationData.AdapterInterfaceType; - - if (PhysicalDeviceObject != NULL) - { - /* Get bus type from the upper level bus driver. */ - Size = sizeof(ULONG); - IoGetDeviceProperty( - PhysicalDeviceObject, - DevicePropertyLegacyBusType, - Size, - &DeviceExtension->AdapterInterfaceType, - &Size); - - /* Get bus device address from the upper level bus driver. */ - Size = sizeof(ULONG); - IoGetDeviceProperty( - PhysicalDeviceObject, - DevicePropertyAddress, - Size, - &PciSlotNumber, - &Size); + IN PDRIVER_OBJECT DriverObject, + IN PVIDEO_PORT_DRIVER_EXTENSION DriverExtension, + IN PDEVICE_OBJECT PhysicalDeviceObject, + OUT PDEVICE_OBJECT *DeviceObject OPTIONAL) +{ + PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension; + ULONG DeviceNumber; + ULONG PciSlotNumber; + PCI_SLOT_NUMBER SlotNumber; + ULONG Size; + NTSTATUS Status; + WCHAR DeviceBuffer[20]; + UNICODE_STRING DeviceName; + PDEVICE_OBJECT DeviceObject_; + + if (DeviceObject == NULL) + DeviceObject = &DeviceObject_; + + /* + * Find the first free device number that can be used for video device + * object names and symlinks. + */ + DeviceNumber = VideoPortDeviceNumber; + if (DeviceNumber == 0xFFFFFFFF) + { + WARN_(VIDEOPRT, "Can't find free device number\n"); + return STATUS_UNSUCCESSFUL; + } + + /* + * Create the device object. + */ + + /* Create a unicode device name. */ + swprintf(DeviceBuffer, L"\\Device\\Video%lu", DeviceNumber); + RtlInitUnicodeString(&DeviceName, DeviceBuffer); + + INFO_(VIDEOPRT, "HwDeviceExtension size is: 0x%x\n", + DriverExtension->InitializationData.HwDeviceExtensionSize); + + /* Create the device object. */ + Status = IoCreateDevice( + DriverObject, + sizeof(VIDEO_PORT_DEVICE_EXTENSION) + + DriverExtension->InitializationData.HwDeviceExtensionSize, + &DeviceName, + FILE_DEVICE_VIDEO, + 0, + TRUE, + DeviceObject); + + if (!NT_SUCCESS(Status)) + { + WARN_(VIDEOPRT, "IoCreateDevice call failed with status 0x%08x\n", Status); + return Status; + } + + /* + * Set the buffering strategy here. If you change this, remember + * to change VidDispatchDeviceControl too. + */ + + (*DeviceObject)->Flags |= DO_BUFFERED_IO; + + /* Initialize device extension. */ + DeviceExtension = (PVIDEO_PORT_DEVICE_EXTENSION)((*DeviceObject)->DeviceExtension); + DeviceExtension->Common.Fdo = TRUE; + DeviceExtension->DeviceNumber = DeviceNumber; + DeviceExtension->DriverObject = DriverObject; + DeviceExtension->PhysicalDeviceObject = PhysicalDeviceObject; + DeviceExtension->FunctionalDeviceObject = *DeviceObject; + DeviceExtension->DriverExtension = DriverExtension; + + InitializeListHead(&DeviceExtension->ChildDeviceList); + + /* Get the registry path associated with this driver. */ + Status = IntCreateRegistryPath(&DriverExtension->RegistryPath, + &DeviceExtension->RegistryPath); + if (!NT_SUCCESS(Status)) + { + WARN_(VIDEOPRT, "IntCreateRegistryPath() call failed with status 0x%08x\n", Status); + IoDeleteDevice(*DeviceObject); + *DeviceObject = NULL; + return Status; + } + + if (PhysicalDeviceObject != NULL) + { + /* Get bus number from the upper level bus driver. */ + Size = sizeof(ULONG); + Status = IoGetDeviceProperty( + PhysicalDeviceObject, + DevicePropertyBusNumber, + Size, + &DeviceExtension->SystemIoBusNumber, + &Size); + if (!NT_SUCCESS(Status)) + { + WARN_(VIDEOPRT, "Couldn't get an information from bus driver. We will try to\n" + "use legacy detection method, but even that doesn't mean that\n" + "it will work.\n"); + DeviceExtension->PhysicalDeviceObject = NULL; + } + } + + DeviceExtension->AdapterInterfaceType = + DriverExtension->InitializationData.AdapterInterfaceType; + + if (PhysicalDeviceObject != NULL) + { + /* Get bus type from the upper level bus driver. */ + Size = sizeof(ULONG); + IoGetDeviceProperty(PhysicalDeviceObject, + DevicePropertyLegacyBusType, + Size, + &DeviceExtension->AdapterInterfaceType, + &Size); + + /* Get bus device address from the upper level bus driver. */ + Size = sizeof(ULONG); + IoGetDeviceProperty(PhysicalDeviceObject, + DevicePropertyAddress, + Size, + &PciSlotNumber, + &Size); /* Convert slotnumber to PCI_SLOT_NUMBER */ SlotNumber.u.AsULONG = 0; SlotNumber.u.bits.DeviceNumber = (PciSlotNumber >> 16) & 0xFFFF; SlotNumber.u.bits.FunctionNumber = PciSlotNumber & 0xFFFF; DeviceExtension->SystemIoSlotNumber = SlotNumber.u.AsULONG; - } - - InitializeListHead(&DeviceExtension->AddressMappingListHead); - InitializeListHead(&DeviceExtension->DmaAdapterList); - - KeInitializeDpc( - &DeviceExtension->DpcObject, - IntVideoPortDeferredRoutine, - DeviceExtension); - - KeInitializeMutex(&DeviceExtension->DeviceLock, 0); - - /* Attach the device. */ - if (PhysicalDeviceObject != NULL) - DeviceExtension->NextDeviceObject = IoAttachDeviceToDeviceStack( - *DeviceObject, PhysicalDeviceObject); - - /* Remove the initailizing flag */ - (*DeviceObject)->Flags &= ~DO_DEVICE_INITIALIZING; - return STATUS_SUCCESS; -} - - -NTSTATUS NTAPI + } + + InitializeListHead(&DeviceExtension->AddressMappingListHead); + InitializeListHead(&DeviceExtension->DmaAdapterList); + + KeInitializeDpc(&DeviceExtension->DpcObject, + IntVideoPortDeferredRoutine, + DeviceExtension); + + KeInitializeMutex(&DeviceExtension->DeviceLock, 0); + + /* Attach the device. */ + if (PhysicalDeviceObject != NULL) + DeviceExtension->NextDeviceObject = IoAttachDeviceToDeviceStack( + *DeviceObject, + PhysicalDeviceObject); + + /* Remove the initailizing flag */ + (*DeviceObject)->Flags &= ~DO_DEVICE_INITIALIZING; + return STATUS_SUCCESS; +} + + +NTSTATUS +NTAPI IntVideoPortFindAdapter( - IN PDRIVER_OBJECT DriverObject, - IN PVIDEO_PORT_DRIVER_EXTENSION DriverExtension, - IN PDEVICE_OBJECT DeviceObject) -{ - WCHAR DeviceVideoBuffer[20]; - PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension; - SIZE_T Size; - NTSTATUS Status; - VIDEO_PORT_CONFIG_INFO ConfigInfo; - SYSTEM_BASIC_INFORMATION SystemBasicInfo; - UCHAR Again = FALSE; - WCHAR DeviceBuffer[20]; - UNICODE_STRING DeviceName; - WCHAR SymlinkBuffer[20]; - UNICODE_STRING SymlinkName; - BOOL LegacyDetection = FALSE; - ULONG DeviceNumber; - - DeviceExtension = (PVIDEO_PORT_DEVICE_EXTENSION)DeviceObject->DeviceExtension; - DeviceNumber = DeviceExtension->DeviceNumber; - - /* - * Setup a ConfigInfo structure that we will pass to HwFindAdapter. - */ - - RtlZeroMemory(&ConfigInfo, sizeof(VIDEO_PORT_CONFIG_INFO)); - ConfigInfo.Length = sizeof(VIDEO_PORT_CONFIG_INFO); - ConfigInfo.AdapterInterfaceType = DeviceExtension->AdapterInterfaceType; - if (ConfigInfo.AdapterInterfaceType == PCIBus) - ConfigInfo.InterruptMode = LevelSensitive; - else - ConfigInfo.InterruptMode = Latched; - ConfigInfo.DriverRegistryPath = DriverExtension->RegistryPath.Buffer; - ConfigInfo.VideoPortGetProcAddress = IntVideoPortGetProcAddress; - ConfigInfo.SystemIoBusNumber = DeviceExtension->SystemIoBusNumber; - ConfigInfo.BusInterruptLevel = DeviceExtension->InterruptLevel; - ConfigInfo.BusInterruptVector = DeviceExtension->InterruptVector; - - Size = sizeof(SystemBasicInfo); - Status = ZwQuerySystemInformation( - SystemBasicInformation, - &SystemBasicInfo, - Size, - &Size); - - if (NT_SUCCESS(Status)) - { - ConfigInfo.SystemMemorySize = - SystemBasicInfo.NumberOfPhysicalPages * - SystemBasicInfo.PageSize; - } - - /* - * Call miniport HwVidFindAdapter entry point to detect if - * particular device is present. There are two possible code - * paths. The first one is for Legacy drivers (NT4) and cases - * when we don't have information about what bus we're on. The - * second case is the standard one for Plug & Play drivers. - */ - if (DeviceExtension->PhysicalDeviceObject == NULL) - { - LegacyDetection = TRUE; - } - - if (LegacyDetection) - { - ULONG BusNumber, MaxBuses; - - MaxBuses = DeviceExtension->AdapterInterfaceType == PCIBus ? PCI_MAX_BRIDGE_NUMBER : 1; - - for (BusNumber = 0; BusNumber < MaxBuses; BusNumber++) - { - DeviceExtension->SystemIoBusNumber = - ConfigInfo.SystemIoBusNumber = BusNumber; - - RtlZeroMemory(&DeviceExtension->MiniPortDeviceExtension, - DriverExtension->InitializationData.HwDeviceExtensionSize); - - /* FIXME: Need to figure out what string to pass as param 3. */ - Status = DriverExtension->InitializationData.HwFindAdapter( - &DeviceExtension->MiniPortDeviceExtension, - DriverExtension->HwContext, - NULL, - &ConfigInfo, - &Again); - - if (Status == ERROR_DEV_NOT_EXIST) - { - continue; - } - else if (Status == NO_ERROR) - { + IN PDRIVER_OBJECT DriverObject, + IN PVIDEO_PORT_DRIVER_EXTENSION DriverExtension, + IN PDEVICE_OBJECT DeviceObject) +{ + WCHAR DeviceVideoBuffer[20]; + PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension; + SIZE_T Size; + NTSTATUS Status; + VIDEO_PORT_CONFIG_INFO ConfigInfo; + SYSTEM_BASIC_INFORMATION SystemBasicInfo; + UCHAR Again = FALSE; + WCHAR DeviceBuffer[20]; + UNICODE_STRING DeviceName; + WCHAR SymlinkBuffer[20]; + UNICODE_STRING SymlinkName; + BOOL LegacyDetection = FALSE; + ULONG DeviceNumber; + + DeviceExtension = (PVIDEO_PORT_DEVICE_EXTENSION)DeviceObject->DeviceExtension; + DeviceNumber = DeviceExtension->DeviceNumber; + + /* Setup a ConfigInfo structure that we will pass to HwFindAdapter. */ + RtlZeroMemory(&ConfigInfo, sizeof(VIDEO_PORT_CONFIG_INFO)); + ConfigInfo.Length = sizeof(VIDEO_PORT_CONFIG_INFO); + ConfigInfo.AdapterInterfaceType = DeviceExtension->AdapterInterfaceType; + if (ConfigInfo.AdapterInterfaceType == PCIBus) + ConfigInfo.InterruptMode = LevelSensitive; + else + ConfigInfo.InterruptMode = Latched; + ConfigInfo.DriverRegistryPath = DriverExtension->RegistryPath.Buffer; + ConfigInfo.VideoPortGetProcAddress = IntVideoPortGetProcAddress; + ConfigInfo.SystemIoBusNumber = DeviceExtension->SystemIoBusNumber; + ConfigInfo.BusInterruptLevel = DeviceExtension->InterruptLevel; + ConfigInfo.BusInterruptVector = DeviceExtension->InterruptVector; + + Size = sizeof(SystemBasicInfo); + Status = ZwQuerySystemInformation(SystemBasicInformation, + &SystemBasicInfo, + Size, + &Size); + if (NT_SUCCESS(Status)) + { + ConfigInfo.SystemMemorySize = SystemBasicInfo.NumberOfPhysicalPages * + SystemBasicInfo.PageSize; + } + + /* + * Call miniport HwVidFindAdapter entry point to detect if + * particular device is present. There are two possible code + * paths. The first one is for Legacy drivers (NT4) and cases + * when we don't have information about what bus we're on. The + * second case is the standard one for Plug & Play drivers. + */ + if (DeviceExtension->PhysicalDeviceObject == NULL) + { + LegacyDetection = TRUE; + } + + if (LegacyDetection) + { + ULONG BusNumber, MaxBuses; + + MaxBuses = DeviceExtension->AdapterInterfaceType == PCIBus ? PCI_MAX_BRIDGE_NUMBER : 1; + + for (BusNumber = 0; BusNumber < MaxBuses; BusNumber++) + { + DeviceExtension->SystemIoBusNumber = + ConfigInfo.SystemIoBusNumber = BusNumber; + + RtlZeroMemory(&DeviceExtension->MiniPortDeviceExtension, + DriverExtension->InitializationData.HwDeviceExtensionSize); + + /* FIXME: Need to figure out what string to pass as param 3. */ + Status = DriverExtension->InitializationData.HwFindAdapter( + &DeviceExtension->MiniPortDeviceExtension, + DriverExtension->HwContext, + NULL, + &ConfigInfo, + &Again); + + if (Status == ERROR_DEV_NOT_EXIST) + { + continue; + } + else if (Status == NO_ERROR) + { + break; + } + else + { + ERR_(VIDEOPRT, "HwFindAdapter call failed with error 0x%X\n", Status); + RtlFreeUnicodeString(&DeviceExtension->RegistryPath); + if (DeviceExtension->NextDeviceObject) + IoDetachDevice(DeviceExtension->NextDeviceObject); + IoDeleteDevice(DeviceObject); + + return Status; + } + } + } + else + { + /* FIXME: Need to figure out what string to pass as param 3. */ + Status = DriverExtension->InitializationData.HwFindAdapter( + &DeviceExtension->MiniPortDeviceExtension, + DriverExtension->HwContext, + NULL, + &ConfigInfo, + &Again); + } + + if (Status != NO_ERROR) + { + ERR_(VIDEOPRT, "HwFindAdapter call failed with error 0x%X\n", Status); + RtlFreeUnicodeString(&DeviceExtension->RegistryPath); + if (DeviceExtension->NextDeviceObject) + IoDetachDevice(DeviceExtension->NextDeviceObject); + IoDeleteDevice(DeviceObject); + return Status; + } + + /* + * Now we know the device is present, so let's do all additional tasks + * such as creating symlinks or setting up interrupts and timer. + */ + + /* Create a unicode device name. */ + swprintf(DeviceBuffer, L"\\Device\\Video%lu", DeviceNumber); + RtlInitUnicodeString(&DeviceName, DeviceBuffer); + + /* Create symbolic link "\??\DISPLAYx" */ + swprintf(SymlinkBuffer, L"\\??\\DISPLAY%lu", DeviceNumber + 1); + RtlInitUnicodeString(&SymlinkName, SymlinkBuffer); + IoCreateSymbolicLink(&SymlinkName, &DeviceName); + + /* Add entry to DEVICEMAP\VIDEO key in registry. */ + swprintf(DeviceVideoBuffer, L"\\Device\\Video%d", DeviceNumber); + RtlWriteRegistryValue( + RTL_REGISTRY_DEVICEMAP, + L"VIDEO", + DeviceVideoBuffer, + REG_SZ, + DeviceExtension->RegistryPath.Buffer, + DeviceExtension->RegistryPath.Length + sizeof(UNICODE_NULL)); + + RtlWriteRegistryValue( + RTL_REGISTRY_DEVICEMAP, + L"VIDEO", + L"MaxObjectNumber", + REG_DWORD, + &DeviceNumber, + sizeof(DeviceNumber)); + + /* FIXME: Allocate hardware resources for device. */ + + /* Allocate interrupt for device. */ + if (!IntVideoPortSetupInterrupt(DeviceObject, DriverExtension, &ConfigInfo)) + { + RtlFreeUnicodeString(&DeviceExtension->RegistryPath); + if (DeviceExtension->NextDeviceObject) + IoDetachDevice(DeviceExtension->NextDeviceObject); + IoDeleteDevice(DeviceObject); + return STATUS_INSUFFICIENT_RESOURCES; + } + + /* + * Allocate timer for device. + */ + + if (!IntVideoPortSetupTimer(DeviceObject, DriverExtension)) + { + if (DeviceExtension->InterruptObject != NULL) + IoDisconnectInterrupt(DeviceExtension->InterruptObject); + if (DeviceExtension->NextDeviceObject) + IoDetachDevice(DeviceExtension->NextDeviceObject); + RtlFreeUnicodeString(&DeviceExtension->RegistryPath); + IoDeleteDevice(DeviceObject); + ERR_(VIDEOPRT, "IntVideoPortSetupTimer failed\n"); + return STATUS_INSUFFICIENT_RESOURCES; + } + + /* Query children of the device. */ + VideoPortEnumerateChildren(&DeviceExtension->MiniPortDeviceExtension, NULL); + + INFO_(VIDEOPRT, "STATUS_SUCCESS\n"); + return STATUS_SUCCESS; +} + +VOID +FASTCALL +IntAttachToCSRSS( + PKPROCESS *CallingProcess, + PKAPC_STATE ApcState) +{ + *CallingProcess = (PKPROCESS)PsGetCurrentProcess(); + if (*CallingProcess != Csrss) + { + KeStackAttachProcess(Csrss, ApcState); + } +} + +VOID +FASTCALL +IntDetachFromCSRSS( + PKPROCESS *CallingProcess, + PKAPC_STATE ApcState) +{ + if (*CallingProcess != Csrss) + { + KeUnstackDetachProcess(ApcState); + } +} + +/* PUBLIC FUNCTIONS ***********************************************************/ + +/* + * @implemented + */ +ULONG +NTAPI +VideoPortInitialize( + IN PVOID Context1, + IN PVOID Context2, + IN PVIDEO_HW_INITIALIZATION_DATA HwInitializationData, + IN PVOID HwContext) +{ + PDRIVER_OBJECT DriverObject = Context1; + PUNICODE_STRING RegistryPath = Context2; + NTSTATUS Status; + PVIDEO_PORT_DRIVER_EXTENSION DriverExtension; + BOOLEAN PnpDriver = FALSE, LegacyDetection = FALSE; + + TRACE_(VIDEOPRT, "VideoPortInitialize\n"); + + /* As a first thing do parameter checks. */ + if (HwInitializationData->HwInitDataSize > sizeof(VIDEO_HW_INITIALIZATION_DATA)) + { + ERR_(VIDEOPRT, "Invalid HwInitializationData\n"); + return STATUS_REVISION_MISMATCH; + } + + if (HwInitializationData->HwFindAdapter == NULL || + HwInitializationData->HwInitialize == NULL || + HwInitializationData->HwStartIO == NULL) + { + ERR_(VIDEOPRT, "Invalid HwInitializationData\n"); + return STATUS_INVALID_PARAMETER; + } + + switch (HwInitializationData->HwInitDataSize) + { + /* + * NT4 drivers are special case, because we must use legacy method + * of detection instead of the Plug & Play one. + */ + case SIZE_OF_NT4_VIDEO_HW_INITIALIZATION_DATA: + INFO_(VIDEOPRT, "We were loaded by a Windows NT miniport driver.\n"); break; - } - else - { - ERR_(VIDEOPRT, "HwFindAdapter call failed with error 0x%X\n", Status); - RtlFreeUnicodeString(&DeviceExtension->RegistryPath); - if (DeviceExtension->NextDeviceObject) - IoDetachDevice(DeviceExtension->NextDeviceObject); - IoDeleteDevice(DeviceObject); - + + case SIZE_OF_W2K_VIDEO_HW_INITIALIZATION_DATA: + INFO_(VIDEOPRT, "We were loaded by a Windows 2000 miniport driver.\n"); + break; + + case sizeof(VIDEO_HW_INITIALIZATION_DATA): + INFO_(VIDEOPRT, "We were loaded by a Windows XP or later miniport driver.\n"); + break; + + default: + ERR_(VIDEOPRT, "Invalid HwInitializationData size.\n"); + return STATUS_UNSUCCESSFUL; + } + + /* Set dispatching routines */ + DriverObject->MajorFunction[IRP_MJ_CREATE] = IntVideoPortDispatchOpen; + DriverObject->MajorFunction[IRP_MJ_CLOSE] = IntVideoPortDispatchClose; + DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = + IntVideoPortDispatchDeviceControl; + DriverObject->MajorFunction[IRP_MJ_INTERNAL_DEVICE_CONTROL] = + IntVideoPortDispatchDeviceControl; + DriverObject->MajorFunction[IRP_MJ_WRITE] = + IntVideoPortDispatchWrite; // ReactOS-specific hack + DriverObject->DriverUnload = IntVideoPortUnload; + + /* Determine type of the miniport driver */ + if ((HwInitializationData->HwInitDataSize >= + FIELD_OFFSET(VIDEO_HW_INITIALIZATION_DATA, HwQueryInterface)) + && HwInitializationData->HwSetPowerState + && HwInitializationData->HwGetPowerState + && HwInitializationData->HwGetVideoChildDescriptor) + { + INFO_(VIDEOPRT, "The miniport is a PnP miniport driver\n"); + PnpDriver = TRUE; + } + + /* Check if legacy detection should be applied */ + if (!PnpDriver || HwContext) + { + INFO_(VIDEOPRT, "Legacy detection for adapter interface %d\n", + HwInitializationData->AdapterInterfaceType); + + /* FIXME: Move the code for legacy detection + to another function and call it here */ + LegacyDetection = TRUE; + } + + /* + * NOTE: + * The driver extension can be already allocated in case that we were + * called by legacy driver and failed detecting device. Some miniport + * drivers in that case adjust parameters and call VideoPortInitialize + * again. + */ + DriverExtension = IoGetDriverObjectExtension(DriverObject, DriverObject); + if (DriverExtension == NULL) + { + Status = IoAllocateDriverObjectExtension( + DriverObject, + DriverObject, + sizeof(VIDEO_PORT_DRIVER_EXTENSION), + (PVOID *)&DriverExtension); + + if (!NT_SUCCESS(Status)) + { + ERR_(VIDEOPRT, "IoAllocateDriverObjectExtension failed 0x%x\n", Status); return Status; - } - } - } - else - { - /* FIXME: Need to figure out what string to pass as param 3. */ - Status = DriverExtension->InitializationData.HwFindAdapter( - &DeviceExtension->MiniPortDeviceExtension, - DriverExtension->HwContext, - NULL, - &ConfigInfo, - &Again); - } - - if (Status != NO_ERROR) - { - ERR_(VIDEOPRT, "HwFindAdapter call failed with error 0x%X\n", Status); - RtlFreeUnicodeString(&DeviceExtension->RegistryPath); - if (DeviceExtension->NextDeviceObject) - IoDetachDevice(DeviceExtension->NextDeviceObject); - IoDeleteDevice(DeviceObject); - return Status; - } - - /* - * Now we know the device is present, so let's do all additional tasks - * such as creating symlinks or setting up interrupts and timer. - */ - - /* Create a unicode device name. */ - swprintf(DeviceBuffer, L"\\Device\\Video%lu", DeviceNumber); - RtlInitUnicodeString(&DeviceName, DeviceBuffer); - - /* Create symbolic link "\??\DISPLAYx" */ - swprintf(SymlinkBuffer, L"\\??\\DISPLAY%lu", DeviceNumber + 1); - RtlInitUnicodeString(&SymlinkName, SymlinkBuffer); - IoCreateSymbolicLink(&SymlinkName, &DeviceName); - - /* Add entry to DEVICEMAP\VIDEO key in registry. */ - swprintf(DeviceVideoBuffer, L"\\Device\\Video%d", DeviceNumber); - RtlWriteRegistryValue( - RTL_REGISTRY_DEVICEMAP, - L"VIDEO", - DeviceVideoBuffer, - REG_SZ, - DeviceExtension->RegistryPath.Buffer, - DeviceExtension->RegistryPath.Length + sizeof(UNICODE_NULL)); - - RtlWriteRegistryValue( - RTL_REGISTRY_DEVICEMAP, - L"VIDEO", - L"MaxObjectNumber", - REG_DWORD, - &DeviceNumber, - sizeof(DeviceNumber)); - - /* FIXME: Allocate hardware resources for device. */ - - /* - * Allocate interrupt for device. - */ - - if (!IntVideoPortSetupInterrupt(DeviceObject, DriverExtension, &ConfigInfo)) - { - RtlFreeUnicodeString(&DeviceExtension->RegistryPath); - if (DeviceExtension->NextDeviceObject) - IoDetachDevice(DeviceExtension->NextDeviceObject); - IoDeleteDevice(DeviceObject); - return STATUS_INSUFFICIENT_RESOURCES; - } - - /* - * Allocate timer for device. - */ - - if (!IntVideoPortSetupTimer(DeviceObject, DriverExtension)) - { - if (DeviceExtension->InterruptObject != NULL) - IoDisconnectInterrupt(DeviceExtension->InterruptObject); - if (DeviceExtension->NextDeviceObject) - IoDetachDevice(DeviceExtension->NextDeviceObject); - RtlFreeUnicodeString(&DeviceExtension->RegistryPath); - IoDeleteDevice(DeviceObject); - ERR_(VIDEOPRT, "IntVideoPortSetupTimer failed\n"); - return STATUS_INSUFFICIENT_RESOURCES; - } - - /* - * Query children of the device. - */ - VideoPortEnumerateChildren(&DeviceExtension->MiniPortDeviceExtension, NULL); - - INFO_(VIDEOPRT, "STATUS_SUCCESS\n"); - return STATUS_SUCCESS; -} - -VOID FASTCALL -IntAttachToCSRSS(PKPROCESS *CallingProcess, PKAPC_STATE ApcState) -{ - *CallingProcess = (PKPROCESS)PsGetCurrentProcess(); - if (*CallingProcess != Csrss) - { - KeStackAttachProcess(Csrss, ApcState); - } -} - -VOID FASTCALL -IntDetachFromCSRSS(PKPROCESS *CallingProcess, PKAPC_STATE ApcState) -{ - if (*CallingProcess != Csrss) - { - KeUnstackDetachProcess(ApcState); - } -} - -/* PUBLIC FUNCTIONS ***********************************************************/ - -/* - * @implemented - */ - -ULONG NTAPI -VideoPortInitialize( - IN PVOID Context1, - IN PVOID Context2, - IN PVIDEO_HW_INITIALIZATION_DATA HwInitializationData, - IN PVOID HwContext) -{ - PDRIVER_OBJECT DriverObject = Context1; - PUNICODE_STRING RegistryPath = Context2; - NTSTATUS Status; - PVIDEO_PORT_DRIVER_EXTENSION DriverExtension; - BOOLEAN PnpDriver = FALSE, LegacyDetection = FALSE; - - TRACE_(VIDEOPRT, "VideoPortInitialize\n"); - - /* - * As a first thing do parameter checks. - */ - - if (HwInitializationData->HwInitDataSize > sizeof(VIDEO_HW_INITIALIZATION_DATA)) - { - ERR_(VIDEOPRT, "Invalid HwInitializationData\n"); - return STATUS_REVISION_MISMATCH; - } - - if (HwInitializationData->HwFindAdapter == NULL || - HwInitializationData->HwInitialize == NULL || - HwInitializationData->HwStartIO == NULL) - { - ERR_(VIDEOPRT, "Invalid HwInitializationData\n"); - return STATUS_INVALID_PARAMETER; - } - - switch (HwInitializationData->HwInitDataSize) - { - /* - * NT4 drivers are special case, because we must use legacy method - * of detection instead of the Plug & Play one. - */ - - case SIZE_OF_NT4_VIDEO_HW_INITIALIZATION_DATA: - INFO_(VIDEOPRT, "We were loaded by a Windows NT miniport driver.\n"); - break; - - case SIZE_OF_W2K_VIDEO_HW_INITIALIZATION_DATA: - INFO_(VIDEOPRT, "We were loaded by a Windows 2000 miniport driver.\n"); - break; - - case sizeof(VIDEO_HW_INITIALIZATION_DATA): - INFO_(VIDEOPRT, "We were loaded by a Windows XP or later miniport driver.\n"); - break; - - default: - ERR_(VIDEOPRT, "Invalid HwInitializationData size.\n"); - return STATUS_UNSUCCESSFUL; - } - - /* Set dispatching routines */ - DriverObject->MajorFunction[IRP_MJ_CREATE] = IntVideoPortDispatchOpen; - DriverObject->MajorFunction[IRP_MJ_CLOSE] = IntVideoPortDispatchClose; - DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = - IntVideoPortDispatchDeviceControl; - DriverObject->MajorFunction[IRP_MJ_INTERNAL_DEVICE_CONTROL] = - IntVideoPortDispatchDeviceControl; - DriverObject->MajorFunction[IRP_MJ_WRITE] = - IntVideoPortDispatchWrite; // ReactOS-specific hack - DriverObject->DriverUnload = IntVideoPortUnload; - - /* Determine type of the miniport driver */ - if ((HwInitializationData->HwInitDataSize >= - FIELD_OFFSET(VIDEO_HW_INITIALIZATION_DATA, HwQueryInterface)) - && HwInitializationData->HwSetPowerState - && HwInitializationData->HwGetPowerState - && HwInitializationData->HwGetVideoChildDescriptor) - { - INFO_(VIDEOPRT, "The miniport is a PnP miniport driver\n"); - PnpDriver = TRUE; - } - - /* Check if legacy detection should be applied */ - if (!PnpDriver || HwContext) - { - INFO_(VIDEOPRT, "Legacy detection for adapter interface %d\n", - HwInitializationData->AdapterInterfaceType); - - /* FIXME: Move the code for legacy detection - to another function and call it here */ - LegacyDetection = TRUE; - } - - /* - * NOTE: - * The driver extension can be already allocated in case that we were - * called by legacy driver and failed detecting device. Some miniport - * drivers in that case adjust parameters and call VideoPortInitialize - * again. - */ - - DriverExtension = IoGetDriverObjectExtension(DriverObject, DriverObject); - if (DriverExtension == NULL) - { - Status = IoAllocateDriverObjectExtension( - DriverObject, - DriverObject, - sizeof(VIDEO_PORT_DRIVER_EXTENSION), - (PVOID *)&DriverExtension); - - if (!NT_SUCCESS(Status)) - { - ERR_(VIDEOPRT, "IoAllocateDriverObjectExtension failed 0x%x\n", Status); - return Status; - } - - /* - * Save the registry path. This should be done only once even if - * VideoPortInitialize is called multiple times. - */ - - if (RegistryPath->Length != 0) - { - DriverExtension->RegistryPath.Length = 0; - DriverExtension->RegistryPath.MaximumLength = - RegistryPath->Length + sizeof(UNICODE_NULL); - DriverExtension->RegistryPath.Buffer = - ExAllocatePoolWithTag( - PagedPool, - DriverExtension->RegistryPath.MaximumLength, - 'RTSU'); - if (DriverExtension->RegistryPath.Buffer == NULL) - { + } + + /* + * Save the registry path. This should be done only once even if + * VideoPortInitialize is called multiple times. + */ + if (RegistryPath->Length != 0) + { + DriverExtension->RegistryPath.Length = 0; + DriverExtension->RegistryPath.MaximumLength = + RegistryPath->Length + sizeof(UNICODE_NULL); + DriverExtension->RegistryPath.Buffer = + ExAllocatePoolWithTag( + PagedPool, + DriverExtension->RegistryPath.MaximumLength, + 'RTSU'); + if (DriverExtension->RegistryPath.Buffer == NULL) + { + RtlInitUnicodeString(&DriverExtension->RegistryPath, NULL); + return STATUS_INSUFFICIENT_RESOURCES; + } + + RtlCopyUnicodeString(&DriverExtension->RegistryPath, RegistryPath); + INFO_(VIDEOPRT, "RegistryPath: %wZ\n", &DriverExtension->RegistryPath); + } + else + { RtlInitUnicodeString(&DriverExtension->RegistryPath, NULL); - return STATUS_INSUFFICIENT_RESOURCES; - } - - RtlCopyUnicodeString(&DriverExtension->RegistryPath, RegistryPath); - INFO_(VIDEOPRT, "RegistryPath: %wZ\n", &DriverExtension->RegistryPath); - } - else - { - RtlInitUnicodeString(&DriverExtension->RegistryPath, NULL); - } - } - - /* - * Copy the correct miniport initialization data to the device extension. - */ - - RtlCopyMemory( - &DriverExtension->InitializationData, - HwInitializationData, - HwInitializationData->HwInitDataSize); - if (HwInitializationData->HwInitDataSize < - sizeof(VIDEO_HW_INITIALIZATION_DATA)) - { - RtlZeroMemory((PVOID)((ULONG_PTR)&DriverExtension->InitializationData + - HwInitializationData->HwInitDataSize), - sizeof(VIDEO_HW_INITIALIZATION_DATA) - - HwInitializationData->HwInitDataSize); - } - DriverExtension->HwContext = HwContext; - - /* - * Plug & Play drivers registers the device in AddDevice routine. For - * legacy drivers we must do it now. - */ - - if (LegacyDetection) - { - PDEVICE_OBJECT DeviceObject; - - if (HwInitializationData->HwInitDataSize != SIZE_OF_NT4_VIDEO_HW_INITIALIZATION_DATA) - { - /* power management */ - DriverObject->MajorFunction[IRP_MJ_POWER] = IntVideoPortDispatchPower; - } - Status = IntVideoPortCreateAdapterDeviceObject(DriverObject, DriverExtension, - NULL, &DeviceObject); - if (!NT_SUCCESS(Status)) - { - ERR_(VIDEOPRT, "IntVideoPortCreateAdapterDeviceObject returned 0x%x\n", Status); - return Status; - } - - Status = IntVideoPortFindAdapter(DriverObject, DriverExtension, DeviceObject); - if (NT_SUCCESS(Status)) - VideoPortDeviceNumber++; - else - ERR_(VIDEOPRT, "IntVideoPortFindAdapter returned 0x%x\n", Status); - - return Status; - } - else - { - DriverObject->DriverExtension->AddDevice = IntVideoPortAddDevice; - DriverObject->MajorFunction[IRP_MJ_PNP] = IntVideoPortDispatchPnp; - DriverObject->MajorFunction[IRP_MJ_POWER] = IntVideoPortDispatchPower; - DriverObject->MajorFunction[IRP_MJ_SYSTEM_CONTROL] = IntVideoPortDispatchSystemControl; - - return STATUS_SUCCESS; - } -} - -/* - * @implemented - */ - + } + } + + /* + * Copy the correct miniport initialization data to the device extension. + */ + RtlCopyMemory(&DriverExtension->InitializationData, + HwInitializationData, + HwInitializationData->HwInitDataSize); + if (HwInitializationData->HwInitDataSize < + sizeof(VIDEO_HW_INITIALIZATION_DATA)) + { + RtlZeroMemory((PVOID)((ULONG_PTR)&DriverExtension->InitializationData + + HwInitializationData->HwInitDataSize), + sizeof(VIDEO_HW_INITIALIZATION_DATA) - + HwInitializationData->HwInitDataSize); + } + DriverExtension->HwContext = HwContext; + + /* + * Plug & Play drivers registers the device in AddDevice routine. For + * legacy drivers we must do it now. + */ + if (LegacyDetection) + { + PDEVICE_OBJECT DeviceObject; + + if (HwInitializationData->HwInitDataSize != SIZE_OF_NT4_VIDEO_HW_INITIALIZATION_DATA) + { + /* power management */ + DriverObject->MajorFunction[IRP_MJ_POWER] = IntVideoPortDispatchPower; + } + Status = IntVideoPortCreateAdapterDeviceObject(DriverObject, + DriverExtension, + NULL, + &DeviceObject); + if (!NT_SUCCESS(Status)) + { + ERR_(VIDEOPRT, "IntVideoPortCreateAdapterDeviceObject returned 0x%x\n", Status); + return Status; + } + + Status = IntVideoPortFindAdapter(DriverObject, DriverExtension, DeviceObject); + if (NT_SUCCESS(Status)) + VideoPortDeviceNumber++; + else + ERR_(VIDEOPRT, "IntVideoPortFindAdapter returned 0x%x\n", Status); + + return Status; + } + else + { + DriverObject->DriverExtension->AddDevice = IntVideoPortAddDevice; + DriverObject->MajorFunction[IRP_MJ_PNP] = IntVideoPortDispatchPnp; + DriverObject->MajorFunction[IRP_MJ_POWER] = IntVideoPortDispatchPower; + DriverObject->MajorFunction[IRP_MJ_SYSTEM_CONTROL] = IntVideoPortDispatchSystemControl; + + return STATUS_SUCCESS; + } +} + +/* + * @implemented + */ VOID VideoPortDebugPrint( - IN VIDEO_DEBUG_LEVEL DebugPrintLevel, - IN PCHAR DebugMessage, ...) -{ - va_list ap; - - va_start(ap, DebugMessage); - vDbgPrintEx(DPFLTR_IHVVIDEO_ID, DebugPrintLevel, DebugMessage, ap); - va_end(ap); + IN VIDEO_DEBUG_LEVEL DebugPrintLevel, + IN PCHAR DebugMessage, + ...) +{ + va_list ap; + + va_start(ap, DebugMessage); + vDbgPrintEx(DPFLTR_IHVVIDEO_ID, DebugPrintLevel, DebugMessage, ap); + va_end(ap); } /* * @unimplemented */ - -VOID NTAPI +VOID +NTAPI VideoPortLogError( - IN PVOID HwDeviceExtension, - IN PVIDEO_REQUEST_PACKET Vrp OPTIONAL, - IN VP_STATUS ErrorCode, - IN ULONG UniqueId) + IN PVOID HwDeviceExtension, + IN PVIDEO_REQUEST_PACKET Vrp OPTIONAL, + IN VP_STATUS ErrorCode, + IN ULONG UniqueId) { UNIMPLEMENTED; @@ -810,470 +795,475 @@ /* * @implemented */ - -UCHAR NTAPI +UCHAR +NTAPI VideoPortGetCurrentIrql(VOID) { - return KeGetCurrentIrql(); + return KeGetCurrentIrql(); } typedef struct QueryRegistryCallbackContext { - PVOID HwDeviceExtension; - PVOID HwContext; - PMINIPORT_GET_REGISTRY_ROUTINE HwGetRegistryRoutine; + PVOID HwDeviceExtension; + PVOID HwContext; + PMINIPORT_GET_REGISTRY_ROUTINE HwGetRegistryRoutine; } QUERY_REGISTRY_CALLBACK_CONTEXT, *PQUERY_REGISTRY_CALLBACK_CONTEXT; -static NTSTATUS NTAPI +static +NTSTATUS +NTAPI QueryRegistryCallback( - IN PWSTR ValueName, - IN ULONG ValueType, - IN PVOID ValueData, - IN ULONG ValueLength, - IN PVOID Context, - IN PVOID EntryContext) -{ - PQUERY_REGISTRY_CALLBACK_CONTEXT CallbackContext = (PQUERY_REGISTRY_CALLBACK_CONTEXT) Context; - - INFO_(VIDEOPRT, "Found registry value for name %S: type %d, length %d\n", + IN PWSTR ValueName, + IN ULONG ValueType, + IN PVOID ValueData, + IN ULONG ValueLength, + IN PVOID Context, + IN PVOID EntryContext) +{ + PQUERY_REGISTRY_CALLBACK_CONTEXT CallbackContext = (PQUERY_REGISTRY_CALLBACK_CONTEXT) Context; + + INFO_(VIDEOPRT, "Found registry value for name %S: type %d, length %d\n", ValueName, ValueType, ValueLength); - return (*(CallbackContext->HwGetRegistryRoutine))( - CallbackContext->HwDeviceExtension, - CallbackContext->HwContext, - ValueName, - ValueData, - ValueLength); + return (*(CallbackContext->HwGetRegistryRoutine))( + CallbackContext->HwDeviceExtension, + CallbackContext->HwContext, + ValueName, + ValueData, + ValueLength); } /* * @unimplemented */ -VP_STATUS NTAPI +VP_STATUS +NTAPI VideoPortGetRegistryParameters( - IN PVOID HwDeviceExtension, - IN PWSTR ParameterName, - IN UCHAR IsParameterFileName, - IN PMINIPORT_GET_REGISTRY_ROUTINE GetRegistryRoutine, - IN PVOID HwContext) -{ - RTL_QUERY_REGISTRY_TABLE QueryTable[2] = {{0}}; - QUERY_REGISTRY_CALLBACK_CONTEXT Context; - PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension; - - DeviceExtension = VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension); - - TRACE_(VIDEOPRT, "VideoPortGetRegistryParameters ParameterName %S, RegPath: %wZ\n", - ParameterName, &DeviceExtension->RegistryPath); - - Context.HwDeviceExtension = HwDeviceExtension; - Context.HwContext = HwContext; - Context.HwGetRegistryRoutine = GetRegistryRoutine; - - QueryTable[0].QueryRoutine = QueryRegistryCallback; - QueryTable[0].Flags = RTL_QUERY_REGISTRY_REQUIRED; - QueryTable[0].Name = ParameterName; - - if (!NT_SUCCESS(RtlQueryRegistryValues( - RTL_REGISTRY_ABSOLUTE, - DeviceExtension->RegistryPath.Buffer, - QueryTable, - &Context, - NULL))) - { - WARN_(VIDEOPRT, "VideoPortGetRegistryParameters could not find the " - "requested parameter\n"); - return ERROR_INVALID_PARAMETER; - } - - if (IsParameterFileName) - { - /* FIXME: need to read the contents of the file */ - UNIMPLEMENTED; - } - - return NO_ERROR; -} - -/* - * @implemented - */ - -VP_STATUS NTAPI + IN PVOID HwDeviceExtension, + IN PWSTR ParameterName, + IN UCHAR IsParameterFileName, + IN PMINIPORT_GET_REGISTRY_ROUTINE GetRegistryRoutine, + IN PVOID HwContext) +{ + RTL_QUERY_REGISTRY_TABLE QueryTable[2] = {{0}}; + QUERY_REGISTRY_CALLBACK_CONTEXT Context; + PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension; + NTSTATUS Status; + + DeviceExtension = VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension); + + TRACE_(VIDEOPRT, "VideoPortGetRegistryParameters ParameterName %S, RegPath: %wZ\n", + ParameterName, &DeviceExtension->RegistryPath); + + Context.HwDeviceExtension = HwDeviceExtension; + Context.HwContext = HwContext; + Context.HwGetRegistryRoutine = GetRegistryRoutine; + + QueryTable[0].QueryRoutine = QueryRegistryCallback; + QueryTable[0].Flags = RTL_QUERY_REGISTRY_REQUIRED; + QueryTable[0].Name = ParameterName; + + Status = RtlQueryRegistryValues(RTL_REGISTRY_ABSOLUTE, + DeviceExtension->RegistryPath.Buffer, + QueryTable, + &Context, + NULL); + if (!NT_SUCCESS(Status)) + { + WARN_(VIDEOPRT, "VideoPortGetRegistryParameters could not find the " + "requested parameter\n"); + return ERROR_INVALID_PARAMETER; + } + + if (IsParameterFileName) + { + /* FIXME: need to read the contents of the file */ + UNIMPLEMENTED; + } + + return NO_ERROR; +} + +/* + * @implemented + */ +VP_STATUS +NTAPI VideoPortSetRegistryParameters( - IN PVOID HwDeviceExtension, - IN PWSTR ValueName, - IN PVOID ValueData, - IN ULONG ValueLength) -{ - VP_STATUS Status; - - TRACE_(VIDEOPRT, "VideoPortSetRegistryParameters ParameterName %S, RegPath: %wZ\n", - ValueName, - &VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension)->RegistryPath); - ASSERT_IRQL_LESS_OR_EQUAL(PASSIVE_LEVEL); - Status = RtlWriteRegistryValue( - RTL_REGISTRY_ABSOLUTE, - VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension)->RegistryPath.Buffer, - ValueName, - REG_BINARY, - ValueData, - ValueLength); - - if (Status != NO_ERROR) - WARN_(VIDEOPRT, "VideoPortSetRegistryParameters error 0x%x\n", Status); - - return Status; -} - -/* - * @implemented - */ - -VP_STATUS NTAPI + IN PVOID HwDeviceExtension, + IN PWSTR ValueName, + IN PVOID ValueData, + IN ULONG ValueLength) +{ + PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension; + VP_STATUS Status; + + DeviceExtension = VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension); + TRACE_(VIDEOPRT, "VideoPortSetRegistryParameters ParameterName %S, RegPath: %wZ\n", + ValueName, + &DeviceExtension->RegistryPath); + ASSERT_IRQL_LESS_OR_EQUAL(PASSIVE_LEVEL); + Status = RtlWriteRegistryValue(RTL_REGISTRY_ABSOLUTE, + DeviceExtension->RegistryPath.Buffer, + ValueName, + REG_BINARY, + ValueData, + ValueLength); + if (Status != NO_ERROR) + WARN_(VIDEOPRT, "VideoPortSetRegistryParameters error 0x%x\n", Status); + + return Status; +} + +/* + * @implemented + */ +VP_STATUS +NTAPI VideoPortGetVgaStatus( - IN PVOID HwDeviceExtension, - OUT PULONG VgaStatus) -{ - PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension; - - TRACE_(VIDEOPRT, "VideoPortGetVgaStatus\n"); - - DeviceExtension = VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension); - if (KeGetCurrentIrql() == PASSIVE_LEVEL) - { - if (DeviceExtension->AdapterInterfaceType == PCIBus) - { - /* VgaStatus: 0 == VGA not enabled, 1 == VGA enabled. */ - /* Assumed for now */ - *VgaStatus = 1; - return NO_ERROR; - } - } - - return ERROR_INVALID_FUNCTION; -} - -/* - * @implemented - */ - -PVOID NTAPI + IN PVOID HwDeviceExtension, + OUT PULONG VgaStatus) +{ + PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension; + + TRACE_(VIDEOPRT, "VideoPortGetVgaStatus\n"); + + DeviceExtension = VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension); + if (KeGetCurrentIrql() == PASSIVE_LEVEL) + { + if (DeviceExtension->AdapterInterfaceType == PCIBus) + { + /* VgaStatus: 0 == VGA not enabled, 1 == VGA enabled. */ + /* Assumed for now */ + *VgaStatus = 1; + return NO_ERROR; + } + } + + return ERROR_INVALID_FUNCTION; +} + +/* + * @implemented + */ +PVOID +NTAPI VideoPortGetRomImage( - IN PVOID HwDeviceExtension, - IN PVOID Unused1, - IN ULONG Unused2, - IN ULONG Length) -{ - static PVOID RomImageBuffer = NULL; - PKPROCESS CallingProcess; - KAPC_STATE ApcState; - - TRACE_(VIDEOPRT, "VideoPortGetRomImage(HwDeviceExtension 0x%X Length 0x%X)\n", - HwDeviceExtension, Length); - - /* If the length is zero then free the existing buffer. */ - if (Length == 0) - { - if (RomImageBuffer != NULL) - { - ExFreePool(RomImageBuffer); - RomImageBuffer = NULL; - } - return NULL; - } - else - { - /* - * The DDK says we shouldn't use the legacy C0000 method but get the - * rom base address from the corresponding pci or acpi register but - * lets ignore that and use C0000 anyway. We have already mapped the - * bios area into memory so we'll copy from there. - */ - - /* Copy the bios. */ - Length = min(Length, 0x10000); - if (RomImageBuffer != NULL) - { - ExFreePool(RomImageBuffer); - } - - RomImageBuffer = ExAllocatePool(PagedPool, Length); - if (RomImageBuffer == NULL) - { - return NULL; - } - - IntAttachToCSRSS(&CallingProcess, &ApcState); - RtlCopyMemory(RomImageBuffer, (PUCHAR)0xC0000, Length); - IntDetachFromCSRSS(&CallingProcess, &ApcState); - - return RomImageBuffer; - } -} - -/* - * @implemented - */ - -BOOLEAN NTAPI + IN PVOID HwDeviceExtension, + IN PVOID Unused1, + IN ULONG Unused2, + IN ULONG Length) +{ + static PVOID RomImageBuffer = NULL; + PKPROCESS CallingProcess; + KAPC_STATE ApcState; + + TRACE_(VIDEOPRT, "VideoPortGetRomImage(HwDeviceExtension 0x%X Length 0x%X)\n", + HwDeviceExtension, Length); + + /* If the length is zero then free the existing buffer. */ + if (Length == 0) + { + if (RomImageBuffer != NULL) + { + ExFreePool(RomImageBuffer); + RomImageBuffer = NULL; + } + return NULL; + } + else + { + /* + * The DDK says we shouldn't use the legacy C0000 method but get the + * rom base address from the corresponding pci or acpi register but + * lets ignore that and use C0000 anyway. We have already mapped the + * bios area into memory so we'll copy from there. + */ + + /* Copy the bios. */ + Length = min(Length, 0x10000); + if (RomImageBuffer != NULL) + { + ExFreePool(RomImageBuffer); + } + + RomImageBuffer = ExAllocatePool(PagedPool, Length); + if (RomImageBuffer == NULL) + { + return NULL; + } + + IntAttachToCSRSS(&CallingProcess, &ApcState); + RtlCopyMemory(RomImageBuffer, (PUCHAR)0xC0000, Length); + IntDetachFromCSRSS(&CallingProcess, &ApcState); + + return RomImageBuffer; + } +} + +/* + * @implemented + */ +BOOLEAN +NTAPI VideoPortScanRom( - IN PVOID HwDeviceExtension, - IN PUCHAR RomBase, - IN ULONG RomLength, - IN PUCHAR String) -{ - ULONG StringLength; - BOOLEAN Found; - PUCHAR SearchLocation; - - TRACE_(VIDEOPRT, "VideoPortScanRom RomBase %p RomLength 0x%x String %s\n", RomBase, RomLength, String); - - StringLength = strlen((PCHAR)String); - Found = FALSE; - SearchLocation = RomBase; - for (SearchLocation = RomBase; - !Found && SearchLocation < RomBase + RomLength - StringLength; - SearchLocation++) - { - Found = (RtlCompareMemory(SearchLocation, String, StringLength) == StringLength); - if (Found) - { - INFO_(VIDEOPRT, "Match found at %p\n", SearchLocation); - } - } - - return Found; -} - -/* - * @implemented - */ - -BOOLEAN NTAPI + IN PVOID HwDeviceExtension, + IN PUCHAR RomBase, + IN ULONG RomLength, + IN PUCHAR String) +{ + ULONG StringLength; + BOOLEAN Found; + PUCHAR SearchLocation; + + TRACE_(VIDEOPRT, "VideoPortScanRom RomBase %p RomLength 0x%x String %s\n", RomBase, RomLength, String); + + StringLength = strlen((PCHAR)String); + Found = FALSE; + SearchLocation = RomBase; + for (SearchLocation = RomBase; + !Found && SearchLocation < RomBase + RomLength - StringLength; + SearchLocation++) + { + Found = (RtlCompareMemory(SearchLocation, String, StringLength) == StringLength); + if (Found) + { + INFO_(VIDEOPRT, "Match found at %p\n", SearchLocation); + } + } + + return Found; +} + +/* + * @implemented + */ +BOOLEAN +NTAPI VideoPortSynchronizeExecution( - IN PVOID HwDeviceExtension, - IN VIDEO_SYNCHRONIZE_PRIORITY Priority, - IN PMINIPORT_SYNCHRONIZE_ROUTINE SynchronizeRoutine, - OUT PVOID Context) -{ - BOOLEAN Ret; - PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension; - KIRQL OldIrql; - - switch (Priority) - { - case VpLowPriority: - Ret = (*SynchronizeRoutine)(Context); - break; - - case VpMediumPriority: - DeviceExtension = VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension); - if (DeviceExtension->InterruptObject == NULL) + IN PVOID HwDeviceExtension, + IN VIDEO_SYNCHRONIZE_PRIORITY Priority, + IN PMINIPORT_SYNCHRONIZE_ROUTINE SynchronizeRoutine, + OUT PVOID Context) +{ + BOOLEAN Ret; + PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension; + KIRQL OldIrql; + + switch (Priority) + { + case VpLowPriority: Ret = (*SynchronizeRoutine)(Context); - else - Ret = KeSynchronizeExecution( - DeviceExtension->InterruptObject, - SynchronizeRoutine, - Context); - break; - - case VpHighPriority: - OldIrql = KeGetCurrentIrql(); - if (OldIrql < SYNCH_LEVEL) - KeRaiseIrql(SYNCH_LEVEL, &OldIrql); - - Ret = (*SynchronizeRoutine)(Context); - - if (OldIrql < SYNCH_LEVEL) - KeLowerIrql(OldIrql); - break; - - default: - Ret = FALSE; - } - - return Ret; -} - -/* - * @implemented - */ - -VP_STATUS NTAPI + break; + + case VpMediumPriority: + DeviceExtension = VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension); + if (DeviceExtension->InterruptObject == NULL) + Ret = (*SynchronizeRoutine)(Context); + else + Ret = KeSynchronizeExecution( + DeviceExtension->InterruptObject, + SynchronizeRoutine, + Context); + break; + + case VpHighPriority: + OldIrql = KeGetCurrentIrql(); + if (OldIrql < SYNCH_LEVEL) + KeRaiseIrql(SYNCH_LEVEL, &OldIrql); + + Ret = (*SynchronizeRoutine)(Context); + + if (OldIrql < SYNCH_LEVEL) + KeLowerIrql(OldIrql); + break; + + default: + Ret = FALSE; + } + + return Ret; +} + +/* + * @implemented + */ +VP_STATUS +NTAPI VideoPortEnumerateChildren( - IN PVOID HwDeviceExtension, - IN PVOID Reserved) -{ - PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension; - ULONG Status; - VIDEO_CHILD_ENUM_INFO ChildEnumInfo; - BOOLEAN bHaveLastMonitorID = FALSE; - UCHAR LastMonitorID[10]; - ULONG Unused; - UINT i; - PDEVICE_OBJECT ChildDeviceObject; - PVIDEO_PORT_CHILD_EXTENSION ChildExtension; - - INFO_(VIDEOPRT, "Starting child device probe\n"); - DeviceExtension = VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension); - if (DeviceExtension->DriverExtension->InitializationData.HwGetVideoChildDescriptor == NULL) - { - WARN_(VIDEOPRT, "Miniport's HwGetVideoChildDescriptor is NULL!\n"); - return NO_ERROR; - } - - if (!IsListEmpty(&DeviceExtension->ChildDeviceList)) - { - ERR_(VIDEOPRT, "FIXME: Support calling VideoPortEnumerateChildren again!\n"); - return NO_ERROR; - } - - /* Enumerate the children */ - for (i = 1; ; i++) - { - Status = IoCreateDevice(DeviceExtension->DriverObject, - sizeof(VIDEO_PORT_CHILD_EXTENSION) + - DeviceExtension->DriverExtension->InitializationData.HwChildDeviceExtensionSize, - NULL, - FILE_DEVICE_CONTROLLER, - FILE_DEVICE_SECURE_OPEN, - FALSE, - &ChildDeviceObject); - if (!NT_SUCCESS(Status)) - return Status; - - ChildExtension = ChildDeviceObject->DeviceExtension; - - RtlZeroMemory(ChildExtension, sizeof(VIDEO_PORT_CHILD_EXTENSION) + - DeviceExtension->DriverExtension->InitializationData.HwChildDeviceExtensionSize); - - ChildExtension->Common.Fdo = FALSE; - ChildExtension->ChildId = i; - ChildExtension->PhysicalDeviceObject = ChildDeviceObject; - ChildExtension->DriverObject = DeviceExtension->DriverObject; - - /* Setup the ChildEnumInfo */ - ChildEnumInfo.Size = sizeof(ChildEnumInfo); - ChildEnumInfo.ChildDescriptorSize = sizeof(ChildExtension->ChildDescriptor); - ChildEnumInfo.ACPIHwId = 0; - - if (DeviceExtension->DriverExtension->InitializationData.HwChildDeviceExtensionSize) - ChildEnumInfo.ChildHwDeviceExtension = VIDEO_PORT_GET_CHILD_EXTENSION(ChildExtension); - else - ChildEnumInfo.ChildHwDeviceExtension = NULL; - - ChildEnumInfo.ChildIndex = ChildExtension->ChildId; - - INFO_(VIDEOPRT, "Probing child: %d\n", ChildEnumInfo.ChildIndex); - Status = DeviceExtension->DriverExtension->InitializationData.HwGetVideoChildDescriptor( - HwDeviceExtension, - &ChildEnumInfo, - &ChildExtension->ChildType, - ChildExtension->ChildDescriptor, - &ChildExtension->ChildId, - &Unused); - if (Status == VIDEO_ENUM_MORE_DEVICES) - { - if (ChildExtension->ChildType == Monitor) - { - // Check if the EDID is valid - if (ChildExtension->ChildDescriptor[0] == 0x00 && - ChildExtension->ChildDescriptor[1] == 0xFF && - ChildExtension->ChildDescriptor[2] == 0xFF && - ChildExtension->ChildDescriptor[3] == 0xFF && - ChildExtension->ChildDescriptor[4] == 0xFF && - ChildExtension->ChildDescriptor[5] == 0xFF && - ChildExtension->ChildDescriptor[6] == 0xFF && - ChildExtension->ChildDescriptor[7] == 0x00) + IN PVOID HwDeviceExtension, + IN PVOID Reserved) +{ + PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension; + ULONG Status; + VIDEO_CHILD_ENUM_INFO ChildEnumInfo; + BOOLEAN bHaveLastMonitorID = FALSE; + UCHAR LastMonitorID[10]; + ULONG Unused; + UINT i; + PDEVICE_OBJECT ChildDeviceObject; + PVIDEO_PORT_CHILD_EXTENSION ChildExtension; + + INFO_(VIDEOPRT, "Starting child device probe\n"); + DeviceExtension = VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension); + if (DeviceExtension->DriverExtension->InitializationData.HwGetVideoChildDescriptor == NULL) + { + WARN_(VIDEOPRT, "Miniport's HwGetVideoChildDescriptor is NULL!\n"); + return NO_ERROR; + } + + if (!IsListEmpty(&DeviceExtension->ChildDeviceList)) + { + ERR_(VIDEOPRT, "FIXME: Support calling VideoPortEnumerateChildren again!\n"); + return NO_ERROR; + } + + /* Enumerate the children */ + for (i = 1; ; i++) + { + Status = IoCreateDevice(DeviceExtension->DriverObject, + sizeof(VIDEO_PORT_CHILD_EXTENSION) + + DeviceExtension->DriverExtension->InitializationData.HwChildDeviceExtensionSize, + NULL, + FILE_DEVICE_CONTROLLER, + FILE_DEVICE_SECURE_OPEN, + FALSE, + &ChildDeviceObject); + if (!NT_SUCCESS(Status)) + return Status; + + ChildExtension = ChildDeviceObject->DeviceExtension; + + RtlZeroMemory(ChildExtension, + sizeof(VIDEO_PORT_CHILD_EXTENSION) + + DeviceExtension->DriverExtension->InitializationData.HwChildDeviceExtensionSize); + + ChildExtension->Common.Fdo = FALSE; + ChildExtension->ChildId = i; + ChildExtension->PhysicalDeviceObject = ChildDeviceObject; + ChildExtension->DriverObject = DeviceExtension->DriverObject; + + /* Setup the ChildEnumInfo */ + ChildEnumInfo.Size = sizeof(ChildEnumInfo); + ChildEnumInfo.ChildDescriptorSize = sizeof(ChildExtension->ChildDescriptor); + ChildEnumInfo.ACPIHwId = 0; + + if (DeviceExtension->DriverExtension->InitializationData.HwChildDeviceExtensionSize) + ChildEnumInfo.ChildHwDeviceExtension = VIDEO_PORT_GET_CHILD_EXTENSION(ChildExtension); + else + ChildEnumInfo.ChildHwDeviceExtension = NULL; + + ChildEnumInfo.ChildIndex = ChildExtension->ChildId; + + INFO_(VIDEOPRT, "Probing child: %d\n", ChildEnumInfo.ChildIndex); + Status = DeviceExtension->DriverExtension->InitializationData.HwGetVideoChildDescriptor( + HwDeviceExtension, + &ChildEnumInfo, + &ChildExtension->ChildType, + ChildExtension->ChildDescriptor, + &ChildExtension->ChildId, + &Unused); + if (Status == VIDEO_ENUM_MORE_DEVICES) + { + if (ChildExtension->ChildType == Monitor) { - if (bHaveLastMonitorID) - { - // Compare the previous monitor ID with the current one, break the loop if they are identical - if (RtlCompareMemory(LastMonitorID, &ChildExtension->ChildDescriptor[8], sizeof(LastMonitorID)) == sizeof(LastMonitorID)) - { - INFO_(VIDEOPRT, "Found identical Monitor ID two times, stopping enumeration\n"); - IoDeleteDevice(ChildDeviceObject); - break; - } - } - - // Copy 10 bytes from the EDID, which can be used to uniquely identify the monitor - RtlCopyMemory(LastMonitorID, &ChildExtension->ChildDescriptor[8], sizeof(LastMonitorID)); - bHaveLastMonitorID = TRUE; - - /* Mark it valid */ - ChildExtension->EdidValid = TRUE; + // Check if the EDID is valid + if (ChildExtension->ChildDescriptor[0] == 0x00 && + ChildExtension->ChildDescriptor[1] == 0xFF && + ChildExtension->ChildDescriptor[2] == 0xFF && + ChildExtension->ChildDescriptor[3] == 0xFF && + ChildExtension->ChildDescriptor[4] == 0xFF && + ChildExtension->ChildDescriptor[5] == 0xFF && + ChildExtension->ChildDescriptor[6] == 0xFF && + ChildExtension->ChildDescriptor[7] == 0x00) + { + if (bHaveLastMonitorID) + { + // Compare the previous monitor ID with the current one, break the loop if they are identical + if (RtlCompareMemory(LastMonitorID, &ChildExtension->ChildDescriptor[8], sizeof(LastMonitorID)) == sizeof(LastMonitorID)) + { + INFO_(VIDEOPRT, "Found identical Monitor ID two times, stopping enumeration\n"); + IoDeleteDevice(ChildDeviceObject); + break; + } + } + + // Copy 10 bytes from the EDID, which can be used to uniquely identify the monitor + RtlCopyMemory(LastMonitorID, &ChildExtension->ChildDescriptor[8], sizeof(LastMonitorID)); + bHaveLastMonitorID = TRUE; + + /* Mark it valid */ + ChildExtension->EdidValid = TRUE; + } + else + { + /* Mark it invalid */ + ChildExtension->EdidValid = FALSE; + } } - else + } + else if (Status == VIDEO_ENUM_INVALID_DEVICE) + { + WARN_(VIDEOPRT, "Child device %d is invalid!\n", ChildEnumInfo.ChildIndex); + IoDeleteDevice(ChildDeviceObject); + continue; + } + else if (Status == VIDEO_ENUM_NO_MORE_DEVICES) + { + INFO_(VIDEOPRT, "End of child enumeration! (%d children enumerated)\n", i - 1); + IoDeleteDevice(ChildDeviceObject); + break; + } + else + { + WARN_(VIDEOPRT, "HwGetVideoChildDescriptor returned unknown status code 0x%x!\n", Status); + IoDeleteDevice(ChildDeviceObject); + break; + } + + if (ChildExtension->ChildType == Monitor) + { + UINT j; + PUCHAR p = ChildExtension->ChildDescriptor; + INFO_(VIDEOPRT, "Monitor device enumerated! (ChildId = 0x%x)\n", ChildExtension->ChildId); + for (j = 0; j < sizeof (ChildExtension->ChildDescriptor); j += 8) { - /* Mark it invalid */ - ChildExtension->EdidValid = FALSE; + INFO_(VIDEOPRT, "%02x %02x %02x %02x %02x %02x %02x %02x\n", + p[j + 0], p[j + 1], p[j + 2], p[j + 3], + p[j + 4], p[j + 5], p[j + 6], p[j + 7]); } - } - } - else if (Status == VIDEO_ENUM_INVALID_DEVICE) - { - WARN_(VIDEOPRT, "Child device %d is invalid!\n", ChildEnumInfo.ChildIndex); - IoDeleteDevice(ChildDeviceObject); - continue; - } - else if (Status == VIDEO_ENUM_NO_MORE_DEVICES) - { - INFO_(VIDEOPRT, "End of child enumeration! (%d children enumerated)\n", i - 1); - IoDeleteDevice(ChildDeviceObject); - break; - } - else - { - WARN_(VIDEOPRT, "HwGetVideoChildDescriptor returned unknown status code 0x%x!\n", Status); - IoDeleteDevice(ChildDeviceObject); - break; - } - - if (ChildExtension->ChildType == Monitor) - { - UINT j; - PUCHAR p = ChildExtension->ChildDescriptor; - INFO_(VIDEOPRT, "Monitor device enumerated! (ChildId = 0x%x)\n", ChildExtension->ChildId); - for (j = 0; j < sizeof (ChildExtension->ChildDescriptor); j += 8) - { - INFO_(VIDEOPRT, "%02x %02x %02x %02x %02x %02x %02x %02x\n", - p[j+0], p[j+1], p[j+2], p[j+3], - p[j+4], p[j+5], p[j+6], p[j+7]); - } - } - else if (ChildExtension->ChildType == Other) - { - INFO_(VIDEOPRT, "\"Other\" device enumerated: DeviceId = %S\n", (PWSTR)ChildExtension->ChildDescriptor); - } - else - { - ERR_(VIDEOPRT, "HwGetVideoChildDescriptor returned unsupported type: %d\n", ChildExtension->ChildType); - } - - /* Clear the init flag */ - ChildDeviceObject->Flags &= ~DO_DEVICE_INITIALIZING; - - InsertTailList(&DeviceExtension->ChildDeviceList, - &ChildExtension->ListEntry); - } - - /* Trigger reenumeration by the PnP manager */ - IoInvalidateDeviceRelations(DeviceExtension->PhysicalDeviceObject, BusRelations); - - return NO_ERROR; + } + else if (ChildExtension->ChildType == Other) + { + INFO_(VIDEOPRT, "\"Other\" device enumerated: DeviceId = %S\n", (PWSTR)ChildExtension->ChildDescriptor); + } + else + { + ERR_(VIDEOPRT, "HwGetVideoChildDescriptor returned unsupported type: %d\n", ChildExtension->ChildType); + } + + /* Clear the init flag */ + ChildDeviceObject->Flags &= ~DO_DEVICE_INITIALIZING; + + InsertTailList(&DeviceExtension->ChildDeviceList, + &ChildExtension->ListEntry); + } + + /* Trigger reenumeration by the PnP manager */ + IoInvalidateDeviceRelations(DeviceExtension->PhysicalDeviceObject, BusRelations); + + return NO_ERROR; } /* * @unimplemented */ - -VP_STATUS NTAPI +VP_STATUS +NTAPI VideoPortCreateSecondaryDisplay( - IN PVOID HwDeviceExtension, - IN OUT PVOID *SecondaryDeviceExtension, - IN ULONG Flag) + IN PVOID HwDeviceExtension, + IN OUT PVOID *SecondaryDeviceExtension, + IN ULONG Flag) { UNIMPLEMENTED; return ERROR_DEV_NOT_EXIST; @@ -1282,144 +1272,145 @@ /* * @implemented */ - -BOOLEAN NTAPI +BOOLEAN +NTAPI VideoPortQueueDpc( - IN PVOID HwDeviceExtension, - IN PMINIPORT_DPC_ROUTINE CallbackRoutine, - IN PVOID Context) -{ - return KeInsertQueueDpc( - &VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension)->DpcObject, - (PVOID)CallbackRoutine, - (PVOID)Context); -} - -/* - * @implemented - */ - -PVOID NTAPI -VideoPortGetAssociatedDeviceExtension(IN PVOID DeviceObject) -{ - PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension; - - TRACE_(VIDEOPRT, "VideoPortGetAssociatedDeviceExtension\n"); - DeviceExtension = ((PDEVICE_OBJECT)DeviceObject)->DeviceExtension; - if (!DeviceExtension) - return NULL; - return DeviceExtension->MiniPortDeviceExtension; -} - -/* - * @implemented - */ - -VP_STATUS NTAPI + IN PVOID HwDeviceExtension, + IN PMINIPORT_DPC_ROUTINE CallbackRoutine, + IN PVOID Context) +{ + return KeInsertQueueDpc( + &VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension)->DpcObject, + (PVOID)CallbackRoutine, + (PVOID)Context); +} + +/* + * @implemented + */ +PVOID +NTAPI +VideoPortGetAssociatedDeviceExtension( + IN PVOID DeviceObject) +{ + PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension; + + TRACE_(VIDEOPRT, "VideoPortGetAssociatedDeviceExtension\n"); + DeviceExtension = ((PDEVICE_OBJECT)DeviceObject)->DeviceExtension; + if (!DeviceExtension) + return NULL; + return DeviceExtension->MiniPortDeviceExtension; +} + +/* + * @implemented + */ +VP_STATUS +NTAPI VideoPortGetVersion( - IN PVOID HwDeviceExtension, - IN OUT PVPOSVERSIONINFO VpOsVersionInfo) -{ - RTL_OSVERSIONINFOEXW Version; - - Version.dwOSVersionInfoSize = sizeof(RTL_OSVERSIONINFOEXW); - if (VpOsVersionInfo->Size >= sizeof(VPOSVERSIONINFO)) - { + IN PVOID HwDeviceExtension, + IN OUT PVPOSVERSIONINFO VpOsVersionInfo) +{ + RTL_OSVERSIONINFOEXW Version; + + Version.dwOSVersionInfoSize = sizeof(RTL_OSVERSIONINFOEXW); + if (VpOsVersionInfo->Size >= sizeof(VPOSVERSIONINFO)) + { #if 1 - if (NT_SUCCESS(RtlGetVersion((PRTL_OSVERSIONINFOW)&Version))) - { - VpOsVersionInfo->MajorVersion = Version.dwMajorVersion; - VpOsVersionInfo->MinorVersion = Version.dwMinorVersion; - VpOsVersionInfo->BuildNumber = Version.dwBuildNumber; - VpOsVersionInfo->ServicePackMajor = Version.wServicePackMajor; - VpOsVersionInfo->ServicePackMinor = Version.wServicePackMinor; - return NO_ERROR; - } - return ERROR_INVALID_PARAMETER; + if (NT_SUCCESS(RtlGetVersion((PRTL_OSVERSIONINFOW)&Version))) + { + VpOsVersionInfo->MajorVersion = Version.dwMajorVersion; + VpOsVersionInfo->MinorVersion = Version.dwMinorVersion; + VpOsVersionInfo->BuildNumber = Version.dwBuildNumber; + VpOsVersionInfo->ServicePackMajor = Version.wServicePackMajor; + VpOsVersionInfo->ServicePackMinor = Version.wServicePackMinor; + return NO_ERROR; + } + return ERROR_INVALID_PARAMETER; #else - VpOsVersionInfo->MajorVersion = 5; - VpOsVersionInfo->MinorVersion = 0; - VpOsVersionInfo->BuildNumber = 2195; - VpOsVersionInfo->ServicePackMajor = 4; - VpOsVersionInfo->ServicePackMinor = 0; - return NO_ERROR; + VpOsVersionInfo->MajorVersion = 5; + VpOsVersionInfo->MinorVersion = 0; + VpOsVersionInfo->BuildNumber = 2195; + VpOsVersionInfo->ServicePackMajor = 4; + VpOsVersionInfo->ServicePackMinor = 0; + return NO_ERROR; #endif - } - - return ERROR_INVALID_PARAMETER; -} - -/* - * @implemented - */ - -BOOLEAN NTAPI + } + + return ERROR_INVALID_PARAMETER; +} + +/* + * @implemented + */ +BOOLEAN +NTAPI VideoPortCheckForDeviceExistence( - IN PVOID HwDeviceExtension, - IN USHORT VendorId, - IN USHORT DeviceId, - IN UCHAR RevisionId, - IN USHORT SubVendorId, - IN USHORT SubSystemId, - IN ULONG Flags) -{ - PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension; - PCI_DEVICE_PRESENT_INTERFACE PciDevicePresentInterface; - IO_STATUS_BLOCK IoStatusBlock; - IO_STACK_LOCATION IoStack; - ULONG PciFlags = 0; - NTSTATUS Status; - BOOL DevicePresent; - - TRACE_(VIDEOPRT, "VideoPortCheckForDeviceExistence\n"); - - if (Flags & ~(CDE_USE_REVISION | CDE_USE_SUBSYSTEM_IDS)) - { - WARN_(VIDEOPRT, "VideoPortCheckForDeviceExistence: Unknown flags 0x%lx\n", Flags & ~(CDE_USE_REVISION | CDE_USE_SUBSYSTEM_IDS)); - return FALSE; - } - - DeviceExtension = VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension); - - PciDevicePresentInterface.Size = sizeof(PCI_DEVICE_PRESENT_INTERFACE); - PciDevicePresentInterface.Version = 1; - IoStack.Parameters.QueryInterface.Size = PciDevicePresentInterface.Size; - IoStack.Parameters.QueryInterface.Version = PciDevicePresentInterface.Version; - IoStack.Parameters.QueryInterface.Interface = (PINTERFACE)&PciDevicePresentInterface; - IoStack.Parameters.QueryInterface.InterfaceType = - &GUID_PCI_DEVICE_PRESENT_INTERFACE; - Status = IopInitiatePnpIrp(DeviceExtension->NextDeviceObject, - &IoStatusBlock, IRP_MN_QUERY_INTERFACE, &IoStack); - if (!NT_SUCCESS(Status)) - { - WARN_(VIDEOPRT, "IopInitiatePnpIrp() failed! (Status 0x%lx)\n", Status); - return FALSE; - } - - if (Flags & CDE_USE_REVISION) - PciFlags |= PCI_USE_REVISION; - if (Flags & CDE_USE_SUBSYSTEM_IDS) - PciFlags |= PCI_USE_SUBSYSTEM_IDS; - - DevicePresent = PciDevicePresentInterface.IsDevicePresent( - VendorId, DeviceId, RevisionId, - SubVendorId, SubSystemId, PciFlags); - - PciDevicePresentInterface.InterfaceDereference(PciDevicePresentInterface.Context); - - return DevicePresent; + IN PVOID HwDeviceExtension, + IN USHORT VendorId, + IN USHORT DeviceId, + IN UCHAR RevisionId, + IN USHORT SubVendorId, + IN USHORT SubSystemId, + IN ULONG Flags) +{ + PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension; + PCI_DEVICE_PRESENT_INTERFACE PciDevicePresentInterface; + IO_STATUS_BLOCK IoStatusBlock; + IO_STACK_LOCATION IoStack; + ULONG PciFlags = 0; + NTSTATUS Status; + BOOL DevicePresent; + + TRACE_(VIDEOPRT, "VideoPortCheckForDeviceExistence\n"); + + if (Flags & ~(CDE_USE_REVISION | CDE_USE_SUBSYSTEM_IDS)) + { + WARN_(VIDEOPRT, "VideoPortCheckForDeviceExistence: Unknown flags 0x%lx\n", Flags & ~(CDE_USE_REVISION | CDE_USE_SUBSYSTEM_IDS)); + return FALSE; + } + + DeviceExtension = VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension); + + PciDevicePresentInterface.Size = sizeof(PCI_DEVICE_PRESENT_INTERFACE); + PciDevicePresentInterface.Version = 1; + IoStack.Parameters.QueryInterface.Size = PciDevicePresentInterface.Size; + IoStack.Parameters.QueryInterface.Version = PciDevicePresentInterface.Version; + IoStack.Parameters.QueryInterface.Interface = (PINTERFACE)&PciDevicePresentInterface; + IoStack.Parameters.QueryInterface.InterfaceType = + &GUID_PCI_DEVICE_PRESENT_INTERFACE; + Status = IopInitiatePnpIrp(DeviceExtension->NextDeviceObject, + &IoStatusBlock, IRP_MN_QUERY_INTERFACE, &IoStack); + if (!NT_SUCCESS(Status)) + { + WARN_(VIDEOPRT, "IopInitiatePnpIrp() failed! (Status 0x%lx)\n", Status); + return FALSE; + } + + if (Flags & CDE_USE_REVISION) + PciFlags |= PCI_USE_REVISION; + if (Flags & CDE_USE_SUBSYSTEM_IDS) + PciFlags |= PCI_USE_SUBSYSTEM_IDS; + + DevicePresent = PciDevicePresentInterface.IsDevicePresent( + VendorId, DeviceId, RevisionId, + SubVendorId, SubSystemId, PciFlags); + + PciDevicePresentInterface.InterfaceDereference(PciDevicePresentInterface.Context); + + return DevicePresent; } /* * @unimplemented */ - -VP_STATUS NTAPI +VP_STATUS +NTAPI VideoPortRegisterBugcheckCallback( - IN PVOID HwDeviceExtension, - IN ULONG BugcheckCode, - IN PVIDEO_BUGCHECK_CALLBACK Callback, - IN ULONG BugcheckDataSize) + IN PVOID HwDeviceExtension, + IN ULONG BugcheckCode, + IN PVIDEO_BUGCHECK_CALLBACK Callback, + IN ULONG BugcheckDataSize) { UNIMPLEMENTED; return NO_ERROR; @@ -1428,64 +1419,64 @@ /* * @implemented */ - -LONGLONG NTAPI +LONGLONG +NTAPI VideoPortQueryPerformanceCounter( - IN PVOID HwDeviceExtension, - OUT PLONGLONG PerformanceFrequency OPTIONAL) -{ - LARGE_INTEGER Result; - - TRACE_(VIDEOPRT, "VideoPortQueryPerformanceCounter\n"); - Result = KeQueryPerformanceCounter((PLARGE_INTEGER)PerformanceFrequency); - return Result.QuadPart; -} - -/* - * @implemented - */ - -VOID NTAPI + IN PVOID HwDeviceExtension, + OUT PLONGLONG PerformanceFrequency OPTIONAL) +{ + LARGE_INTEGER Result; + + TRACE_(VIDEOPRT, "VideoPortQueryPerformanceCounter\n"); + Result = KeQueryPerformanceCounter((PLARGE_INTEGER)PerformanceFrequency); + return Result.QuadPart; +} + +/* + * @implemented + */ +VOID +NTAPI VideoPortAcquireDeviceLock( - IN PVOID HwDeviceExtension) -{ - PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension; - NTSTATUS Status; - (void)Status; - - TRACE_(VIDEOPRT, "VideoPortAcquireDeviceLock\n"); - DeviceExtension = VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension); - Status = KeWaitForMutexObject(&DeviceExtension->DeviceLock, Executive, - KernelMode, FALSE, NULL); - // ASSERT(Status == STATUS_SUCCESS); -} - -/* - * @implemented - */ - -VOID NTAPI + IN PVOID HwDeviceExtension) +{ + PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension; + NTSTATUS Status; + (void)Status; + + TRACE_(VIDEOPRT, "VideoPortAcquireDeviceLock\n"); + DeviceExtension = VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension); + Status = KeWaitForMutexObject(&DeviceExtension->DeviceLock, Executive, + KernelMode, FALSE, NULL); + // ASSERT(Status == STATUS_SUCCESS); +} + +/* + * @implemented + */ +VOID +NTAPI VideoPortReleaseDeviceLock( - IN PVOID HwDeviceExtension) -{ - PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension; - LONG Status; - (void)Status; - - TRACE_(VIDEOPRT, "VideoPortReleaseDeviceLock\n"); - DeviceExtension = VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension); - Status = KeReleaseMutex(&DeviceExtension->DeviceLock, FALSE); - //ASSERT(Status == STATUS_SUCCESS); + IN PVOID HwDeviceExtension) +{ + PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension; + LONG Status; + (void)Status; + + TRACE_(VIDEOPRT, "VideoPortReleaseDeviceLock\n"); + DeviceExtension = VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension); + Status = KeReleaseMutex(&DeviceExtension->DeviceLock, FALSE); + //ASSERT(Status == STATUS_SUCCESS); } /* * @unimplemented */ - -VOID NTAPI +VOID +NTAPI VpNotifyEaData( - IN PDEVICE_OBJECT DeviceObject, - IN PVOID Data) + IN PDEVICE_OBJECT DeviceObject, + IN PVOID Data) { UNIMPLEMENTED; } @@ -1493,12 +1484,13 @@ /* * @implemented */ -PVOID NTAPI +PVOID +NTAPI VideoPortAllocateContiguousMemory( - IN PVOID HwDeviceExtension, - IN ULONG NumberOfBytes, - IN PHYSICAL_ADDRESS HighestAcceptableAddress - ) + IN PVOID HwDeviceExtension, + IN ULONG NumberOfBytes, + IN PHYSICAL_ADDRESS HighestAcceptableAddress +) { return MmAllocateContiguousMemory(NumberOfBytes, HighestAcceptableAddress); @@ -1507,96 +1499,97 @@ /* * @implemented */ -BOOLEAN NTAPI +BOOLEAN +NTAPI VideoPortIsNoVesa(VOID) { - NTSTATUS Status; - HANDLE KeyHandle; - UNICODE_STRING Path = RTL_CONSTANT_STRING(L"\\REGISTRY\\MACHINE\\SYSTEM\\CurrentControlSet\\Control"); - UNICODE_STRING ValueName = RTL_CONSTANT_STRING(L"SystemStartOptions"); - OBJECT_ATTRIBUTES ObjectAttributes; - PKEY_VALUE_PARTIAL_INFORMATION KeyInfo; - ULONG Length, NewLength; - - /* Initialize object attributes with the path we want */ - InitializeObjectAttributes(&ObjectAttributes, - &Path, - OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE, - NULL, - NULL); - - /* Open the key */ - Status = ZwOpenKey(&KeyHandle, - KEY_QUERY_VALUE, - &ObjectAttributes); - - if (!NT_SUCCESS(Status)) - { - VideoPortDebugPrint(Error, "ZwOpenKey failed (0x%x)\n", Status); - return FALSE; - } - - /* Find out how large our buffer should be */ - Status = ZwQueryValueKey(KeyHandle, - &ValueName, - KeyValuePartialInformation, - NULL, - 0, - &Length); - if (Status != STATUS_BUFFER_OVERFLOW && Status != STATUS_BUFFER_TOO_SMALL) - { - VideoPortDebugPrint(Error, "ZwQueryValueKey failed (0x%x)\n", Status); - ZwClose(KeyHandle); - return FALSE; - } - - /* Allocate it */ - KeyInfo = ExAllocatePool(PagedPool, Length); - if (!KeyInfo) - { - VideoPortDebugPrint(Error, "Out of memory\n"); - ZwClose(KeyHandle); - return FALSE; - } - - /* Now for real this time */ - Status = ZwQueryValueKey(KeyHandle, - &ValueName, - KeyValuePartialInformation, - KeyInfo, - Length, - &NewLength); - - ZwClose(KeyHandle); - - if (!NT_SUCCESS(Status)) - { - VideoPortDebugPrint(Error, "ZwQueryValueKey failed (0x%x)\n", Status); - ExFreePool(KeyInfo); - return FALSE; - } - - /* Sanity check */ - if (KeyInfo->Type != REG_SZ) - { - VideoPortDebugPrint(Error, "Invalid type for SystemStartOptions\n"); - ExFreePool(KeyInfo); - return FALSE; - } - - /* Check if NOVESA or BASEVIDEO is present in the start options */ - if (wcsstr((PWCHAR)KeyInfo->Data, L"NOVESA") || - wcsstr((PWCHAR)KeyInfo->Data, L"BASEVIDEO")) - { - VideoPortDebugPrint(Info, "VESA mode disabled\n"); - ExFreePool(KeyInfo); - return TRUE; - } - - ExFreePool(KeyInfo); - - VideoPortDebugPrint(Info, "VESA mode enabled\n"); - - return FALSE; -} - + NTSTATUS Status; + HANDLE KeyHandle; + UNICODE_STRING Path = RTL_CONSTANT_STRING(L"\\REGISTRY\\MACHINE\\SYSTEM\\CurrentControlSet\\Control"); + UNICODE_STRING ValueName = RTL_CONSTANT_STRING(L"SystemStartOptions"); + OBJECT_ATTRIBUTES ObjectAttributes; + PKEY_VALUE_PARTIAL_INFORMATION KeyInfo; + ULONG Length, NewLength; + + /* Initialize object attributes with the path we want */ + InitializeObjectAttributes(&ObjectAttributes, + &Path, + OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE, + NULL, + NULL); + + /* Open the key */ + Status = ZwOpenKey(&KeyHandle, + KEY_QUERY_VALUE, + &ObjectAttributes); + + if (!NT_SUCCESS(Status)) + { + VideoPortDebugPrint(Error, "ZwOpenKey failed (0x%x)\n", Status); + return FALSE; + } + + /* Find out how large our buffer should be */ + Status = ZwQueryValueKey(KeyHandle, + &ValueName, + KeyValuePartialInformation, + NULL, + 0, + &Length); + if (Status != STATUS_BUFFER_OVERFLOW && Status != STATUS_BUFFER_TOO_SMALL) + { + VideoPortDebugPrint(Error, "ZwQueryValueKey failed (0x%x)\n", Status); + ZwClose(KeyHandle); + return FALSE; + } + + /* Allocate it */ + KeyInfo = ExAllocatePool(PagedPool, Length); + if (!KeyInfo) + { + VideoPortDebugPrint(Error, "Out of memory\n"); + ZwClose(KeyHandle); + return FALSE; + } + + /* Now for real this time */ + Status = ZwQueryValueKey(KeyHandle, + &ValueName, + KeyValuePartialInformation, + KeyInfo, + Length, + &NewLength); + + ZwClose(KeyHandle); + + if (!NT_SUCCESS(Status)) + { + VideoPortDebugPrint(Error, "ZwQueryValueKey failed (0x%x)\n", Status); + ExFreePool(KeyInfo); + return FALSE; + } + + /* Sanity check */ + if (KeyInfo->Type != REG_SZ) + { + VideoPortDebugPrint(Error, "Invalid type for SystemStartOptions\n"); + ExFreePool(KeyInfo); + return FALSE; + } + + /* Check if NOVESA or BASEVIDEO is present in the start options */ + if (wcsstr((PWCHAR)KeyInfo->Data, L"NOVESA") || + wcsstr((PWCHAR)KeyInfo->Data, L"BASEVIDEO")) + { + VideoPortDebugPrint(Info, "VESA mode disabled\n"); + ExFreePool(KeyInfo); + return TRUE; + } + + ExFreePool(KeyInfo); + + VideoPortDebugPrint(Info, "VESA mode enabled\n"); + + return FALSE; +} +
11 years, 1 month
1
0
0
0
[tfaber] 60981: [CLASSPNP] - Fix warnings
by tfaber@svn.reactos.org
Author: tfaber Date: Wed Nov 13 21:00:27 2013 New Revision: 60981 URL:
http://svn.reactos.org/svn/reactos?rev=60981&view=rev
Log: [CLASSPNP] - Fix warnings Modified: trunk/reactos/drivers/storage/classpnp/power.c Modified: trunk/reactos/drivers/storage/classpnp/power.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/storage/classpnp/p…
============================================================================== --- trunk/reactos/drivers/storage/classpnp/power.c [iso-8859-1] (original) +++ trunk/reactos/drivers/storage/classpnp/power.c [iso-8859-1] Wed Nov 13 21:00:27 2013 @@ -465,6 +465,11 @@ return status; } + + case PowerUpDeviceInitial: { + NT_ASSERT(context->PowerChangeState.PowerUp != PowerUpDeviceInitial); + break; + } } return STATUS_MORE_PROCESSING_REQUIRED; @@ -964,6 +969,11 @@ fdoExtension->PowerDownInProgress = FALSE; return status; + } + + case PowerDownDeviceInitial2: { + NT_ASSERT(context->PowerChangeState.PowerDown2 != PowerDownDeviceInitial2); + break; } } @@ -1049,6 +1059,8 @@ */ SET_FLAG(DeviceObject->Flags, DO_VERIFY_VOLUME); } + break; + default: break; } @@ -1326,6 +1338,8 @@ SET_FLAG(fdoExtension->DeviceObject->Flags, DO_VERIFY_VOLUME); } break; + default: + break; } } }
11 years, 1 month
1
0
0
0
[jgardou] 60980: [OOPS++] - Fix build, now! Running out of excuses.
by jgardou@svn.reactos.org
Author: jgardou Date: Wed Nov 13 20:14:00 2013 New Revision: 60980 URL:
http://svn.reactos.org/svn/reactos?rev=60980&view=rev
Log: [OOPS++] - Fix build, now! Running out of excuses. Modified: trunk/reactos/win32ss/user/user32/windows/cursoricon.c Modified: trunk/reactos/win32ss/user/user32/windows/cursoricon.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/user32/window…
============================================================================== --- trunk/reactos/win32ss/user/user32/windows/cursoricon.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/user32/windows/cursoricon.c [iso-8859-1] Wed Nov 13 20:14:00 2013 @@ -376,7 +376,7 @@ int *width, int *height, int *bits ) { const CURSORICONDIR *resdir = dir; - const CURSORDIR *cursor; + const CURSORRESDIR *cursor; if ( resdir->idCount <= n ) return FALSE;
11 years, 1 month
1
0
0
0
← Newer
1
...
15
16
17
18
19
20
21
...
35
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
Results per page:
10
25
50
100
200