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
September 2011
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
ros-diffs@reactos.org
20 participants
399 discussions
Start a n
N
ew thread
[tkreuzer] 53620: [NTOSKRNL] Move the internal headers below the redefinition of types, because gcc instantiates inline function where they are defined, using the original types. Fixes build.
by tkreuzer@svn.reactos.org
Author: tkreuzer Date: Wed Sep 7 13:58:34 2011 New Revision: 53620 URL:
http://svn.reactos.org/svn/reactos?rev=53620&view=rev
Log: [NTOSKRNL] Move the internal headers below the redefinition of types, because gcc instantiates inline function where they are defined, using the original types. Fixes build. Modified: trunk/reactos/ntoskrnl/include/ntoskrnl.h Modified: trunk/reactos/ntoskrnl/include/ntoskrnl.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/ntoskrnl.…
============================================================================== --- trunk/reactos/ntoskrnl/include/ntoskrnl.h [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/include/ntoskrnl.h [iso-8859-1] Wed Sep 7 13:58:34 2011 @@ -86,14 +86,6 @@ /* PNP GUIDs */ #include <umpnpmgr/sysguid.h> -/* Internal Headers */ -#include "internal/ntoskrnl.h" -#include "config.h" - -#include <reactos/probe.h> -#include "internal/probe.h" -#include "resource.h" - // // Define the internal versions of external and public global data // @@ -123,3 +115,12 @@ #undef HALDISPATCH #define HALDISPATCH (&HalDispatchTable) #define ExRaiseStatus RtlRaiseStatus + +/* Internal Headers */ +#include "internal/ntoskrnl.h" +#include "config.h" + +#include <reactos/probe.h> +#include "internal/probe.h" +#include "resource.h" +
13 years, 3 months
1
0
0
0
[tkreuzer] 53619: [NTOSKRNL] Forgot this file, sorry
by tkreuzer@svn.reactos.org
Author: tkreuzer Date: Wed Sep 7 13:45:06 2011 New Revision: 53619 URL:
http://svn.reactos.org/svn/reactos?rev=53619&view=rev
Log: [NTOSKRNL] Forgot this file, sorry Modified: trunk/reactos/ntoskrnl/ke/krnlinit.c Modified: trunk/reactos/ntoskrnl/ke/krnlinit.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/krnlinit.c?rev…
============================================================================== --- trunk/reactos/ntoskrnl/ke/krnlinit.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/ke/krnlinit.c [iso-8859-1] Wed Sep 7 13:45:06 2011 @@ -23,6 +23,9 @@ /* PRCB Array */ PKPRCB KiProcessorBlock[MAXIMUM_PROCESSORS]; + +/* Number of processors */ +UCHAR KeNumberProcessors = 0; /* NUMA Node Support */ KNODE KiNode0;
13 years, 3 months
1
0
0
0
[tkreuzer] 53618: [NTOSKRNL] Make KeNumberProcessors internally an UCHAR and move it into krnlinit.c instead of having it once per architecture. Fixes a bunch of MSVC warnings.
by tkreuzer@svn.reactos.org
Author: tkreuzer Date: Wed Sep 7 13:43:54 2011 New Revision: 53618 URL:
http://svn.reactos.org/svn/reactos?rev=53618&view=rev
Log: [NTOSKRNL] Make KeNumberProcessors internally an UCHAR and move it into krnlinit.c instead of having it once per architecture. Fixes a bunch of MSVC warnings. Modified: trunk/reactos/ntoskrnl/include/ntoskrnl.h trunk/reactos/ntoskrnl/ke/amd64/cpu.c trunk/reactos/ntoskrnl/ke/arm/cpu.c trunk/reactos/ntoskrnl/ke/i386/cpu.c trunk/reactos/ntoskrnl/ke/powerpc/cpu.c trunk/reactos/ntoskrnl/ntoskrnl.pspec trunk/reactos/ntoskrnl/ntoskrnl.spec Modified: trunk/reactos/ntoskrnl/include/ntoskrnl.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/ntoskrnl.…
============================================================================== --- trunk/reactos/ntoskrnl/include/ntoskrnl.h [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/include/ntoskrnl.h [iso-8859-1] Wed Sep 7 13:43:54 2011 @@ -106,6 +106,8 @@ #define KdDebuggerNotPresent _KdDebuggerNotPresent #define NlsOemLeadByteInfo _NlsOemLeadByteInfo extern PUSHORT _NlsOemLeadByteInfo; +#define KeNumberProcessors _KeNumberProcessors +extern UCHAR _KeNumberProcessors; #define FsRtlLegalAnsiCharacterArray _FsRtlLegalAnsiCharacterArray #undef LEGAL_ANSI_CHARACTER_ARRAY #undef NLS_MB_CODE_PAGE_TAG Modified: trunk/reactos/ntoskrnl/ke/amd64/cpu.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/amd64/cpu.c?re…
============================================================================== --- trunk/reactos/ntoskrnl/ke/amd64/cpu.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/ke/amd64/cpu.c [iso-8859-1] Wed Sep 7 13:43:54 2011 @@ -35,7 +35,6 @@ ULONG KeI386NpxPresent = 1; ULONG KeLargestCacheLine = 0x40; ULONG KiDmaIoCoherency = 0; -CHAR KeNumberProcessors = 0; KAFFINITY KeActiveProcessors = 1; BOOLEAN KiSMTProcessorsPresent; Modified: trunk/reactos/ntoskrnl/ke/arm/cpu.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/arm/cpu.c?rev=…
============================================================================== --- trunk/reactos/ntoskrnl/ke/arm/cpu.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/ke/arm/cpu.c [iso-8859-1] Wed Sep 7 13:43:54 2011 @@ -17,7 +17,6 @@ ULONG KeFixedTbEntries; ULONG KiDmaIoCoherency; ULONG KeIcacheFlushCount = 0; -CCHAR KeNumberProcessors; ULONG KeDcacheFlushCount; ULONG KeActiveProcessors; ULONG KeProcessorArchitecture; Modified: trunk/reactos/ntoskrnl/ke/i386/cpu.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/i386/cpu.c?rev…
============================================================================== --- trunk/reactos/ntoskrnl/ke/i386/cpu.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/ke/i386/cpu.c [iso-8859-1] Wed Sep 7 13:43:54 2011 @@ -41,7 +41,6 @@ ULONG KeIcacheFlushCount = 0; ULONG KiDmaIoCoherency = 0; ULONG KePrefetchNTAGranularity = 32; -CHAR KeNumberProcessors = 0; KAFFINITY KeActiveProcessors = 1; BOOLEAN KiI386PentiumLockErrataPresent; BOOLEAN KiSMTProcessorsPresent; @@ -587,7 +586,7 @@ /* Compute associativity */ Associativity = 4; if (RegisterByte >= 0x79) Associativity = 8; - + /* Mask out only the first nibble */ RegisterByte &= 0x07; @@ -605,7 +604,7 @@ { /* Set minimum cache line size */ if (CacheLine < 128) CacheLine = 128; - + /* Hard-code size/associativity */ Associativity = 8; switch (RegisterByte) @@ -614,24 +613,24 @@ Size = 512 * 1024; Associativity = 4; break; - + case 0x23: Size = 1024 * 1024; break; - + case 0x25: Size = 2048 * 1024; break; - + case 0x29: Size = 4096 * 1024; break; - + default: Size = 0; break; } - + /* Check if this cache is bigger than the last */ if ((Size / Associativity) > CurrentSize) { @@ -661,7 +660,7 @@ { /* Set minimum cache line size */ if (CacheLine < 64) CacheLine = 64; - + /* Hard-code size/associativity */ switch (RegisterByte) { @@ -669,37 +668,37 @@ Size = 4 * 1024 * 1024; Associativity = 8; break; - + case 0x4B: Size = 6 * 1024 * 1024; Associativity = 12; break; - + case 0x4C: Size = 8 * 1024 * 1024; Associativity = 16; break; - + case 0x78: Size = 1 * 1024 * 1024; Associativity = 4; break; - + case 0x7D: Size = 2 * 1024 * 1024; Associativity = 8; break; - + case 0x7F: Size = 512 * 1024; Associativity = 2; break; - + case 0x86: Size = 512 * 1024; Associativity = 4; break; - + case 0x87: Size = 1 * 1024 * 1024; Associativity = 8; @@ -709,7 +708,7 @@ Size = 0; break; } - + /* Check if this cache is bigger than the last */ if ((Size / Associativity) > CurrentSize) { @@ -734,17 +733,17 @@ /* Get L1 size first */ CPUID(0x80000005, &Data[0], &Data[1], &Data[2], &Data[3]); KePrefetchNTAGranularity = Data[2] & 0xFF; - + /* Check if we support CPUID 0x80000006 */ CPUID(0x80000000, &Data[0], &Data[1], &Data[2], &Data[3]); if (Data[0] >= 0x80000006) { /* Get 2nd level cache and tlb size */ CPUID(0x80000006, &Data[0], &Data[1], &Data[2], &Data[3]); - + /* Cache line size */ CacheLine = Data[2] & 0xFF; - + /* Hardcode associativity */ RegisterByte = Data[2] >> 12; switch (RegisterByte) @@ -752,28 +751,28 @@ case 2: Associativity = 2; break; - + case 4: Associativity = 4; break; - + case 6: Associativity = 8; break; - + case 8: case 15: Associativity = 16; break; - + default: Associativity = 1; break; } - + /* Compute size */ Size = (Data[2] >> 16) << 10; - + /* Hack for Model 6, Steping 300 */ if ((KeGetCurrentPrcb()->CpuType == 6) && (KeGetCurrentPrcb()->CpuStep == 0x300)) @@ -797,7 +796,7 @@ /* FIXME */ break; } - + /* Set the cache line */ if (CacheLine > KeLargestCacheLine) KeLargestCacheLine = CacheLine; DPRINT1("Prefetch Cache: %d bytes\tL2 Cache: %d bytes\tL2 Cache Line: %d bytes\tL2 Cache Associativity: %d\n", @@ -1221,13 +1220,13 @@ { ULONG Cr0; USHORT Magic; - + /* Set magic */ Magic = 0xFFFF; - + /* Read CR0 and mask out FPU flags */ Cr0 = __readcr0() & ~(CR0_MP | CR0_TS | CR0_EM | CR0_ET); - + /* Store on FPU stack */ #ifdef _MSC_VER __asm fninit; @@ -1235,7 +1234,7 @@ #else asm volatile ("fninit;" "fnstsw %0" : "+m"(Magic)); #endif - + /* Magic should now be cleared */ if (Magic & 0xFF) { @@ -1243,13 +1242,13 @@ __writecr0(Cr0 | CR0_EM | CR0_TS); return FALSE; } - + /* You have an FPU, enable it */ Cr0 |= CR0_ET; - + /* Enable INT 16 on 486 and higher */ if (KeGetCurrentPrcb()->CpuType >= 3) Cr0 |= CR0_NE; - + /* Set FPU state */ __writecr0(Cr0 | CR0_EM | CR0_TS); return TRUE; @@ -1263,28 +1262,28 @@ BOOLEAN ErrataPresent; ULONG Cr0; volatile double Value1, Value2; - + /* Disable interrupts */ _disable(); - + /* Read CR0 and remove FPU flags */ Cr0 = __readcr0(); __writecr0(Cr0 & ~(CR0_MP | CR0_TS | CR0_EM)); - + /* Initialize FPU state */ Ke386FnInit(); - + /* Multiply the magic values and divide, we should get the result back */ Value1 = 4195835.0; Value2 = 3145727.0; ErrataPresent = (Value1 * Value2 / 3145727.0) != 4195835.0; - + /* Restore CR0 */ __writecr0(Cr0); - + /* Enable interrupts */ _enable(); - + /* Return if there's an errata */ return ErrataPresent; } @@ -1296,23 +1295,23 @@ ULONG EFlags, Cr0; PKTHREAD Thread, NpxThread; PFX_SAVE_AREA FxSaveArea; - + /* Save volatiles and disable interrupts */ EFlags = __readeflags(); _disable(); - + /* Save the PCR and get the current thread */ Thread = KeGetCurrentThread(); - + /* Check if we're already loaded */ if (Thread->NpxState != NPX_STATE_LOADED) { /* If there's nothing to load, quit */ if (!SaveArea) return; - + /* Need FXSR support for this */ ASSERT(KeI386FxsrPresent == TRUE); - + /* Check for sane CR0 */ Cr0 = __readcr0(); if (Cr0 & (CR0_MP | CR0_TS | CR0_EM)) @@ -1320,7 +1319,7 @@ /* Mask out FPU flags */ __writecr0(Cr0 & ~(CR0_MP | CR0_TS | CR0_EM)); } - + /* Get the NPX thread and check its FPU state */ NpxThread = KeGetCurrentPrcb()->NpxThread; if ((NpxThread) && (NpxThread->NpxState == NPX_STATE_LOADED)) @@ -1328,11 +1327,11 @@ /* Get the FX frame and store the state there */ FxSaveArea = KiGetThreadNpxArea(NpxThread); Ke386FxSave(FxSaveArea); - + /* NPX thread has lost its state */ NpxThread->NpxState = NPX_STATE_NOT_LOADED; } - + /* Now load NPX state from the NPX area */ FxSaveArea = KiGetThreadNpxArea(Thread); Ke386FxStore(FxSaveArea); @@ -1346,11 +1345,11 @@ /* Mask out FPU flags */ __writecr0(Cr0 & ~(CR0_MP | CR0_TS | CR0_EM)); } - + /* Get FX frame */ FxSaveArea = KiGetThreadNpxArea(Thread); Thread->NpxState = NPX_STATE_NOT_LOADED; - + /* Save state if supported by CPU */ if (KeI386FxsrPresent) Ke386FxSave(FxSaveArea); } @@ -1360,12 +1359,12 @@ /* Clear NPX thread */ KeGetCurrentPrcb()->NpxThread = NULL; - + /* Add the CR0 from the NPX frame */ Cr0 |= NPX_STATE_NOT_LOADED; Cr0 |= FxSaveArea->Cr0NpxState; __writecr0(Cr0); - + /* Restore interrupt state */ __writeeflags(EFlags); } @@ -1380,10 +1379,10 @@ KiCoprocessorError(VOID) { PFX_SAVE_AREA NpxArea; - + /* Get the FPU area */ NpxArea = KiGetThreadNpxArea(KeGetCurrentThread()); - + /* Set CR0_TS */ NpxArea->Cr0NpxState = CR0_TS; __writecr0(__readcr0() | CR0_TS); Modified: trunk/reactos/ntoskrnl/ke/powerpc/cpu.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/powerpc/cpu.c?…
============================================================================== --- trunk/reactos/ntoskrnl/ke/powerpc/cpu.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/ke/powerpc/cpu.c [iso-8859-1] Wed Sep 7 13:43:54 2011 @@ -23,7 +23,6 @@ ULONG KeDcacheFlushCount = 0; ULONG KeIcacheFlushCount = 0; ULONG KiDmaIoCoherency = 0; -CHAR KeNumberProcessors; KAFFINITY KeActiveProcessors = 1; BOOLEAN KiSMTProcessorsPresent; Modified: trunk/reactos/ntoskrnl/ntoskrnl.pspec URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ntoskrnl.pspec?re…
============================================================================== --- trunk/reactos/ntoskrnl/ntoskrnl.pspec [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/ntoskrnl.pspec [iso-8859-1] Wed Sep 7 13:43:54 2011 @@ -645,7 +645,7 @@ @ stdcall KeLeaveCriticalRegion() _KeLeaveCriticalRegion @ stdcall KeLeaveGuardedRegion() _KeLeaveGuardedRegion @ extern KeLoaderBlock -@ extern KeNumberProcessors +@ extern KeNumberProcessors _KeNumberProcessors @ stdcall KeProfileInterrupt(ptr) @ stdcall KeProfileInterruptWithSource(ptr long) @ stdcall KePulseEvent(ptr long long) Modified: trunk/reactos/ntoskrnl/ntoskrnl.spec URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ntoskrnl.spec?rev…
============================================================================== --- trunk/reactos/ntoskrnl/ntoskrnl.spec [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/ntoskrnl.spec [iso-8859-1] Wed Sep 7 13:43:54 2011 @@ -628,7 +628,7 @@ @ stdcall KeLeaveGuardedRegion() _KeLeaveGuardedRegion @ extern KeLoaderBlock @ cdecl -arch=x86_64 KeLowerIrql(long) -@ extern KeNumberProcessors +@ extern KeNumberProcessors _KeNumberProcessors @ stdcall -arch=i386,arm KeProfileInterrupt(ptr) @ stdcall KeProfileInterruptWithSource(ptr long) @ stdcall KePulseEvent(ptr long long)
13 years, 3 months
1
0
0
0
[cmihail] 53617: [shell32.dll][FORMATTING] - No code changes. Make the code more readable in preparation for investigating some failing wine tests.
by cmihail@svn.reactos.org
Author: cmihail Date: Wed Sep 7 13:39:13 2011 New Revision: 53617 URL:
http://svn.reactos.org/svn/reactos?rev=53617&view=rev
Log: [shell32.dll][FORMATTING] - No code changes. Make the code more readable in preparation for investigating some failing wine tests. Modified: branches/shell32_new-bringup/dll/win32/shell32/shlview.cpp Modified: branches/shell32_new-bringup/dll/win32/shell32/shlview.cpp URL:
http://svn.reactos.org/svn/reactos/branches/shell32_new-bringup/dll/win32/s…
============================================================================== --- branches/shell32_new-bringup/dll/win32/shell32/shlview.cpp [iso-8859-1] (original) +++ branches/shell32_new-bringup/dll/win32/shell32/shlview.cpp [iso-8859-1] Wed Sep 7 13:39:13 2011 @@ -346,7 +346,8 @@ { pSFParent = shellFolder; shellFolder->QueryInterface(IID_IShellFolder2, (LPVOID *)&pSF2Parent); - return S_OK; + + return S_OK; } /********************************************************** @@ -359,10 +360,11 @@ if (pCommDlgBrowser.p != NULL) { - TRACE("ICommDlgBrowser::IncludeObject pidl=%p\n", pidl); - ret = pCommDlgBrowser->IncludeObject((IShellView *)this, pidl); - TRACE("--0x%08x\n", ret); - } + TRACE("ICommDlgBrowser::IncludeObject pidl=%p\n", pidl); + ret = pCommDlgBrowser->IncludeObject((IShellView *)this, pidl); + TRACE("--0x%08x\n", ret); + } + return ret; } @@ -372,10 +374,11 @@ if (pCommDlgBrowser.p != NULL) { - TRACE("ICommDlgBrowser::OnDefaultCommand\n"); - ret = pCommDlgBrowser->OnDefaultCommand((IShellView *)this); - TRACE("-- returns %08x\n", ret); - } + TRACE("ICommDlgBrowser::OnDefaultCommand\n"); + ret = pCommDlgBrowser->OnDefaultCommand((IShellView *)this); + TRACE("-- returns %08x\n", ret); + } + return ret; } @@ -385,10 +388,11 @@ if (pCommDlgBrowser.p != NULL) { - TRACE("ICommDlgBrowser::OnStateChange flags=%x\n", uFlags); - ret = pCommDlgBrowser->OnStateChange((IShellView *)this, uFlags); - TRACE("--\n"); - } + TRACE("ICommDlgBrowser::OnStateChange flags=%x\n", uFlags); + ret = pCommDlgBrowser->OnStateChange((IShellView *)this, uFlags); + TRACE("--\n"); + } + return ret; } /********************************************************** @@ -405,14 +409,14 @@ if (pCommDlgBrowser != NULL) { - pShellBrowser->SendControlMsg(FCW_TOOLBAR, TB_CHECKBUTTON, - FCIDM_TB_SMALLICON, (FolderSettings.ViewMode==FVM_LIST)? TRUE : FALSE, &result); - pShellBrowser->SendControlMsg(FCW_TOOLBAR, TB_CHECKBUTTON, - FCIDM_TB_REPORTVIEW, (FolderSettings.ViewMode==FVM_DETAILS)? TRUE : FALSE, &result); - pShellBrowser->SendControlMsg(FCW_TOOLBAR, TB_ENABLEBUTTON, - FCIDM_TB_SMALLICON, TRUE, &result); - pShellBrowser->SendControlMsg(FCW_TOOLBAR, TB_ENABLEBUTTON, - FCIDM_TB_REPORTVIEW, TRUE, &result); + pShellBrowser->SendControlMsg(FCW_TOOLBAR, TB_CHECKBUTTON, + FCIDM_TB_SMALLICON, (FolderSettings.ViewMode==FVM_LIST)? TRUE : FALSE, &result); + pShellBrowser->SendControlMsg(FCW_TOOLBAR, TB_CHECKBUTTON, + FCIDM_TB_REPORTVIEW, (FolderSettings.ViewMode==FVM_DETAILS)? TRUE : FALSE, &result); + pShellBrowser->SendControlMsg(FCW_TOOLBAR, TB_ENABLEBUTTON, + FCIDM_TB_SMALLICON, TRUE, &result); + pShellBrowser->SendControlMsg(FCW_TOOLBAR, TB_ENABLEBUTTON, + FCIDM_TB_REPORTVIEW, TRUE, &result); } } @@ -454,19 +458,38 @@ switch (FolderSettings.ViewMode) { - case FVM_ICON: dwStyle |= LVS_ICON; break; - case FVM_DETAILS: dwStyle |= LVS_REPORT; break; - case FVM_SMALLICON: dwStyle |= LVS_SMALLICON; break; - case FVM_LIST: dwStyle |= LVS_LIST; break; - default: dwStyle |= LVS_LIST; break; - } - - if (FolderSettings.fFlags & FWF_AUTOARRANGE) dwStyle |= LVS_AUTOARRANGE; - if (FolderSettings.fFlags & FWF_DESKTOP) + case FVM_ICON: + dwStyle |= LVS_ICON; + break; + + case FVM_DETAILS: + dwStyle |= LVS_REPORT; + break; + + case FVM_SMALLICON: + dwStyle |= LVS_SMALLICON; + break; + + case FVM_LIST: + dwStyle |= LVS_LIST; + break; + + default: + dwStyle |= LVS_LIST; + break; + } + + if (FolderSettings.fFlags & FWF_AUTOARRANGE) + dwStyle |= LVS_AUTOARRANGE; + + if (FolderSettings.fFlags & FWF_DESKTOP) FolderSettings.fFlags |= FWF_NOCLIENTEDGE | FWF_NOSCROLL; - if (FolderSettings.fFlags & FWF_SINGLESEL) dwStyle |= LVS_SINGLESEL; - if (FolderSettings.fFlags & FWF_NOCLIENTEDGE) - dwExStyle &= ~WS_EX_CLIENTEDGE; + + if (FolderSettings.fFlags & FWF_SINGLESEL) + dwStyle |= LVS_SINGLESEL; + + if (FolderSettings.fFlags & FWF_NOCLIENTEDGE) + dwExStyle &= ~WS_EX_CLIENTEDGE; hWndList=CreateWindowExW( dwExStyle, WC_LISTVIEWW, @@ -478,34 +501,35 @@ shell32_hInstance, NULL); - if(!hWndList) - return FALSE; + if (!hWndList) + return FALSE; ListViewSortInfo.bIsAscending = TRUE; ListViewSortInfo.nHeaderID = -1; ListViewSortInfo.nLastHeaderID = -1; - if (FolderSettings.fFlags & FWF_DESKTOP) { - /* - * FIXME: look at the registry value - * HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\ListviewShadow - * and activate drop shadows if necessary - */ - if (1) - { - SendMessageW(hWndList, LVM_SETTEXTBKCOLOR, 0, CLR_NONE); - SendMessageW(hWndList, LVM_SETBKCOLOR, 0, CLR_NONE); - } - else - { - SendMessageW(hWndList, LVM_SETTEXTBKCOLOR, 0, GetSysColor(COLOR_DESKTOP)); - SendMessageW(hWndList, LVM_SETBKCOLOR, 0, GetSysColor(COLOR_DESKTOP)); - } - - SendMessageW(hWndList, LVM_SETTEXTCOLOR, 0, RGB(255,255,255)); - } - - /* UpdateShellSettings(); */ + if (FolderSettings.fFlags & FWF_DESKTOP) + { + /* + * FIXME: look at the registry value + * HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\ListviewShadow + * and activate drop shadows if necessary + */ + if (1) + { + SendMessageW(hWndList, LVM_SETTEXTBKCOLOR, 0, CLR_NONE); + SendMessageW(hWndList, LVM_SETBKCOLOR, 0, CLR_NONE); + } + else + { + SendMessageW(hWndList, LVM_SETTEXTBKCOLOR, 0, GetSysColor(COLOR_DESKTOP)); + SendMessageW(hWndList, LVM_SETBKCOLOR, 0, GetSysColor(COLOR_DESKTOP)); + } + + SendMessageW(hWndList, LVM_SETTEXTCOLOR, 0, RGB(255,255,255)); + } + + /* UpdateShellSettings(); */ return TRUE; } @@ -518,7 +542,6 @@ { LVCOLUMNW lvColumn; SHELLDETAILS sd; - int i; WCHAR szTemp[50]; TRACE("%p\n",this); @@ -530,19 +553,20 @@ if (pSF2Parent) { - for (i=0; 1; i++) - { - if (FAILED(pSF2Parent->GetDetailsOf(NULL, i, &sd))) - break; - lvColumn.fmt = sd.fmt; - lvColumn.cx = sd.cxChar*8; /* chars->pixel */ - StrRetToStrNW( szTemp, 50, &sd.str, NULL); - SendMessageW(hWndList, LVM_INSERTCOLUMNW, i, (LPARAM) &lvColumn); - } + for (int i=0; 1; i++) + { + if (FAILED(pSF2Parent->GetDetailsOf(NULL, i, &sd))) + break; + + lvColumn.fmt = sd.fmt; + lvColumn.cx = sd.cxChar*8; /* chars->pixel */ + StrRetToStrNW( szTemp, 50, &sd.str, NULL); + SendMessageW(hWndList, LVM_INSERTCOLUMNW, i, (LPARAM) &lvColumn); + } } else { - FIXME("no SF2\n"); + FIXME("no SF2\n"); } SendMessageW(hWndList, LVM_SETIMAGELIST, LVSIL_SMALL, (LPARAM)ShellSmallIconList); @@ -562,11 +586,13 @@ int ret; TRACE("pidl1=%p pidl2=%p lpsf=%p\n", lParam1, lParam2, (LPVOID) lpData); - if(!lpData) return 0; + if (!lpData) + return 0; ret = (SHORT)SCODE_CODE(((IShellFolder *)lpData)->CompareIDs(0, (LPITEMIDLIST)lParam1, (LPITEMIDLIST)lParam2)); TRACE("ret=%i\n",ret); - return ret; + + return ret; } /************************************************************************* @@ -609,7 +635,7 @@ bIsBothFolder = bIsFolder1 && bIsFolder2; /* When sorting between a File and a Folder, the Folder gets sorted first */ - if( (bIsFolder1 || bIsFolder2) && !bIsBothFolder) + if ( (bIsFolder1 || bIsFolder2) && !bIsBothFolder) { nDiff = bIsFolder1 ? -1 : 1; } @@ -631,7 +657,7 @@ nDiff = lstrcmpiA(strName1, strName2); } /* Sort by FileName: Folder or Files can be sorted */ - else if(pSortInfo->nHeaderID == LISTVIEW_COLUMN_NAME || bIsBothFolder) + else if (pSortInfo->nHeaderID == LISTVIEW_COLUMN_NAME || bIsBothFolder) { /* Sort by Text */ _ILSimpleGetText(pItemIdList1, strName1, MAX_PATH); @@ -639,12 +665,12 @@ nDiff = lstrcmpiA(strName1, strName2); } /* Sort by File Size, Only valid for Files */ - else if(pSortInfo->nHeaderID == LISTVIEW_COLUMN_SIZE) + else if (pSortInfo->nHeaderID == LISTVIEW_COLUMN_SIZE) { nDiff = (INT)(_ILGetFileSize(pItemIdList1, NULL, 0) - _ILGetFileSize(pItemIdList2, NULL, 0)); } /* Sort by File Type, Only valid for Files */ - else if(pSortInfo->nHeaderID == LISTVIEW_COLUMN_TYPE) + else if (pSortInfo->nHeaderID == LISTVIEW_COLUMN_TYPE) { /* Sort by Type */ _ILGetFileType(pItemIdList1, strName1, MAX_PATH); @@ -654,20 +680,19 @@ } /* If the Date, FileSize, FileType, Attrib was the same, sort by FileName */ - if(nDiff == 0) + if (nDiff == 0) { _ILSimpleGetText(pItemIdList1, strName1, MAX_PATH); _ILSimpleGetText(pItemIdList2, strName2, MAX_PATH); nDiff = lstrcmpiA(strName1, strName2); } - if(!pSortInfo->bIsAscending) + if (!pSortInfo->bIsAscending) { nDiff = -nDiff; } return nDiff; - } /********************************************************** @@ -678,16 +703,18 @@ LVITEMW lvItem; lvItem.iSubItem = 0; lvItem.mask = LVIF_PARAM; - for(lvItem.iItem = 0; + + for (lvItem.iItem = 0; SendMessageW(hWndList, LVM_GETITEMW, 0, (LPARAM) &lvItem); lvItem.iItem++) { - LPITEMIDLIST currentpidl = (LPITEMIDLIST) lvItem.lParam; - HRESULT hr = pSFParent->CompareIDs(0, pidl, currentpidl); - if(SUCCEEDED(hr) && !HRESULT_CODE(hr)) - { - return lvItem.iItem; - } + LPITEMIDLIST currentpidl = (LPITEMIDLIST) lvItem.lParam; + HRESULT hr = pSFParent->CompareIDs(0, pidl, currentpidl); + + if (SUCCEEDED(hr) && !HRESULT_CODE(hr)) + { + return lvItem.iItem; + } } return -1; } @@ -707,10 +734,11 @@ lvItem.lParam = (LPARAM) ILClone(ILFindLastID(pidl)); /*set the item's data*/ lvItem.pszText = LPSTR_TEXTCALLBACKW; /*get text on a callback basis*/ lvItem.iImage = I_IMAGECALLBACK; /*get the image on a callback basis*/ - if (SendMessageW(hWndList, LVM_INSERTITEMW, 0, (LPARAM)&lvItem) == -1) - return FALSE; + + if (SendMessageW(hWndList, LVM_INSERTITEMW, 0, (LPARAM)&lvItem) == -1) + return FALSE; else - return TRUE; + return TRUE; } /********************************************************** @@ -723,7 +751,8 @@ TRACE("(%p)(pidl=%p)\n", this, pidl); nIndex = LV_FindItemByPidl(ILFindLastID(pidl)); - return (-1 == ListView_DeleteItem(hWndList, nIndex)) ? FALSE : TRUE; + + return (-1 == ListView_DeleteItem(hWndList, nIndex)) ? FALSE : TRUE; } /********************************************************** @@ -737,21 +766,23 @@ TRACE("(%p)(pidlold=%p pidlnew=%p)\n", this, pidlOld, pidlNew); nItem = LV_FindItemByPidl(ILFindLastID(pidlOld)); - if ( -1 != nItem ) - { - lvItem.mask = LVIF_PARAM; /* only the pidl */ - lvItem.iItem = nItem; - SendMessageW(hWndList, LVM_GETITEMW, 0, (LPARAM) &lvItem); - - SHFree((LPITEMIDLIST)lvItem.lParam); - lvItem.mask = LVIF_PARAM; - lvItem.iItem = nItem; - lvItem.lParam = (LPARAM) ILClone(ILFindLastID(pidlNew)); /* set the item's data */ - SendMessageW(hWndList, LVM_SETITEMW, 0, (LPARAM) &lvItem); - SendMessageW(hWndList, LVM_UPDATE, nItem, 0); - return TRUE; /* FIXME: better handling */ - } - return FALSE; + + if ( -1 != nItem ) + { + lvItem.mask = LVIF_PARAM; /* only the pidl */ + lvItem.iItem = nItem; + SendMessageW(hWndList, LVM_GETITEMW, 0, (LPARAM) &lvItem); + + SHFree((LPITEMIDLIST)lvItem.lParam); + lvItem.mask = LVIF_PARAM; + lvItem.iItem = nItem; + lvItem.lParam = (LPARAM) ILClone(ILFindLastID(pidlNew)); /* set the item's data */ + SendMessageW(hWndList, LVM_SETITEMW, 0, (LPARAM) &lvItem); + SendMessageW(hWndList, LVM_UPDATE, nItem, 0); + return TRUE; /* FIXME: better handling */ + } + + return FALSE; } /********************************************************** @@ -766,7 +797,9 @@ LPITEMIDLIST pidl = (LPITEMIDLIST)ptr; CDefView *pThis = (CDefView *)arg; /* in a commdlg This works as a filemask*/ - if ( pThis->IncludeObject(pidl)==S_OK ) pThis->LV_AddItem(pidl); + if (pThis->IncludeObject(pidl) == S_OK) + pThis->LV_AddItem(pidl); + SHFree(pidl); return TRUE; } @@ -781,31 +814,29 @@ TRACE("%p\n",this); - DbgPrint("[shell32, CDefView::FillList] Called\n"); - /* get the itemlist from the shfolder*/ hRes = pSFParent->EnumObjects(m_hWnd, SHCONTF_NONFOLDERS | SHCONTF_FOLDERS, &pEnumIDList); if (hRes != S_OK) { - if (hRes==S_FALSE) - return(NOERROR); - return(hRes); + if (hRes==S_FALSE) + return(NOERROR); + return(hRes); } /* create a pointer array */ hdpa = DPA_Create(16); if (!hdpa) { - return(E_OUTOFMEMORY); + return(E_OUTOFMEMORY); } /* copy the items into the array*/ while((S_OK == pEnumIDList->Next(1, &pidl, &dwFetched)) && dwFetched) { - if (DPA_InsertPtr(hdpa, 0x7fff, pidl) == -1) - { - SHFree(pidl); - } + if (DPA_InsertPtr(hdpa, 0x7fff, pidl) == -1) + { + SHFree(pidl); + } } /* sort the array */ @@ -879,10 +910,10 @@ if(CreateList()) { - if(InitList()) - { - FillList(); - } + if(InitList()) + { + FillList(); + } } if (SUCCEEDED(this->QueryInterface(IID_IDropTarget, (LPVOID*)&pdt))) @@ -892,10 +923,10 @@ pSFParent->QueryInterface(IID_IPersistFolder2, (LPVOID*)&ppf2); if (ppf2) { - ppf2->GetCurFolder((LPITEMIDLIST*)&ntreg.pidl); - ntreg.fRecursive = TRUE; - hNotify = SHChangeNotifyRegister(m_hWnd, SHCNF_IDLIST, SHCNE_ALLEVENTS, SHV_CHANGE_NOTIFY, 1, &ntreg); - SHFree((LPITEMIDLIST)ntreg.pidl); + ppf2->GetCurFolder((LPITEMIDLIST*)&ntreg.pidl); + ntreg.fRecursive = TRUE; + hNotify = SHChangeNotifyRegister(m_hWnd, SHCNF_IDLIST, SHCNE_ALLEVENTS, SHV_CHANGE_NOTIFY, 1, &ntreg); + SHFree((LPITEMIDLIST)ntreg.pidl); } hAccel = LoadAcceleratorsA(shell32_hInstance, "shv_accel"); @@ -919,34 +950,36 @@ TRACE("(%p)\n",this); hSubMenu = CreatePopupMenu(); - if(hSubMenu) - { /*get the number of items in our global array*/ - for(nTools = 0; Tools[nTools].idCommand != -1; nTools++){} - - /*add the menu items*/ - for(i = 0; i < nTools; i++) - { - LoadStringW(shell32_hInstance, Tools[i].idMenuString, szText, MAX_PATH); - - ZeroMemory(&mii, sizeof(mii)); - mii.cbSize = sizeof(mii); - mii.fMask = MIIM_TYPE | MIIM_ID | MIIM_STATE; - - if(BTNS_SEP != Tools[i].bStyle) /* no separator*/ + if (hSubMenu) + { + /*get the number of items in our global array*/ + for(nTools = 0; Tools[nTools].idCommand != -1; nTools++){} + + /*add the menu items*/ + for(i = 0; i < nTools; i++) { - mii.fType = MFT_STRING; - mii.fState = MFS_ENABLED; - mii.dwTypeData = szText; - mii.wID = Tools[i].idCommand; + LoadStringW(shell32_hInstance, Tools[i].idMenuString, szText, MAX_PATH); + + ZeroMemory(&mii, sizeof(mii)); + mii.cbSize = sizeof(mii); + mii.fMask = MIIM_TYPE | MIIM_ID | MIIM_STATE; + + if(BTNS_SEP != Tools[i].bStyle) /* no separator*/ + { + mii.fType = MFT_STRING; + mii.fState = MFS_ENABLED; + mii.dwTypeData = szText; + mii.wID = Tools[i].idCommand; + } + else + { + mii.fType = MFT_SEPARATOR; + } + /* tack This item onto the end of the menu */ + InsertMenuItemW(hSubMenu, (UINT)-1, TRUE, &mii); } - else - { - mii.fType = MFT_SEPARATOR; - } - /* tack This item onto the end of the menu */ - InsertMenuItemW(hSubMenu, (UINT)-1, TRUE, &mii); - } - } + } + TRACE("-- return (menu=%p)\n",hSubMenu); return hSubMenu; } @@ -955,14 +988,15 @@ * ShellView_MergeFileMenu() */ void CDefView::MergeFileMenu(HMENU hSubMenu) -{ TRACE("(%p)->(submenu=%p) stub\n",this,hSubMenu); - - if(hSubMenu) +{ + TRACE("(%p)->(submenu=%p) stub\n",this,hSubMenu); + + if (hSubMenu) { /*insert This item at the beginning of the menu */ _InsertMenuItemW(hSubMenu, 0, TRUE, 0, MFT_SEPARATOR, NULL, MFS_ENABLED); _InsertMenuItemW(hSubMenu, 0, TRUE, IDM_MYFILEITEM, MFT_STRING, L"dummy45", MFS_ENABLED); - - } + } + TRACE("--\n"); } @@ -973,20 +1007,21 @@ { TRACE("(%p)->(submenu=%p)\n",this,hSubMenu); - if(hSubMenu) - { /*add a separator at the correct position in the menu*/ - MENUITEMINFOW mii; - static WCHAR view[] = L"View"; - - _InsertMenuItemW(hSubMenu, FCIDM_MENU_VIEW_SEP_OPTIONS, FALSE, 0, MFT_SEPARATOR, NULL, MFS_ENABLED); - - ZeroMemory(&mii, sizeof(mii)); - mii.cbSize = sizeof(mii); - mii.fMask = MIIM_SUBMENU | MIIM_TYPE | MIIM_DATA; - mii.fType = MFT_STRING; - mii.dwTypeData = view; - mii.hSubMenu = LoadMenuW(shell32_hInstance, L"MENU_001"); - InsertMenuItemW(hSubMenu, FCIDM_MENU_VIEW_SEP_OPTIONS, FALSE, &mii); + if (hSubMenu) + { + /*add a separator at the correct position in the menu*/ + MENUITEMINFOW mii; + static WCHAR view[] = L"View"; + + _InsertMenuItemW(hSubMenu, FCIDM_MENU_VIEW_SEP_OPTIONS, FALSE, 0, MFT_SEPARATOR, NULL, MFS_ENABLED); + + ZeroMemory(&mii, sizeof(mii)); + mii.cbSize = sizeof(mii); + mii.fMask = MIIM_SUBMENU | MIIM_TYPE | MIIM_DATA; + mii.fType = MFT_STRING; + mii.dwTypeData = view; + mii.hSubMenu = LoadMenuW(shell32_hInstance, L"MENU_001"); + InsertMenuItemW(hSubMenu, FCIDM_MENU_VIEW_SEP_OPTIONS, FALSE, &mii); } } @@ -1010,31 +1045,31 @@ TRACE("selected=%i\n", cidl); - if(apidl) - { - TRACE("-- Items selected =%u\n", cidl); - - lvItem.mask = LVIF_STATE | LVIF_PARAM; - lvItem.stateMask = LVIS_SELECTED; - lvItem.iItem = 0; - lvItem.iSubItem = 0; - lvItem.state = 0; - - while(SendMessageW(hWndList, LVM_GETITEMW, 0, (LPARAM)&lvItem) && (i < cidl)) - { - if(lvItem.state & LVIS_SELECTED) + if (apidl) + { + TRACE("-- Items selected =%u\n", cidl); + + lvItem.mask = LVIF_STATE | LVIF_PARAM; + lvItem.stateMask = LVIS_SELECTED; + lvItem.iItem = 0; + lvItem.iSubItem = 0; + lvItem.state = 0; + + while(SendMessageW(hWndList, LVM_GETITEMW, 0, (LPARAM)&lvItem) && (i < cidl)) { - apidl[i] = (LPITEMIDLIST)lvItem.lParam; - i++; - if (i == cidl) - break; - TRACE("-- selected Item found\n"); + if(lvItem.state & LVIS_SELECTED) + { + apidl[i] = (LPITEMIDLIST)lvItem.lParam; + i++; + if (i == cidl) + break; + TRACE("-- selected Item found\n"); + } + lvItem.iItem++; } - lvItem.iItem++; - } - } + } + return cidl; - } /********************************************************** @@ -1122,13 +1157,14 @@ if (FAILED(hr)) - return hr; + return hr; if (0 == CF_IDLIST) { - CF_IDLIST = RegisterClipboardFormatW(CFSTR_SHELLIDLIST); - } - fetc.cfFormat = CF_IDLIST; + CF_IDLIST = RegisterClipboardFormatW(CFSTR_SHELLIDLIST); + } + + fetc.cfFormat = CF_IDLIST; fetc.ptd = NULL; fetc.dwAspect = DVASPECT_CONTENT; fetc.lindex = -1; @@ -1136,11 +1172,11 @@ hr = selection->QueryGetData(&fetc); if (FAILED(hr)) - return hr; + return hr; hr = selection->GetData(&fetc, &stgm); if (FAILED(hr)) - return hr; + return hr; pIDList = (LPIDA)GlobalLock(stgm.hGlobal); @@ -1154,31 +1190,31 @@ for (i = pIDList->cidl; i > 0; --i) { - LPCITEMIDLIST pidl; - - pidl = (LPCITEMIDLIST)((LPBYTE)pIDList+pIDList->aoffset[i]); - - attribs = SFGAO_FOLDER; - hr = pSFParent->GetAttributesOf(1, &pidl, &attribs); - - if (SUCCEEDED(hr) && ! (attribs & SFGAO_FOLDER)) - { - SHELLEXECUTEINFOW shexinfo; - - shexinfo.cbSize = sizeof(SHELLEXECUTEINFOW); - shexinfo.fMask = SEE_MASK_INVOKEIDLIST; /* SEE_MASK_IDLIST is also possible. */ - shexinfo.hwnd = NULL; - shexinfo.lpVerb = NULL; - shexinfo.lpFile = NULL; - shexinfo.lpParameters = NULL; - shexinfo.lpDirectory = parent_dir; - shexinfo.nShow = SW_NORMAL; - shexinfo.lpIDList = ILCombine(parent_pidl, pidl); - - ShellExecuteExW(&shexinfo); /* Discard error/success info */ - - ILFree((LPITEMIDLIST)shexinfo.lpIDList); - } + LPCITEMIDLIST pidl; + + pidl = (LPCITEMIDLIST)((LPBYTE)pIDList+pIDList->aoffset[i]); + + attribs = SFGAO_FOLDER; + hr = pSFParent->GetAttributesOf(1, &pidl, &attribs); + + if (SUCCEEDED(hr) && ! (attribs & SFGAO_FOLDER)) + { + SHELLEXECUTEINFOW shexinfo; + + shexinfo.cbSize = sizeof(SHELLEXECUTEINFOW); + shexinfo.fMask = SEE_MASK_INVOKEIDLIST; /* SEE_MASK_IDLIST is also possible. */ + shexinfo.hwnd = NULL; + shexinfo.lpVerb = NULL; + shexinfo.lpFile = NULL; + shexinfo.lpParameters = NULL; + shexinfo.lpDirectory = parent_dir; + shexinfo.nShow = SW_NORMAL; + shexinfo.lpIDList = ILCombine(parent_pidl, pidl); + + ShellExecuteExW(&shexinfo); /* Discard error/success info */ + + ILFree((LPITEMIDLIST)shexinfo.lpIDList); + } } GlobalUnlock(stgm.hGlobal); @@ -1219,91 +1255,95 @@ /* look, what's selected and create a context menu object of it*/ if (GetSelections()) { - pSFParent->GetUIObjectOf(hWndParent, cidl, (LPCITEMIDLIST*)apidl, IID_IContextMenu, NULL, (LPVOID *)&pCM); - - if(pCM) - { - TRACE("-- pContextMenu\n"); + pSFParent->GetUIObjectOf(hWndParent, cidl, (LPCITEMIDLIST*)apidl, IID_IContextMenu, NULL, (LPVOID *)&pCM); + + if (pCM) + { + TRACE("-- pContextMenu\n"); + hMenu = CreatePopupMenu(); + + if (hMenu) + { + hResult = IUnknown_SetSite(pCM, (IShellView *)this); + + /* See if we are in Explore or Open mode. If the browser's tree is present, we are in Explore mode.*/ + if (SUCCEEDED(pShellBrowser->GetControlWindow(FCW_TREE, &hwndTree)) && hwndTree) + { + TRACE("-- explore mode\n"); + fExplore = TRUE; + } + + /* build the flags depending on what we can do with the selected item */ + wFlags = CMF_NORMAL | (cidl != 1 ? 0 : CMF_CANRENAME) | (fExplore ? CMF_EXPLORE : 0); + + /* let the ContextMenu merge its items in */ + if (SUCCEEDED(pCM->QueryContextMenu(hMenu, 0, FCIDM_SHVIEWFIRST, FCIDM_SHVIEWLAST, wFlags ))) + { + if (FolderSettings.fFlags & FWF_DESKTOP) + SetMenuDefaultItem(hMenu, FCIDM_SHVIEW_OPEN, MF_BYCOMMAND); + + if (bDefault) + { + TRACE("-- get menu default command\n"); + uCommand = GetMenuDefaultItem(hMenu, FALSE, GMDI_GOINTOPOPUPS); + } + else + { + TRACE("-- track popup\n"); + uCommand = TrackPopupMenu( hMenu,TPM_LEFTALIGN | TPM_RETURNCMD,x,y,0,m_hWnd,NULL); + } + + if (uCommand > 0) + { + TRACE("-- uCommand=%u\n", uCommand); + + if (uCommand==FCIDM_SHVIEW_OPEN && pCommDlgBrowser.p != NULL) + { + TRACE("-- dlg: OnDefaultCommand\n"); + if (OnDefaultCommand() != S_OK) + { + OpenSelectedItems(); + } + } + else + { + TRACE("-- explore -- invoke command\n"); + ZeroMemory(&cmi, sizeof(cmi)); + cmi.cbSize = sizeof(cmi); + cmi.hwnd = hWndParent; /* this window has to answer CWM_GETISHELLBROWSER */ + cmi.lpVerb = (LPCSTR)MAKEINTRESOURCEA(uCommand); + pCM->InvokeCommand(&cmi); + } + } + + hResult = IUnknown_SetSite(pCM, NULL); + DestroyMenu(hMenu); + } + } + pCM.Release(); + } + } + else /* background context menu */ + { hMenu = CreatePopupMenu(); - if( hMenu ) - { - hResult = IUnknown_SetSite(pCM, (IShellView *)this); - /* See if we are in Explore or Open mode. If the browser's tree is present, we are in Explore mode.*/ - if(SUCCEEDED(pShellBrowser->GetControlWindow(FCW_TREE, &hwndTree)) && hwndTree) - { - TRACE("-- explore mode\n"); - fExplore = TRUE; - } - - /* build the flags depending on what we can do with the selected item */ - wFlags = CMF_NORMAL | (cidl != 1 ? 0 : CMF_CANRENAME) | (fExplore ? CMF_EXPLORE : 0); - - /* let the ContextMenu merge its items in */ - if (SUCCEEDED(pCM->QueryContextMenu(hMenu, 0, FCIDM_SHVIEWFIRST, FCIDM_SHVIEWLAST, wFlags ))) - { - if (FolderSettings.fFlags & FWF_DESKTOP) - SetMenuDefaultItem(hMenu, FCIDM_SHVIEW_OPEN, MF_BYCOMMAND); - - if( bDefault ) - { - TRACE("-- get menu default command\n"); - uCommand = GetMenuDefaultItem(hMenu, FALSE, GMDI_GOINTOPOPUPS); - } - else - { - TRACE("-- track popup\n"); - uCommand = TrackPopupMenu( hMenu,TPM_LEFTALIGN | TPM_RETURNCMD,x,y,0,m_hWnd,NULL); - } - - if(uCommand > 0) - { - TRACE("-- uCommand=%u\n", uCommand); - if (uCommand==FCIDM_SHVIEW_OPEN && pCommDlgBrowser.p != NULL) - { - TRACE("-- dlg: OnDefaultCommand\n"); - if (OnDefaultCommand() != S_OK) - { - OpenSelectedItems(); - } - } - else - { - TRACE("-- explore -- invoke command\n"); - ZeroMemory(&cmi, sizeof(cmi)); - cmi.cbSize = sizeof(cmi); - cmi.hwnd = hWndParent; /* this window has to answer CWM_GETISHELLBROWSER */ - cmi.lpVerb = (LPCSTR)MAKEINTRESOURCEA(uCommand); - pCM->InvokeCommand(&cmi); - } - } - hResult = IUnknown_SetSite(pCM, NULL); - DestroyMenu(hMenu); - } - } + CDefFolderMenu_Create2(NULL, NULL, cidl, (LPCITEMIDLIST*)apidl, pSFParent, NULL, 0, NULL, (IContextMenu**)&pCM); + pCM->QueryContextMenu(hMenu, 0, FCIDM_SHVIEWFIRST, FCIDM_SHVIEWLAST, 0); + + uCommand = TrackPopupMenu( hMenu, TPM_LEFTALIGN | TPM_RETURNCMD,x,y,0,m_hWnd,NULL); + DestroyMenu(hMenu); + + TRACE("-- (%p)->(uCommand=0x%08x )\n",this, uCommand); + + ZeroMemory(&cmi, sizeof(cmi)); + cmi.cbSize = sizeof(cmi); + cmi.lpVerb = (LPCSTR)MAKEINTRESOURCEA(uCommand); + cmi.hwnd = hWndParent; + pCM->InvokeCommand(&cmi); + pCM.Release(); - } - } - else /* background context menu */ - { - hMenu = CreatePopupMenu(); - - CDefFolderMenu_Create2(NULL, NULL, cidl, (LPCITEMIDLIST*)apidl, pSFParent, NULL, 0, NULL, (IContextMenu**)&pCM); - pCM->QueryContextMenu(hMenu, 0, FCIDM_SHVIEWFIRST, FCIDM_SHVIEWLAST, 0); - - uCommand = TrackPopupMenu( hMenu, TPM_LEFTALIGN | TPM_RETURNCMD,x,y,0,m_hWnd,NULL); - DestroyMenu(hMenu); - - TRACE("-- (%p)->(uCommand=0x%08x )\n",this, uCommand); - - ZeroMemory(&cmi, sizeof(cmi)); - cmi.cbSize = sizeof(cmi); - cmi.lpVerb = (LPCSTR)MAKEINTRESOURCEA(uCommand); - cmi.hwnd = hWndParent; - pCM->InvokeCommand(&cmi); - - pCM.Release(); - } + } + return 0; } @@ -1343,17 +1383,17 @@ { TRACE("%p\n",this); - if(uState != SVUIA_DEACTIVATE) - { - if(hMenu) - { - pShellBrowser->SetMenuSB(0, 0, 0); - pShellBrowser->RemoveMenusSB(hMenu); - DestroyMenu(hMenu); - hMenu = 0; - } - - uState = SVUIA_DEACTIVATE; + if (uState != SVUIA_DEACTIVATE) + { + if (hMenu) + { + pShellBrowser->SetMenuSB(0, 0, 0); + pShellBrowser->RemoveMenusSB(hMenu); + DestroyMenu(hMenu); + hMenu = 0; + } + + uState = SVUIA_DEACTIVATE; } } @@ -1366,9 +1406,9 @@ TRACE("%p uState=%x\n", this, uState); /*don't do anything if the state isn't really changing */ - if(uState == uState) - { - return; + if (uState == uState) + { + return; } OnDeactivate(); @@ -1376,57 +1416,58 @@ /*only do This if we are active */ if(uState != SVUIA_DEACTIVATE) { - /*merge the menus */ - hMenu = CreateMenu(); - - if(hMenu) - { - pShellBrowser->InsertMenusSB(hMenu, &omw); - TRACE("-- after fnInsertMenusSB\n"); - - /*build the top level menu get the menu item's text*/ - strcpy(szText,"dummy 31"); - - ZeroMemory(&mii, sizeof(mii)); - mii.cbSize = sizeof(mii); - mii.fMask = MIIM_SUBMENU | MIIM_TYPE | MIIM_STATE; - mii.fType = MFT_STRING; - mii.fState = MFS_ENABLED; - mii.dwTypeData = szText; - mii.hSubMenu = BuildFileMenu(); - - /*insert our menu into the menu bar*/ - if(mii.hSubMenu) + /*merge the menus */ + hMenu = CreateMenu(); + + if(hMenu) { - InsertMenuItemA(hMenu, FCIDM_MENU_HELP, FALSE, &mii); + pShellBrowser->InsertMenusSB(hMenu, &omw); + TRACE("-- after fnInsertMenusSB\n"); + + /*build the top level menu get the menu item's text*/ + strcpy(szText,"dummy 31"); + + ZeroMemory(&mii, sizeof(mii)); + mii.cbSize = sizeof(mii); + mii.fMask = MIIM_SUBMENU | MIIM_TYPE | MIIM_STATE; + mii.fType = MFT_STRING; + mii.fState = MFS_ENABLED; + mii.dwTypeData = szText; + mii.hSubMenu = BuildFileMenu(); + + /*insert our menu into the menu bar*/ + if (mii.hSubMenu) + { + InsertMenuItemA(hMenu, FCIDM_MENU_HELP, FALSE, &mii); + } + + /*get the view menu so we can merge with it*/ + ZeroMemory(&mii, sizeof(mii)); + mii.cbSize = sizeof(mii); + mii.fMask = MIIM_SUBMENU; + + if (GetMenuItemInfoA(hMenu, FCIDM_MENU_VIEW, FALSE, &mii)) + { + MergeViewMenu(mii.hSubMenu); + } + + /*add the items that should only be added if we have the focus*/ + if (SVUIA_ACTIVATE_FOCUS == uState) + { + /*get the file menu so we can merge with it */ + ZeroMemory(&mii, sizeof(mii)); + mii.cbSize = sizeof(mii); + mii.fMask = MIIM_SUBMENU; + + if (GetMenuItemInfoA(hMenu, FCIDM_MENU_FILE, FALSE, &mii)) + { + MergeFileMenu(mii.hSubMenu); + } + } + + TRACE("-- before fnSetMenuSB\n"); + pShellBrowser->SetMenuSB(hMenu, 0, m_hWnd); } - - /*get the view menu so we can merge with it*/ - ZeroMemory(&mii, sizeof(mii)); - mii.cbSize = sizeof(mii); - mii.fMask = MIIM_SUBMENU; - - if(GetMenuItemInfoA(hMenu, FCIDM_MENU_VIEW, FALSE, &mii)) - { - MergeViewMenu(mii.hSubMenu); - } - - /*add the items that should only be added if we have the focus*/ - if(SVUIA_ACTIVATE_FOCUS == uState) - { - /*get the file menu so we can merge with it */ - ZeroMemory(&mii, sizeof(mii)); - mii.cbSize = sizeof(mii); - mii.fMask = MIIM_SUBMENU; - - if(GetMenuItemInfoA(hMenu, FCIDM_MENU_FILE, FALSE, &mii)) - { - MergeFileMenu(mii.hSubMenu); - } - } - TRACE("-- before fnSetMenuSB\n"); - pShellBrowser->SetMenuSB(hMenu, 0, m_hWnd); - } } uState = uState; TRACE("--\n"); @@ -1497,46 +1538,47 @@ TRACE("(%p)->(0x%08x 0x%08x %p) stub\n",this, dwCmdID, dwCmd, hwndCmd); - switch(dwCmdID) - { - case FCIDM_SHVIEW_SMALLICON: - FolderSettings.ViewMode = FVM_SMALLICON; - SetStyle (LVS_SMALLICON, LVS_TYPEMASK); - CheckToolbar(); - break; - - case FCIDM_SHVIEW_BIGICON: - FolderSettings.ViewMode = FVM_ICON; - SetStyle (LVS_ICON, LVS_TYPEMASK); - CheckToolbar(); - break; - - case FCIDM_SHVIEW_LISTVIEW: - FolderSettings.ViewMode = FVM_LIST; - SetStyle (LVS_LIST, LVS_TYPEMASK); - CheckToolbar(); - break; - - case FCIDM_SHVIEW_REPORTVIEW: - FolderSettings.ViewMode = FVM_DETAILS; - SetStyle (LVS_REPORT, LVS_TYPEMASK); - CheckToolbar(); - break; - - /* the menu-ID's for sorting are 0x30... see shrec.rc */ - case 0x30: - case 0x31: - case 0x32: - case 0x33: - ListViewSortInfo.nHeaderID = (LPARAM) (dwCmdID - 0x30); - ListViewSortInfo.bIsAscending = TRUE; - ListViewSortInfo.nLastHeaderID = ListViewSortInfo.nHeaderID; - SendMessageA(hWndList, LVM_SORTITEMS, (WPARAM) &ListViewSortInfo, (LPARAM)ListViewCompareItems); - break; - - default: + switch (dwCmdID) + { + case FCIDM_SHVIEW_SMALLICON: + FolderSettings.ViewMode = FVM_SMALLICON; + SetStyle (LVS_SMALLICON, LVS_TYPEMASK); + CheckToolbar(); + break; + + case FCIDM_SHVIEW_BIGICON: + FolderSettings.ViewMode = FVM_ICON; + SetStyle (LVS_ICON, LVS_TYPEMASK); + CheckToolbar(); + break; + + case FCIDM_SHVIEW_LISTVIEW: + FolderSettings.ViewMode = FVM_LIST; + SetStyle (LVS_LIST, LVS_TYPEMASK); + CheckToolbar(); + break; + + case FCIDM_SHVIEW_REPORTVIEW: + FolderSettings.ViewMode = FVM_DETAILS; + SetStyle (LVS_REPORT, LVS_TYPEMASK); + CheckToolbar(); + break; + + /* the menu-ID's for sorting are 0x30... see shrec.rc */ + case 0x30: + case 0x31: + case 0x32: + case 0x33: + ListViewSortInfo.nHeaderID = (LPARAM) (dwCmdID - 0x30); + ListViewSortInfo.bIsAscending = TRUE; + ListViewSortInfo.nLastHeaderID = ListViewSortInfo.nHeaderID; + SendMessageA(hWndList, LVM_SORTITEMS, (WPARAM) &ListViewSortInfo, (LPARAM)ListViewCompareItems); + break; + + default: TRACE("-- COMMAND 0x%04x unhandled\n", dwCmdID); } + return 0; } @@ -1560,429 +1602,430 @@ TRACE("%p CtlID=%u lpnmh->code=%x\n",this,CtlID,lpnmh->code); - switch(lpnmh->code) - { - case NM_SETFOCUS: - TRACE("-- NM_SETFOCUS %p\n", this); - OnSetFocus(0, 0, 0, unused); - break; - - case NM_KILLFOCUS: - TRACE("-- NM_KILLFOCUS %p\n", this); - OnDeactivate(); - /* Notify the ICommDlgBrowser interface */ - OnStateChange(CDBOSC_KILLFOCUS); - break; - - case NM_CUSTOMDRAW: - TRACE("-- NM_CUSTOMDRAW %p\n", this); - return CDRF_DODEFAULT; - - case NM_RELEASEDCAPTURE: - TRACE("-- NM_RELEASEDCAPTURE %p\n", this); - break; - - case NM_CLICK: - TRACE("-- NM_CLICK %p\n", this); - break; - - case NM_RCLICK: - TRACE("-- NM_RCLICK %p\n", this); - break; - - case NM_DBLCLK: + switch (lpnmh->code) + { + case NM_SETFOCUS: + TRACE("-- NM_SETFOCUS %p\n", this); + OnSetFocus(0, 0, 0, unused); + break; + + case NM_KILLFOCUS: + TRACE("-- NM_KILLFOCUS %p\n", this); + OnDeactivate(); + /* Notify the ICommDlgBrowser interface */ + OnStateChange(CDBOSC_KILLFOCUS); + break; + + case NM_CUSTOMDRAW: + TRACE("-- NM_CUSTOMDRAW %p\n", this); + return CDRF_DODEFAULT; + + case NM_RELEASEDCAPTURE: + TRACE("-- NM_RELEASEDCAPTURE %p\n", this); + break; + + case NM_CLICK: + TRACE("-- NM_CLICK %p\n", this); + break; + + case NM_RCLICK: + TRACE("-- NM_RCLICK %p\n", this); + break; + + case NM_DBLCLK: TRACE("-- NM_DBLCLK %p\n", this); if (OnDefaultCommand() != S_OK) OpenSelectedItems(); break; - case NM_RETURN: + case NM_RETURN: TRACE("-- NM_RETURN %p\n", this); if (OnDefaultCommand() != S_OK) OpenSelectedItems(); break; - case HDN_ENDTRACKW: - TRACE("-- HDN_ENDTRACKW %p\n", this); - /*nColumn1 = ListView_GetColumnWidth(hWndList, 0); - nColumn2 = ListView_GetColumnWidth(hWndList, 1);*/ - break; - - case LVN_DELETEITEM: - TRACE("-- LVN_DELETEITEM %p\n", this); - SHFree((LPITEMIDLIST)lpnmlv->lParam); /*delete the pidl because we made a copy of it*/ - break; - - case LVN_DELETEALLITEMS: - TRACE("-- LVN_DELETEALLITEMS %p\n", this); - return FALSE; - - case LVN_INSERTITEM: - TRACE("-- LVN_INSERTITEM (STUB)%p\n", this); - break; - - case LVN_ITEMACTIVATE: - TRACE("-- LVN_ITEMACTIVATE %p\n", this); - OnStateChange(CDBOSC_SELCHANGE); /* the browser will get the IDataObject now */ - break; - - case LVN_COLUMNCLICK: - ListViewSortInfo.nHeaderID = lpnmlv->iSubItem; - if(ListViewSortInfo.nLastHeaderID == ListViewSortInfo.nHeaderID) + case HDN_ENDTRACKW: + TRACE("-- HDN_ENDTRACKW %p\n", this); + /*nColumn1 = ListView_GetColumnWidth(hWndList, 0); + nColumn2 = ListView_GetColumnWidth(hWndList, 1);*/ + break; + + case LVN_DELETEITEM: + TRACE("-- LVN_DELETEITEM %p\n", this); + SHFree((LPITEMIDLIST)lpnmlv->lParam); /*delete the pidl because we made a copy of it*/ + break; + + case LVN_DELETEALLITEMS: + TRACE("-- LVN_DELETEALLITEMS %p\n", this); + return FALSE; + + case LVN_INSERTITEM: + TRACE("-- LVN_INSERTITEM (STUB)%p\n", this); + break; + + case LVN_ITEMACTIVATE: + TRACE("-- LVN_ITEMACTIVATE %p\n", this); + OnStateChange(CDBOSC_SELCHANGE); /* the browser will get the IDataObject now */ + break; + + case LVN_COLUMNCLICK: + ListViewSortInfo.nHeaderID = lpnmlv->iSubItem; + if (ListViewSortInfo.nLastHeaderID == ListViewSortInfo.nHeaderID) + { + ListViewSortInfo.bIsAscending = !ListViewSortInfo.bIsAscending; + } + else + { + ListViewSortInfo.bIsAscending = TRUE; + } + ListViewSortInfo.nLastHeaderID = ListViewSortInfo.nHeaderID; + + SendMessageW(lpnmlv->hdr.hwndFrom, LVM_SORTITEMS, (WPARAM) &ListViewSortInfo, (LPARAM)ListViewCompareItems); + break; + + case LVN_GETDISPINFOA: + case LVN_GETDISPINFOW: + TRACE("-- LVN_GETDISPINFO %p\n", this); + pidl = (LPITEMIDLIST)lpdi->item.lParam; + + if (lpdi->item.mask & LVIF_TEXT) /* text requested */ + { + if (pSF2Parent) + { + SHELLDETAILS sd; + pSF2Parent->GetDetailsOf(pidl, lpdi->item.iSubItem, &sd); + if (lpnmh->code == LVN_GETDISPINFOA) + { + /* shouldn't happen */ + NMLVDISPINFOA *lpdiA = (NMLVDISPINFOA *)lpnmh; + StrRetToStrNA( lpdiA->item.pszText, lpdiA->item.cchTextMax, &sd.str, NULL); + TRACE("-- text=%s\n",lpdiA->item.pszText); + } + else /* LVN_GETDISPINFOW */ + { + StrRetToStrNW( lpdi->item.pszText, lpdi->item.cchTextMax, &sd.str, NULL); + TRACE("-- text=%s\n",debugstr_w(lpdi->item.pszText)); + } + } + else + { + FIXME("no SF2\n"); + } + } + if(lpdi->item.mask & LVIF_IMAGE) /* image requested */ + { + lpdi->item.iImage = SHMapPIDLToSystemImageListIndex(pSFParent, pidl, 0); + } + lpdi->item.mask |= LVIF_DI_SETITEM; + break; + + case LVN_ITEMCHANGED: + TRACE("-- LVN_ITEMCHANGED %p\n", this); + OnStateChange(CDBOSC_SELCHANGE); /* the browser will get the IDataObject now */ + break; + + case LVN_BEGINDRAG: + case LVN_BEGINRDRAG: + TRACE("-- LVN_BEGINDRAG\n"); + + if (GetSelections()) + { + IDataObject * pda; + DWORD dwAttributes = SFGAO_CANLINK; + DWORD dwEffect = DROPEFFECT_COPY | DROPEFFECT_MOVE; + + if (SUCCEEDED(pSFParent->GetUIObjectOf(m_hWnd, cidl, (LPCITEMIDLIST*)apidl, IID_IDataObject,0,(LPVOID *)&pda))) + { + IDropSource * pds = (IDropSource *)this; /* own DropSource interface */ + + if (SUCCEEDED(pSFParent->GetAttributesOf(cidl, (LPCITEMIDLIST*)apidl, &dwAttributes))) + { + if (dwAttributes & SFGAO_CANLINK) + { + dwEffect |= DROPEFFECT_LINK; + } + } + + if (pds) + { + DWORD dwEffect2; + DoDragDrop(pda, pds, dwEffect, &dwEffect2); + } + pda->Release(); + } + } + break; + + case LVN_BEGINLABELEDITW: { - ListViewSortInfo.bIsAscending = !ListViewSortInfo.bIsAscending; + DWORD dwAttr = SFGAO_CANRENAME; + pidl = (LPITEMIDLIST)lpdi->item.lParam; + + TRACE("-- LVN_BEGINLABELEDITW %p\n", this); + + pSFParent->GetAttributesOf(1, (LPCITEMIDLIST*)&pidl, &dwAttr); + if (SFGAO_CANRENAME & dwAttr) + { + return FALSE; + } + return TRUE; } - else + + case LVN_ENDLABELEDITW: { - ListViewSortInfo.bIsAscending = TRUE; + TRACE("-- LVN_ENDLABELEDITW %p\n", this); + if (lpdi->item.pszText) + { + HRESULT hr; + LVITEMW lvItem; + + lvItem.iItem = lpdi->item.iItem; + lvItem.iSubItem = 0; + lvItem.mask = LVIF_PARAM; + SendMessageW(hWndList, LVM_GETITEMW, 0, (LPARAM) &lvItem); + + pidl = (LPITEMIDLIST)lpdi->item.lParam; + hr = pSFParent->SetNameOf(0, pidl, lpdi->item.pszText, SHGDN_INFOLDER, &pidl); + + if (SUCCEEDED(hr) && pidl) + { + lvItem.mask = LVIF_PARAM; + lvItem.lParam = (LPARAM)pidl; + SendMessageW(hWndList, LVM_SETITEMW, 0, (LPARAM) &lvItem); + + return TRUE; + } + } + + return FALSE; } - ListViewSortInfo.nLastHeaderID = ListViewSortInfo.nHeaderID; - - SendMessageW(lpnmlv->hdr.hwndFrom, LVM_SORTITEMS, (WPARAM) &ListViewSortInfo, (LPARAM)ListViewCompareItems); - break; - - case LVN_GETDISPINFOA: - case LVN_GETDISPINFOW: - TRACE("-- LVN_GETDISPINFO %p\n", this); - pidl = (LPITEMIDLIST)lpdi->item.lParam; - - if(lpdi->item.mask & LVIF_TEXT) /* text requested */ - { - if (pSF2Parent) - { - SHELLDETAILS sd; - pSF2Parent->GetDetailsOf(pidl, lpdi->item.iSubItem, &sd); - if (lpnmh->code == LVN_GETDISPINFOA) - { - /* shouldn't happen */ - NMLVDISPINFOA *lpdiA = (NMLVDISPINFOA *)lpnmh; - StrRetToStrNA( lpdiA->item.pszText, lpdiA->item.cchTextMax, &sd.str, NULL); - TRACE("-- text=%s\n",lpdiA->item.pszText); - } - else /* LVN_GETDISPINFOW */ - { - StrRetToStrNW( lpdi->item.pszText, lpdi->item.cchTextMax, &sd.str, NULL); - TRACE("-- text=%s\n",debugstr_w(lpdi->item.pszText)); - } - } - else - { - FIXME("no SF2\n"); - } - } - if(lpdi->item.mask & LVIF_IMAGE) /* image requested */ - { - lpdi->item.iImage = SHMapPIDLToSystemImageListIndex(pSFParent, pidl, 0); - } - lpdi->item.mask |= LVIF_DI_SETITEM; - break; - - case LVN_ITEMCHANGED: - TRACE("-- LVN_ITEMCHANGED %p\n", this); - OnStateChange(CDBOSC_SELCHANGE); /* the browser will get the IDataObject now */ - break; - - case LVN_BEGINDRAG: - case LVN_BEGINRDRAG: - TRACE("-- LVN_BEGINDRAG\n"); - - if (GetSelections()) - { - IDataObject * pda; - DWORD dwAttributes = SFGAO_CANLINK; - DWORD dwEffect = DROPEFFECT_COPY | DROPEFFECT_MOVE; - - if (SUCCEEDED(pSFParent->GetUIObjectOf(m_hWnd, cidl, (LPCITEMIDLIST*)apidl, IID_IDataObject,0,(LPVOID *)&pda))) - { - IDropSource * pds = (IDropSource *)this; /* own DropSource interface */ - - if (SUCCEEDED(pSFParent->GetAttributesOf(cidl, (LPCITEMIDLIST*)apidl, &dwAttributes))) - { - if (dwAttributes & SFGAO_CANLINK) - { - dwEffect |= DROPEFFECT_LINK; - } - } - - if (pds) - { - DWORD dwEffect2; - DoDragDrop(pda, pds, dwEffect, &dwEffect2); - } - pda->Release(); - } - } - break; - - case LVN_BEGINLABELEDITW: - { - DWORD dwAttr = SFGAO_CANRENAME; - pidl = (LPITEMIDLIST)lpdi->item.lParam; - - TRACE("-- LVN_BEGINLABELEDITW %p\n", this); - - pSFParent->GetAttributesOf(1, (LPCITEMIDLIST*)&pidl, &dwAttr); - if (SFGAO_CANRENAME & dwAttr) - { - return FALSE; - } - return TRUE; - } - - case LVN_ENDLABELEDITW: - { - TRACE("-- LVN_ENDLABELEDITW %p\n", this); - if (lpdi->item.pszText) - { - HRESULT hr; - LVITEMW lvItem; - - lvItem.iItem = lpdi->item.iItem; - lvItem.iSubItem = 0; - lvItem.mask = LVIF_PARAM; - SendMessageW(hWndList, LVM_GETITEMW, 0, (LPARAM) &lvItem); - - pidl = (LPITEMIDLIST)lpdi->item.lParam; - hr = pSFParent->SetNameOf(0, pidl, lpdi->item.pszText, SHGDN_INFOLDER, &pidl); - - if(SUCCEEDED(hr) && pidl) - { - lvItem.mask = LVIF_PARAM; - lvItem.lParam = (LPARAM)pidl; - SendMessageW(hWndList, LVM_SETITEMW, 0, (LPARAM) &lvItem); - return TRUE; - } - } - return FALSE; - } - - case LVN_KEYDOWN: + + case LVN_KEYDOWN: { /* MSG msg; - msg.hwnd = m_hWnd; - msg.message = WM_KEYDOWN; - msg.wParam = plvKeyDown->wVKey; - msg.lParam = 0; - msg.time = 0; - msg.pt = 0;*/ - - LPNMLVKEYDOWN plvKeyDown = (LPNMLVKEYDOWN) lpnmh; - SHORT ctrl = GetKeyState(VK_CONTROL) & 0x8000; - - /* initiate a rename of the selected file or directory */ - if(plvKeyDown->wVKey == VK_F2) - { + msg.hwnd = m_hWnd; + msg.message = WM_KEYDOWN; + msg.wParam = plvKeyDown->wVKey; + msg.lParam = 0; + msg.time = 0; + msg.pt = 0;*/ + + LPNMLVKEYDOWN plvKeyDown = (LPNMLVKEYDOWN) lpnmh; + SHORT ctrl = GetKeyState(VK_CONTROL) & 0x8000; + + /* initiate a rename of the selected file or directory */ + if (plvKeyDown->wVKey == VK_F2) + { /* see how many files are selected */ int i = ListView_GetSelectedCount(hWndList); /* get selected item */ - if(i == 1) + if (i == 1) { - /* get selected item */ - i = ListView_GetNextItem(hWndList, -1, - LVNI_SELECTED); - - SendMessageW(hWndList, LVM_ENSUREVISIBLE, i, 0); - SendMessageW(hWndList, LVM_EDITLABELW, i, 0); + /* get selected item */ + i = ListView_GetNextItem(hWndList, -1, LVNI_SELECTED); + + SendMessageW(hWndList, LVM_ENSUREVISIBLE, i, 0); + SendMessageW(hWndList, LVM_EDITLABELW, i, 0); } - } -#if 0 - TranslateAccelerator(m_hWnd, hAccel, &msg) -#endif - else if(plvKeyDown->wVKey == VK_DELETE) - { - UINT i; - int item_index; - LVITEMA item; - LPITEMIDLIST* pItems; - ISFHelper *psfhlp; - - pSFParent->QueryInterface(IID_ISFHelper, - (LPVOID*)&psfhlp); - - if (psfhlp == NULL) - break; - - if(!(i = ListView_GetSelectedCount(hWndList))) - break; - - /* allocate memory for the pidl array */ - pItems = (LPITEMIDLIST *)HeapAlloc(GetProcessHeap(), 0, - sizeof(LPITEMIDLIST) * i); - - /* retrieve all selected items */ - i = 0; - item_index = -1; - while(ListView_GetSelectedCount(hWndList) > i) - { - /* get selected item */ - item_index = ListView_GetNextItem(hWndList, - item_index, LVNI_SELECTED); - item.iItem = item_index; - item.mask = LVIF_PARAM; - SendMessageA(hWndList, LVM_GETITEMA, 0, (LPARAM) &item); - - /* get item pidl */ - pItems[i] = (LPITEMIDLIST)item.lParam; - - i++; - } - - /* perform the item deletion */ - psfhlp->DeleteItems(i, (LPCITEMIDLIST*)pItems); - - /* free pidl array memory */ - HeapFree(GetProcessHeap(), 0, pItems); - } - - /* Initiate a refresh */ - else if(plvKeyDown->wVKey == VK_F5) - { - Refresh(); - } - else if(plvKeyDown->wVKey == VK_BACK) - { - LPSHELLBROWSER lpSb; - if((lpSb = (LPSHELLBROWSER)SendMessageW(hWndParent, CWM_GETISHELLBROWSER, 0, 0))) + } + #if 0 + TranslateAccelerator(m_hWnd, hAccel, &msg) + #endif + else if(plvKeyDown->wVKey == VK_DELETE) { - lpSb->BrowseObject(NULL, SBSP_PARENT); + UINT i; + int item_index; + LVITEMA item; + LPITEMIDLIST* pItems; + ISFHelper *psfhlp; + + pSFParent->QueryInterface(IID_ISFHelper, + (LPVOID*)&psfhlp); + + if (psfhlp == NULL) + break; + + if (!(i = ListView_GetSelectedCount(hWndList))) + break; + + /* allocate memory for the pidl array */ + pItems = (LPITEMIDLIST *)HeapAlloc(GetProcessHeap(), 0, + sizeof(LPITEMIDLIST) * i); + + /* retrieve all selected items */ + i = 0; + item_index = -1; + while (ListView_GetSelectedCount(hWndList) > i) + { + /* get selected item */ + item_index = ListView_GetNextItem(hWndList, + item_index, LVNI_SELECTED); + item.iItem = item_index; + item.mask = LVIF_PARAM; + SendMessageA(hWndList, LVM_GETITEMA, 0, (LPARAM) &item); + + /* get item pidl */ + pItems[i] = (LPITEMIDLIST)item.lParam; + + i++; + } + + /* perform the item deletion */ + psfhlp->DeleteItems(i, (LPCITEMIDLIST*)pItems); + + /* free pidl array memory */ + HeapFree(GetProcessHeap(), 0, pItems); } - } - else if(plvKeyDown->wVKey == 'C' && ctrl) - { - if (GetSelections()) + /* Initiate a refresh */ + else if (plvKeyDown->wVKey == VK_F5) + { + Refresh(); + } + else if (plvKeyDown->wVKey == VK_BACK) + { + LPSHELLBROWSER lpSb; + if ((lpSb = (LPSHELLBROWSER)SendMessageW(hWndParent, CWM_GETISHELLBROWSER, 0, 0))) + { + lpSb->BrowseObject(NULL, SBSP_PARENT); + } + } + else if (plvKeyDown->wVKey == 'C' && ctrl) + { + if (GetSelections()) + { + CComPtr<IDataObject> pda; + + if (SUCCEEDED(pSFParent->GetUIObjectOf(m_hWnd, cidl, (LPCITEMIDLIST*)apidl, IID_IDataObject, 0, (LPVOID *)&pda))) + { + HRESULT hr = OleSetClipboard(pda); + if (FAILED(hr)) + { + WARN("OleSetClipboard failed"); + } + } + } + break; + } + else if(plvKeyDown->wVKey == 'V' && ctrl) { CComPtr<IDataObject> pda; - - if (SUCCEEDED(pSFParent->GetUIObjectOf(m_hWnd, cidl, (LPCITEMIDLIST*)apidl, IID_IDataObject, 0, (LPVOID *)&pda))) + STGMEDIUM medium; + FORMATETC formatetc; + LPITEMIDLIST * apidl; + LPITEMIDLIST pidl; + CComPtr<IShellFolder> psfFrom; + CComPtr<IShellFolder> psfDesktop; + CComPtr<IShellFolder> psfTarget; + LPIDA lpcida; + CComPtr<ISFHelper> psfhlpdst; + CComPtr<ISFHelper> psfhlpsrc; + HRESULT hr; + + hr = OleGetClipboard(&pda); + if (hr != S_OK) { - HRESULT hr = OleSetClipboard(pda); - if (FAILED(hr)) - { - WARN("OleSetClipboard failed"); - } + ERR("Failed to get clipboard with %lx\n", hr); + return E_FAIL; } - } - break; - } - else if(plvKeyDown->wVKey == 'V' && ctrl) - { - CComPtr<IDataObject> pda; - STGMEDIUM medium; - FORMATETC formatetc; - LPITEMIDLIST * apidl; - LPITEMIDLIST pidl; - CComPtr<IShellFolder> psfFrom; - CComPtr<IShellFolder> psfDesktop; - CComPtr<IShellFolder> psfTarget; - LPIDA lpcida; - CComPtr<ISFHelper> psfhlpdst; - CComPtr<ISFHelper> psfhlpsrc; - HRESULT hr; - - hr = OleGetClipboard(&pda); - if (hr != S_OK) - { - ERR("Failed to get clipboard with %lx\n", hr); - return E_FAIL; - } - - InitFormatEtc(formatetc, RegisterClipboardFormatW(CFSTR_SHELLIDLIST), TYMED_HGLOBAL); - hr = pda->GetData(&formatetc, &medium); - - if (FAILED(hr)) - { - ERR("Failed to get clipboard data with %lx\n", hr); - return E_FAIL; - } - - /* lock the handle */ - lpcida = (LPIDA)GlobalLock(medium.hGlobal); - if (!lpcida) - { - ERR("failed to lock pidl\n"); - ReleaseStgMedium(&medium); - return E_FAIL; - } - - /* convert the data into pidl */ - apidl = _ILCopyCidaToaPidl(&pidl, lpcida); - - if (!apidl) - { - ERR("failed to copy pidl\n"); - return E_FAIL; - } - - if (FAILED(SHGetDesktopFolder(&psfDesktop))) - { - ERR("failed to get desktop folder\n"); + + InitFormatEtc(formatetc, RegisterClipboardFormatW(CFSTR_SHELLIDLIST), TYMED_HGLOBAL); + hr = pda->GetData(&formatetc, &medium); + + if (FAILED(hr)) + { + ERR("Failed to get clipboard data with %lx\n", hr); + return E_FAIL; + } + + /* lock the handle */ + lpcida = (LPIDA)GlobalLock(medium.hGlobal); + if (!lpcida) + { + ERR("failed to lock pidl\n"); + ReleaseStgMedium(&medium); + return E_FAIL; + } + + /* convert the data into pidl */ + apidl = _ILCopyCidaToaPidl(&pidl, lpcida); + + if (!apidl) + { + ERR("failed to copy pidl\n"); + return E_FAIL; + } + + if (FAILED(SHGetDesktopFolder(&psfDesktop))) + { + ERR("failed to get desktop folder\n"); + SHFree(pidl); + _ILFreeaPidl(apidl, lpcida->cidl); + ReleaseStgMedium(&medium); + return E_FAIL; + } + + if (_ILIsDesktop(pidl)) + { + /* use desktop shellfolder */ + psfFrom = psfDesktop; + } + else if (FAILED(psfDesktop->BindToObject(pidl, NULL, IID_IShellFolder, (LPVOID*)&psfFrom))) + { + ERR("no IShellFolder\n"); + + SHFree(pidl); + _ILFreeaPidl(apidl, lpcida->cidl); + ReleaseStgMedium(&medium); + + return E_FAIL; + } + + psfTarget = pSFParent; + + + /* get source and destination shellfolder */ + if (FAILED(psfTarget->QueryInterface(IID_ISFHelper, (LPVOID*)&psfhlpdst))) + { + ERR("no IID_ISFHelper for destination\n"); + + SHFree(pidl); + _ILFreeaPidl(apidl, lpcida->cidl); + ReleaseStgMedium(&medium); + + return E_FAIL; + } + + if (FAILED(psfFrom->QueryInterface(IID_ISFHelper, (LPVOID*)&psfhlpsrc))) + { + ERR("no IID_ISFHelper for source\n"); + + SHFree(pidl); + _ILFreeaPidl(apidl, lpcida->cidl); + ReleaseStgMedium(&medium); + return E_FAIL; + } + + /* FIXXME + * do we want to perform a copy or move ??? + */ + hr = psfhlpdst->CopyItems(psfFrom, lpcida->cidl, (LPCITEMIDLIST*)apidl); + SHFree(pidl); _ILFreeaPidl(apidl, lpcida->cidl); ReleaseStgMedium(&medium); - return E_FAIL; - } - - if (_ILIsDesktop(pidl)) - { - /* use desktop shellfolder */ - psfFrom = psfDesktop; - } - else if (FAILED(psfDesktop->BindToObject(pidl, NULL, IID_IShellFolder, (LPVOID*)&psfFrom))) - { - ERR("no IShellFolder\n"); - - SHFree(pidl); - _ILFreeaPidl(apidl, lpcida->cidl); - ReleaseStgMedium(&medium); - - return E_FAIL; - } - - psfTarget = pSFParent; - - - /* get source and destination shellfolder */ - if (FAILED(psfTarget->QueryInterface(IID_ISFHelper, (LPVOID*)&psfhlpdst))) - { - ERR("no IID_ISFHelper for destination\n"); - - SHFree(pidl); - _ILFreeaPidl(apidl, lpcida->cidl); - ReleaseStgMedium(&medium); - - return E_FAIL; - } - - if (FAILED(psfFrom->QueryInterface(IID_ISFHelper, (LPVOID*)&psfhlpsrc))) - { - ERR("no IID_ISFHelper for source\n"); - - SHFree(pidl); - _ILFreeaPidl(apidl, lpcida->cidl); - ReleaseStgMedium(&medium); - return E_FAIL; - } - - /* FIXXME - * do we want to perform a copy or move ??? - */ - hr = psfhlpdst->CopyItems(psfFrom, lpcida->cidl, (LPCITEMIDLIST*)apidl); - - SHFree(pidl); - _ILFreeaPidl(apidl, lpcida->cidl); - ReleaseStgMedium(&medium); - - TRACE("paste end hr %x\n", hr); - break; - } - else - FIXME("LVN_KEYDOWN key=0x%08x\n",plvKeyDown->wVKey); + + TRACE("paste end hr %x\n", hr); + break; + } + else + FIXME("LVN_KEYDOWN key=0x%08x\n",plvKeyDown->wVKey); } break; - default: - TRACE("-- %p WM_COMMAND %x unhandled\n", this, lpnmh->code); - break; - } + default: + TRACE("-- %p WM_COMMAND %x unhandled\n", this, lpnmh->code); + break; + } + return 0; } @@ -2003,17 +2046,21 @@ case SHCNE_CREATE: LV_AddItem(Pidls[0]); break; + case SHCNE_RMDIR: case SHCNE_DELETE: LV_DeleteItem(Pidls[0]); break; + case SHCNE_RENAMEFOLDER: case SHCNE_RENAMEITEM: LV_RenameItem(Pidls[0], Pidls[1]); break; + case SHCNE_UPDATEITEM: break; } + return TRUE; } @@ -2024,9 +2071,9 @@ { if (!pCM.p) { - /* no menu */ - ERR("no menu!!!\n"); - return FALSE; + /* no menu */ + ERR("no menu!!!\n"); + return FALSE; } if (pCM.p->HandleMenuMsg(uMsg, (WPARAM)m_hWnd, lParam) == S_OK) @@ -2077,8 +2124,9 @@ if (lpmsg->message >= WM_KEYFIRST && lpmsg->message >= WM_KEYLAST) { - TRACE("-- key=0x04%lx\n",lpmsg->wParam) ; - } + TRACE("-- key=0x04%lx\n",lpmsg->wParam) ; + } + return S_FALSE; /* not handled */ } @@ -2100,29 +2148,29 @@ TRACE("(%p)->(state=%x) stub\n",this, uState); /*don't do anything if the state isn't really changing*/ - if(uState == uState) - { - return S_OK; + if (uState == uState) + { + return S_OK; } /*OnActivate handles the menu merging and internal state*/ DoActivate(uState); /*only do This if we are active*/ - if(uState != SVUIA_DEACTIVATE) - { - -/* - GetFolderPath is not a method of IShellFolder - IShellFolder_GetFolderPath( pSFParent, szName, sizeof(szName) ); -*/ - /* set the number of parts */ - pShellBrowser->SendControlMsg(FCW_STATUS, SB_SETPARTS, 1, (LPARAM)nPartArray, &lResult); - - /* set the text for the parts */ -/* - pShellBrowser->SendControlMsg(FCW_STATUS, SB_SETTEXTA, 0, (LPARAM)szName, &lResult); -*/ + if (uState != SVUIA_DEACTIVATE) + { + + /* + GetFolderPath is not a method of IShellFolder + IShellFolder_GetFolderPath( pSFParent, szName, sizeof(szName) ); + */ + /* set the number of parts */ + pShellBrowser->SendControlMsg(FCW_STATUS, SB_SETPARTS, 1, (LPARAM)nPartArray, &lResult); + + /* set the text for the parts */ + /* + pShellBrowser->SendControlMsg(FCW_STATUS, SB_SETTEXTA, 0, (LPARAM)szName, &lResult); + */ } return S_OK; @@ -2195,9 +2243,9 @@ /*Make absolutely sure all our UI is cleaned up.*/ UIActivate(SVUIA_DEACTIVATE); - if(hMenu) - { - DestroyMenu(hMenu); + if (hMenu) + { + DestroyMenu(hMenu); } DestroyWindow(); @@ -2212,7 +2260,8 @@ TRACE("(%p)->(%p) vmode=%x flags=%x\n",this, lpfs, FolderSettings.ViewMode, FolderSettings.fFlags); - if (!lpfs) return E_INVALIDARG; + if (!lpfs) + return E_INVALIDARG; *lpfs = FolderSettings; return NOERROR; @@ -2242,42 +2291,43 @@ if (i != -1) { - LVITEMW lvItem; - - if(uFlags & SVSI_ENSUREVISIBLE) + LVITEMW lvItem; + + if(uFlags & SVSI_ENSUREVISIBLE) SendMessageW(hWndList, LVM_ENSUREVISIBLE, i, 0); - lvItem.mask = LVIF_STATE; - lvItem.stateMask = LVIS_SELECTED | LVIS_FOCUSED; - lvItem.iItem = 0; - lvItem.iSubItem = 0; - - while(SendMessageW(hWndList, LVM_GETITEMW, 0, (LPARAM) &lvItem)) - { - if (lvItem.iItem == i) + lvItem.mask = LVIF_STATE; + lvItem.stateMask = LVIS_SELECTED | LVIS_FOCUSED; + lvItem.iItem = 0; + lvItem.iSubItem = 0; + + while (SendMessageW(hWndList, LVM_GETITEMW, 0, (LPARAM) &lvItem)) { - if (uFlags & SVSI_SELECT) - lvItem.state |= LVIS_SELECTED; - else - lvItem.state &= ~LVIS_SELECTED; - - if(uFlags & SVSI_FOCUSED) - lvItem.state &= ~LVIS_FOCUSED; + if (lvItem.iItem == i) + { + if (uFlags & SVSI_SELECT) + lvItem.state |= LVIS_SELECTED; + else + lvItem.state &= ~LVIS_SELECTED; + + if (uFlags & SVSI_FOCUSED) + lvItem.state &= ~LVIS_FOCUSED; + } + else + { + if (uFlags & SVSI_DESELECTOTHERS) + lvItem.state &= ~LVIS_SELECTED; + } + + SendMessageW(hWndList, LVM_SETITEMW, 0, (LPARAM) &lvItem); + lvItem.iItem++; } - else - { - if (uFlags & SVSI_DESELECTOTHERS) - lvItem.state &= ~LVIS_SELECTED; - } - SendMessageW(hWndList, LVM_SETITEMW, 0, (LPARAM) &lvItem); - lvItem.iItem++; - } - - - if(uFlags & SVSI_EDIT) + + + if(uFlags & SVSI_EDIT) SendMessageW(hWndList, LVM_EDITLABELW, i, 0); - - } + } + return S_OK; } @@ -2289,23 +2339,24 @@ *ppvOut = NULL; - switch(uItem) + switch (uItem) { case SVGIO_BACKGROUND: - if (IsEqualIID(riid, IID_IContextMenu)) - { - //*ppvOut = ISvBgCm_Constructor(pSFParent, FALSE); - CDefFolderMenu_Create2(NULL, NULL, cidl, (LPCITEMIDLIST*)apidl, pSFParent, NULL, 0, NULL, (IContextMenu**)ppvOut); - if (!ppvOut) - hr = E_OUTOFMEMORY; - } - break; + if (IsEqualIID(riid, IID_IContextMenu)) + { + //*ppvOut = ISvBgCm_Constructor(pSFParent, FALSE); + CDefFolderMenu_Create2(NULL, NULL, cidl, (LPCITEMIDLIST*)apidl, pSFParent, NULL, 0, NULL, (IContextMenu**)ppvOut); + if (!ppvOut) + hr = E_OUTOFMEMORY; + } + break; case SVGIO_SELECTION: GetSelections(); hr = pSFParent->GetUIObjectOf(m_hWnd, cidl, (LPCITEMIDLIST*)apidl, riid, 0, ppvOut); break; } + TRACE("-- (%p)->(interface=%p)\n",this, *ppvOut); return hr; @@ -2325,6 +2376,7 @@ { if (pSFParent == NULL) return E_FAIL; + return pSFParent->QueryInterface(riid, ppv); } @@ -2388,18 +2440,18 @@ */ HRESULT WINAPI CDefView::QueryStatus(const GUID *pguidCmdGroup, ULONG cCmds, OLECMD *prgCmds, OLECMDTEXT *pCmdText) { - UINT i; - FIXME("(%p)->(%p(%s) 0x%08x %p %p\n", this, pguidCmdGroup, debugstr_guid(pguidCmdGroup), cCmds, prgCmds, pCmdText); if (!prgCmds) return E_POINTER; - for (i = 0; i < cCmds; i++) + + for (UINT i=0; i < cCmds; i++) { FIXME("\tprgCmds[%d].cmdID = %d\n", i, prgCmds[i].cmdID); prgCmds[i].cmdf = 0; } + return OLECMDERR_E_UNKNOWNGROUP; } @@ -2417,7 +2469,8 @@ (nCmdID == 0x29) && (nCmdexecopt == 4) && pvaOut) return S_OK; - if (IsEqualIID(*pguidCmdGroup, CGID_ShellDocView) && + + if (IsEqualIID(*pguidCmdGroup, CGID_ShellDocView) && (nCmdID == 9) && (nCmdexecopt == 0)) return 1; @@ -2461,38 +2514,50 @@ htinfo.pt.y < SCROLLAREAWIDTH || htinfo.pt.y > clientRect.bottom - SCROLLAREAWIDTH )) { cScrollDelay = (cScrollDelay + 1) % 5; /* DragOver is called every 50 ms */ - if (cScrollDelay == 0) { /* Mouse did hover another 250 ms over the scroll-area */ + if (cScrollDelay == 0) + { + /* Mouse did hover another 250 ms over the scroll-area */ if (htinfo.pt.x < SCROLLAREAWIDTH) SendMessageW(hWndList, WM_HSCROLL, SB_LINEUP, 0); + if (htinfo.pt.x > clientRect.right - SCROLLAREAWIDTH) SendMessageW(hWndList, WM_HSCROLL, SB_LINEDOWN, 0); + if (htinfo.pt.y < SCROLLAREAWIDTH) SendMessageW(hWndList, WM_VSCROLL, SB_LINEUP, 0); + if (htinfo.pt.y > clientRect.bottom - SCROLLAREAWIDTH) SendMessageW(hWndList, WM_VSCROLL, SB_LINEDOWN, 0); } - } else { + } + else + { cScrollDelay = 0; /* Reset, if the cursor is not over the listview's scroll-area */ } + ptLastMousePos = htinfo.pt; /* If we are still over the previous sub-item, notify it via DragOver and return. */ if (pCurDropTarget && lResult == iDragOverItem) - return pCurDropTarget->DragOver(grfKeyState, pt, pdwEffect); + return pCurDropTarget->DragOver(grfKeyState, pt, pdwEffect); /* We've left the previous sub-item, notify it via DragLeave and Release it. */ - if (pCurDropTarget) { + if (pCurDropTarget) + { pCurDropTarget->DragLeave(); pCurDropTarget.Release(); } iDragOverItem = lResult; - if (lResult == -1) { + if (lResult == -1) + { /* We are not above one of the listview's subitems. Bind to the parent folder's * DropTarget interface. */ hr = pSFParent->QueryInterface(IID_IDropTarget, (LPVOID*)&pCurDropTarget); - } else { + } + else + { /* Query the relative PIDL of the shellfolder object represented by the currently * dragged over listview-item ... */ lvItem.mask = LVIF_PARAM; @@ -2568,11 +2633,11 @@ TRACE("(%p)\n",this); if (fEscapePressed) - return DRAGDROP_S_CANCEL; + return DRAGDROP_S_CANCEL; else if (!(grfKeyState & MK_LBUTTON) && !(grfKeyState & MK_RBUTTON)) - return DRAGDROP_S_DROP; + return DRAGDROP_S_DROP; else - return NOERROR; + return NOERROR; } HRESULT WINAPI CDefView::GiveFeedback(DWORD dwEffect) @@ -2630,14 +2695,16 @@ { TRACE("this=%p pAspects=%p pAdvf=%p ppAdvSink=%p\n", this, pAspects, pAdvf, ppAdvSink); - if( ppAdvSink ) + if (ppAdvSink) { *ppAdvSink = pAdvSink; pAdvSink.p->AddRef(); } - if( pAspects ) + + if (pAspects) *pAspects = dwAspects; - if( pAdvf ) + + if (pAdvf) *pAdvf = dwAdvf; return S_OK; @@ -2661,19 +2728,24 @@ if (newView == NULL) return E_POINTER; - *newView = NULL; + + *newView = NULL; ATLTRY (theView = new CComObject<CDefView>); - if (theView == NULL) + + if (theView == NULL) return E_OUTOFMEMORY; - hResult = theView->QueryInterface (IID_IShellView, (void **)&result); + + hResult = theView->QueryInterface (IID_IShellView, (void **)&result); if (FAILED (hResult)) { delete theView; return hResult; } - hResult = theView->Initialize (pFolder); + + hResult = theView->Initialize (pFolder); if (FAILED (hResult)) return hResult; *newView = result.Detach (); - return S_OK; -} + + return S_OK; +}
13 years, 3 months
1
0
0
0
[tkreuzer] 53616: [HAL] - move v86 code out of trap.S into v86.S (APIC uses a different trap entry file), compile it directly in the dll instead of a lib to be able to silence linker warnings - Gro...
by tkreuzer@svn.reactos.org
Author: tkreuzer Date: Wed Sep 7 12:00:29 2011 New Revision: 53616 URL:
http://svn.reactos.org/svn/reactos?rev=53616&view=rev
Log: [HAL] - move v86 code out of trap.S into v86.S (APIC uses a different trap entry file), compile it directly in the dll instead of a lib to be able to silence linker warnings - Group files in HAL_PIC_SOURCE and HAL_APIC_SOURCE, you just need to replace PIC with APIC to build the hal with APIC support (we can later use it to build the other hals: halapic, halaacpi, halmacpi, halmps) - use apic on amd64 builds - give halacpi its own resource file - silence MSVC linker warnings Added: trunk/reactos/hal/halx86/acpi/halacpi.rc (with props) trunk/reactos/hal/halx86/generic/v86.S (with props) Modified: trunk/reactos/hal/halx86/CMakeLists.txt trunk/reactos/hal/halx86/generic/trap.S trunk/reactos/hal/halx86/hal_generic.rbuild Modified: trunk/reactos/hal/halx86/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/hal/halx86/CMakeLists.txt?…
============================================================================== --- trunk/reactos/hal/halx86/CMakeLists.txt [iso-8859-1] (original) +++ trunk/reactos/hal/halx86/CMakeLists.txt [iso-8859-1] Wed Sep 7 12:00:29 2011 @@ -15,7 +15,6 @@ generic/drive.c generic/memory.c generic/misc.c - generic/profil.c generic/reboot.c generic/sysinfo.c generic/usage.c) @@ -23,10 +22,7 @@ if(ARCH MATCHES i386) list(APPEND HAL_GENERIC_SOURCE generic/bios.c - generic/timer.c - generic/portio.c - generic/systimer.S - generic/trap.S) + generic/portio.c) endif() add_library(lib_hal_generic ${HAL_GENERIC_SOURCE}) @@ -58,11 +54,28 @@ #add_pch(lib_hal_acpi include/hal.h) target_link_libraries(lib_hal_acpi lib_hal_generic) +list(APPEND HAL_UP_SOURCE + generic/spinlock.c + generic/halinit.c + up/halinit_up.c + up/processor.c) + +list(APPEND HAL_PIC_SOURCE + generic/profil.c + generic/timer.c + generic/systimer.S + generic/trap.S + up/pic.c) + +list(APPEND HAL_APIC_SOURCE + apic/apic.c + apic/apictimer.c + apic/apictrap.S + apic/rtctimer.c + apic/tsc.c + apic/tsccal.S) + if(ARCH MATCHES i386) - list(APPEND HAL_UP_SOURCE - up/pic.c - up/processor.c) - list(APPEND MINI_HAL_SOURCE generic/portio.c generic/systimer.S @@ -94,10 +107,9 @@ # hal add_library(hal SHARED ${HAL_UP_SOURCE} - up/halinit_up.c + ${HAL_PIC_SOURCE} + generic/v86.S up/halup.rc - generic/spinlock.c - generic/halinit.c ${CMAKE_CURRENT_BINARY_DIR}/hal.def) target_link_libraries(hal lib_hal_generic lib_hal_legacy libcntpr) add_importlibs(hal ntoskrnl) @@ -107,15 +119,17 @@ set_subsystem(hal native) set_image_base(hal 0x00010000) add_cd_file(TARGET hal DESTINATION reactos/system32 NO_CAB FOR all) + if(MSVC) + add_target_link_flags(hal "/ignore:4216 /ignore:4078") + endif() # hal acpi spec2def(halacpi.dll ../hal.spec halacpi) add_library(halacpi SHARED ${HAL_UP_SOURCE} - up/halinit_up.c - up/halup.rc - generic/spinlock.c - generic/halinit.c + ${HAL_PIC_SOURCE} + generic/v86.S + acpi/halacpi.rc ${CMAKE_CURRENT_BINARY_DIR}/halacpi.def) target_link_libraries(halacpi lib_hal_generic lib_hal_acpi libcntpr) add_importlibs(halacpi ntoskrnl) @@ -125,6 +139,9 @@ set_image_base(halacpi 0x00010000) set_property(TARGET halacpi PROPERTY COMPILE_DEFINITIONS CONFIG_ACPI) add_cd_file(TARGET halacpi DESTINATION reactos/system32 NO_CAB FOR all) + if(MSVC) + add_target_link_flags(halacpi "/ignore:4216 /ignore:4078") + endif() # mini_hal add_library(mini_hal ${MINI_HAL_SOURCE}) @@ -138,13 +155,11 @@ list(APPEND HAL_SOURCE ${HAL_GENERIC_SOURCE} ${HAL_ACPI_SOURCE} - ${HAL_UP_SOURCE} + ${HAL_APIC_SOURCE} generic/spinlock.c generic/halinit.c amd64/x86bios.c amd64/halinit.c - amd64/stubs.c - amd64/systimer.S amd64/processor.c ${CMAKE_CURRENT_BINARY_DIR}/hal.def) @@ -158,6 +173,9 @@ set_image_base(hal 0x00010000) add_importlibs(hal ntoskrnl) target_link_libraries(hal libcntpr) + if(MSVC) + add_target_link_flags(hal "/ignore:4216") + endif() add_cd_file(TARGET hal DESTINATION reactos/system32 NO_CAB FOR all) Added: trunk/reactos/hal/halx86/acpi/halacpi.rc URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/hal/halx86/acpi/halacpi.rc…
============================================================================== --- trunk/reactos/hal/halx86/acpi/halacpi.rc (added) +++ trunk/reactos/hal/halx86/acpi/halacpi.rc [iso-8859-1] Wed Sep 7 12:00:29 2011 @@ -1,0 +1,5 @@ +#define REACTOS_VERSION_DLL +#define REACTOS_STR_FILE_DESCRIPTION "X86 Uniprocessor Hardware Abstraction Layer\0" +#define REACTOS_STR_INTERNAL_NAME "halacpi\0" +#define REACTOS_STR_ORIGINAL_FILENAME "halacpi.dll\0" +#include <reactos/version.rc> Propchange: trunk/reactos/hal/halx86/acpi/halacpi.rc ------------------------------------------------------------------------------ svn:eol-style = native Modified: trunk/reactos/hal/halx86/generic/trap.S URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/hal/halx86/generic/trap.S?…
============================================================================== --- trunk/reactos/hal/halx86/generic/trap.S [iso-8859-1] (original) +++ trunk/reactos/hal/halx86/generic/trap.S [iso-8859-1] Wed Sep 7 12:00:29 2011 @@ -20,28 +20,4 @@ TRAP_ENTRY HalpClockInterrupt, KI_PUSH_FAKE_ERROR_CODE TRAP_ENTRY HalpProfileInterrupt, KI_PUSH_FAKE_ERROR_CODE -PUBLIC @HalpExitToV86@4 -@HalpExitToV86@4: - /* Point esp to the iret frame and return */ - lea esp, [ecx + KTRAP_FRAME_EIP] - iretd - -/* Here starts the real mode code */ -.code16 -PUBLIC _HalpRealModeStart -_HalpRealModeStart: - /* INT 0x10: AH = 0 (Set video Mode), AL = 0x12 (Mode 12) */ - mov eax, HEX(12) - int HEX(10) - - /* BOP */ - .byte HEX(C4), HEX(C4) - -/* The real mode stack */ -.align 4 -.space 2048 -_HalpRealModeEnd: -PUBLIC _HalpRealModeEnd -.endcode16 - END Added: trunk/reactos/hal/halx86/generic/v86.S URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/hal/halx86/generic/v86.S?r…
============================================================================== --- trunk/reactos/hal/halx86/generic/v86.S (added) +++ trunk/reactos/hal/halx86/generic/v86.S [iso-8859-1] Wed Sep 7 12:00:29 2011 @@ -1,0 +1,41 @@ +/* + * FILE: hal/halx86/generic/v86.S + * COPYRIGHT: See COPYING in the top level directory + * PURPOSE: System Traps, Entrypoints and Exitpoints + * PROGRAMMER: Timo Kreuzer (timo.kreuzer(a)reactos.org) + * NOTE: See asmmacro.S for the shared entry/exit code. + */ + +/* INCLUDES ******************************************************************/ + +#include <asm.inc> + +#include <ks386.inc> + +.code + +PUBLIC @HalpExitToV86@4 +@HalpExitToV86@4: + /* Point esp to the iret frame and return */ + lea esp, [ecx + KTRAP_FRAME_EIP] + iretd + +/* Here starts the real mode code */ +.code16 +PUBLIC _HalpRealModeStart +_HalpRealModeStart: + /* INT 0x10: AH = 0 (Set video Mode), AL = 0x12 (Mode 12) */ + mov eax, HEX(12) + int HEX(10) + + /* BOP */ + .byte HEX(C4), HEX(C4) + +/* The real mode stack */ +.align 4 +.space 2048 +_HalpRealModeEnd: +PUBLIC _HalpRealModeEnd +.endcode16 + +END Propchange: trunk/reactos/hal/halx86/generic/v86.S ------------------------------------------------------------------------------ svn:eol-style = native Modified: trunk/reactos/hal/halx86/hal_generic.rbuild URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/hal/halx86/hal_generic.rbu…
============================================================================== --- trunk/reactos/hal/halx86/hal_generic.rbuild [iso-8859-1] (original) +++ trunk/reactos/hal/halx86/hal_generic.rbuild [iso-8859-1] Wed Sep 7 12:00:29 2011 @@ -24,6 +24,7 @@ <file>portio.c</file> <file>systimer.S</file> <file>trap.S</file> + <file>v86.S</file> </if> </directory> <directory name="include">
13 years, 3 months
1
0
0
0
[tkreuzer] 53615: [HAL] Rename HalpAcquireSystemHardwareSpinLock to HalpAcquireCmosSpinLock
by tkreuzer@svn.reactos.org
Author: tkreuzer Date: Wed Sep 7 10:14:48 2011 New Revision: 53615 URL:
http://svn.reactos.org/svn/reactos?rev=53615&view=rev
Log: [HAL] Rename HalpAcquireSystemHardwareSpinLock to HalpAcquireCmosSpinLock Modified: trunk/reactos/hal/halx86/generic/beep.c trunk/reactos/hal/halx86/generic/cmos.c trunk/reactos/hal/halx86/generic/profil.c trunk/reactos/hal/halx86/generic/reboot.c trunk/reactos/hal/halx86/generic/spinlock.c trunk/reactos/hal/halx86/generic/systimer.S trunk/reactos/hal/halx86/include/halp.h Modified: trunk/reactos/hal/halx86/generic/beep.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/hal/halx86/generic/beep.c?…
============================================================================== --- trunk/reactos/hal/halx86/generic/beep.c [iso-8859-1] (original) +++ trunk/reactos/hal/halx86/generic/beep.c [iso-8859-1] Wed Sep 7 10:14:48 2011 @@ -29,7 +29,7 @@ // // Acquire CMOS Lock // - HalpAcquireSystemHardwareSpinLock(); + HalpAcquireCmosSpinLock(); // // Turn the timer off by disconnecting its output pin and speaker gate @@ -58,7 +58,7 @@ // Program the PIT for binary mode // TimerControl.BcdMode = FALSE; - + // // Program the PIT to generate a square wave (Mode 3) on channel 2. // Channel 0 is used for the IRQ0 clock interval timer, and channel @@ -76,17 +76,17 @@ // TimerControl.OperatingMode = PitOperatingMode3; TimerControl.Channel = PitChannel2; - + // // Set the access mode that we'll use to program the reload value. // TimerControl.AccessMode = PitAccessModeLowHigh; - + // // Now write the programming bits // __outbyte(TIMER_CONTROL_PORT, TimerControl.Bits); - + // // Next we write the reload value for channel 2 // Modified: trunk/reactos/hal/halx86/generic/cmos.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/hal/halx86/generic/cmos.c?…
============================================================================== --- trunk/reactos/hal/halx86/generic/cmos.c [iso-8859-1] (original) +++ trunk/reactos/hal/halx86/generic/cmos.c [iso-8859-1] Wed Sep 7 10:14:48 2011 @@ -57,7 +57,7 @@ if (!Length) return 0; /* Acquire CMOS Lock */ - HalpAcquireSystemHardwareSpinLock(); + HalpAcquireCmosSpinLock(); /* Check if this is simple CMOS */ if (BusNumber == 0) @@ -111,7 +111,7 @@ if (!Length) return 0; /* Acquire CMOS Lock */ - HalpAcquireSystemHardwareSpinLock(); + HalpAcquireCmosSpinLock(); /* Check if this is simple CMOS */ if (BusNumber == 0) @@ -179,7 +179,7 @@ if (_stricmp(Name, "LastKnownGood")) return ENOENT; /* Acquire CMOS Lock */ - HalpAcquireSystemHardwareSpinLock(); + HalpAcquireCmosSpinLock(); /* Query the current value */ Val = HalpReadCmos(RTC_REGISTER_B) & 0x01; @@ -220,7 +220,7 @@ if (!_stricmp(Value, "TRUE")) { /* It's true, acquire CMOS lock */ - HalpAcquireSystemHardwareSpinLock(); + HalpAcquireCmosSpinLock(); /* Read the current value and add the flag */ Val = HalpReadCmos(RTC_REGISTER_B) | 1; @@ -228,7 +228,7 @@ else if (!_stricmp(Value, "FALSE")) { /* It's false, acquire CMOS lock */ - HalpAcquireSystemHardwareSpinLock(); + HalpAcquireCmosSpinLock(); /* Read the current value and mask out the flag */ Val = HalpReadCmos(RTC_REGISTER_B) & ~1; @@ -255,7 +255,7 @@ HalQueryRealTimeClock(OUT PTIME_FIELDS Time) { /* Acquire CMOS Lock */ - HalpAcquireSystemHardwareSpinLock(); + HalpAcquireCmosSpinLock(); /* Loop while update is in progress */ while ((HalpReadCmos(RTC_REGISTER_A)) & RTC_REG_A_UIP); @@ -290,7 +290,7 @@ HalSetRealTimeClock(IN PTIME_FIELDS Time) { /* Acquire CMOS Lock */ - HalpAcquireSystemHardwareSpinLock(); + HalpAcquireCmosSpinLock(); /* Loop while update is in progress */ while ((HalpReadCmos(RTC_REGISTER_A)) & RTC_REG_A_UIP); Modified: trunk/reactos/hal/halx86/generic/profil.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/hal/halx86/generic/profil.…
============================================================================== --- trunk/reactos/hal/halx86/generic/profil.c [iso-8859-1] (original) +++ trunk/reactos/hal/halx86/generic/profil.c [iso-8859-1] Wed Sep 7 10:14:48 2011 @@ -25,7 +25,7 @@ UCHAR StatusB; /* Acquire the CMOS lock */ - HalpAcquireSystemHardwareSpinLock(); + HalpAcquireCmosSpinLock(); /* Read Status Register B */ StatusB = HalpReadCmos(RTC_REGISTER_B); Modified: trunk/reactos/hal/halx86/generic/reboot.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/hal/halx86/generic/reboot.…
============================================================================== --- trunk/reactos/hal/halx86/generic/reboot.c [iso-8859-1] (original) +++ trunk/reactos/hal/halx86/generic/reboot.c [iso-8859-1] Wed Sep 7 10:14:48 2011 @@ -50,7 +50,7 @@ ((PUSHORT)ZeroPageMapping)[0x239] = 0x1234; /* Lock CMOS Access (and disable interrupts) */ - HalpAcquireSystemHardwareSpinLock(); + HalpAcquireCmosSpinLock(); /* Setup control register B */ WRITE_PORT_UCHAR((PUCHAR)0x70, 0x0B); Modified: trunk/reactos/hal/halx86/generic/spinlock.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/hal/halx86/generic/spinloc…
============================================================================== --- trunk/reactos/hal/halx86/generic/spinlock.c [iso-8859-1] (original) +++ trunk/reactos/hal/halx86/generic/spinlock.c [iso-8859-1] Wed Sep 7 10:14:48 2011 @@ -224,7 +224,7 @@ VOID NTAPI -HalpAcquireSystemHardwareSpinLock(VOID) +HalpAcquireCmosSpinLock(VOID) { ULONG Flags; Modified: trunk/reactos/hal/halx86/generic/systimer.S URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/hal/halx86/generic/systime…
============================================================================== --- trunk/reactos/hal/halx86/generic/systimer.S [iso-8859-1] (original) +++ trunk/reactos/hal/halx86/generic/systimer.S [iso-8859-1] Wed Sep 7 10:14:48 2011 @@ -11,7 +11,7 @@ #include <ks386.inc> -EXTERN _HalpAcquireSystemHardwareSpinLock@0:PROC +EXTERN _HalpAcquireCmosSpinLock@0:PROC EXTERN _HalpReleaseCmosSpinLock@0:PROC EXTERN _DbgBreakPoint@0:PROC @@ -98,7 +98,7 @@ mov dword ptr [ebp-12], 0 /* Acquire CMOS lock */ - call _HalpAcquireSystemHardwareSpinLock@0 + call _HalpAcquireCmosSpinLock@0 /* Now initialize register A on the CMOS */ mov ax, HEX(2D00) OR CMOS_REGISTER_A @@ -186,7 +186,7 @@ push offset Looper /* Acquire CMOS lock */ - call _HalpAcquireSystemHardwareSpinLock@0 + call _HalpAcquireCmosSpinLock@0 /* Now initialize register A on the CMOS */ mov ax, HEX(2D00) OR CMOS_REGISTER_A @@ -271,7 +271,7 @@ mov eax, HEX(13) /* Acquire CMOS lock */ - call _HalpAcquireSystemHardwareSpinLock@0 + call _HalpAcquireCmosSpinLock@0 /* Now initialize register A on the CMOS */ mov ax, HEX(2D00) OR CMOS_REGISTER_A Modified: trunk/reactos/hal/halx86/include/halp.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/hal/halx86/include/halp.h?…
============================================================================== --- trunk/reactos/hal/halx86/include/halp.h [iso-8859-1] (original) +++ trunk/reactos/hal/halx86/include/halp.h [iso-8859-1] Wed Sep 7 10:14:48 2011 @@ -722,7 +722,7 @@ // VOID NTAPI -HalpAcquireSystemHardwareSpinLock( +HalpAcquireCmosSpinLock( VOID );
13 years, 3 months
1
0
0
0
[rharabien] 53614: [MKHIVE] - Fix max key name length, max value name length, max value data length properties of registry key not being set correctly - Fixes #6042 - regedit on LiveCD shows keys a...
by rharabien@svn.reactos.org
Author: rharabien Date: Wed Sep 7 09:51:13 2011 New Revision: 53614 URL:
http://svn.reactos.org/svn/reactos?rev=53614&view=rev
Log: [MKHIVE] - Fix max key name length, max value name length, max value data length properties of registry key not being set correctly - Fixes #6042 - regedit on LiveCD shows keys and values now Modified: trunk/reactos/tools/mkhive/cmi.c trunk/reactos/tools/mkhive/registry.c Modified: trunk/reactos/tools/mkhive/cmi.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/mkhive/cmi.c?rev=536…
============================================================================== --- trunk/reactos/tools/mkhive/cmi.c [iso-8859-1] (original) +++ trunk/reactos/tools/mkhive/cmi.c [iso-8859-1] Wed Sep 7 09:51:13 2011 @@ -388,6 +388,19 @@ if (NT_SUCCESS(Status)) { ParentKeyCell->SubKeyCounts[Storage]++; + if (Packable) + { + if (NameLength*sizeof(WCHAR) > ParentKeyCell->MaxNameLen) + ParentKeyCell->MaxNameLen = NameLength*sizeof(WCHAR); + } + else + { + if (NameLength > ParentKeyCell->MaxNameLen) + ParentKeyCell->MaxNameLen = NameLength; + } + if (NewKeyCell->ClassLength > ParentKeyCell->MaxClassLen) + ParentKeyCell->MaxClassLen = NewKeyCell->ClassLength; + *pSubKeyCell = NewKeyCell; *pBlockOffset = NKBOffset; } @@ -720,6 +733,16 @@ ValueListCell->ValueOffset[KeyCell->ValueList.Count] = NewValueCellOffset; KeyCell->ValueList.Count++; + if (NewValueCell->Flags & VALUE_COMP_NAME) + { + if (NewValueCell->NameLength*sizeof(WCHAR) > KeyCell->MaxValueNameLen) + KeyCell->MaxValueNameLen = NewValueCell->NameLength*sizeof(WCHAR); + } + else + { + if (NewValueCell->NameLength > KeyCell->MaxValueNameLen) + KeyCell->MaxValueNameLen = NewValueCell->NameLength; + } HvMarkCellDirty(&RegistryHive->Hive, KeyCellOffset, FALSE); HvMarkCellDirty(&RegistryHive->Hive, KeyCell->ValueList.List, FALSE); Modified: trunk/reactos/tools/mkhive/registry.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/mkhive/registry.c?re…
============================================================================== --- trunk/reactos/tools/mkhive/registry.c [iso-8859-1] (original) +++ trunk/reactos/tools/mkhive/registry.c [iso-8859-1] Wed Sep 7 09:51:13 2011 @@ -448,6 +448,9 @@ HvMarkCellDirty(&Key->RegistryHive->Hive, ValueCellOffset, FALSE); } + if (cbData > Key->KeyCell->MaxValueDataLen) + Key->KeyCell->MaxValueDataLen = cbData; + HvMarkCellDirty(&Key->RegistryHive->Hive, Key->KeyCellOffset, FALSE); DPRINT("Return status 0x%08x\n", Status);
13 years, 3 months
1
0
0
0
[cmihail] 53613: [shell32.dll] - Another round of fixing badly initialized variables. Again Amine Khaldi being the hero.
by cmihail@svn.reactos.org
Author: cmihail Date: Wed Sep 7 01:33:31 2011 New Revision: 53613 URL:
http://svn.reactos.org/svn/reactos?rev=53613&view=rev
Log: [shell32.dll] - Another round of fixing badly initialized variables. Again Amine Khaldi being the hero. Modified: branches/shell32_new-bringup/dll/win32/shell32/shellord.cpp branches/shell32_new-bringup/dll/win32/shell32/shfldr_netplaces.cpp branches/shell32_new-bringup/dll/win32/shell32/shfldr_printers.cpp branches/shell32_new-bringup/dll/win32/shell32/shlview.cpp branches/shell32_new-bringup/dll/win32/shell32/shv_def_cmenu.cpp branches/shell32_new-bringup/dll/win32/shell32/shv_item_new.cpp Modified: branches/shell32_new-bringup/dll/win32/shell32/shellord.cpp URL:
http://svn.reactos.org/svn/reactos/branches/shell32_new-bringup/dll/win32/s…
============================================================================== --- branches/shell32_new-bringup/dll/win32/shell32/shellord.cpp [iso-8859-1] (original) +++ branches/shell32_new-bringup/dll/win32/shell32/shellord.cpp [iso-8859-1] Wed Sep 7 01:33:31 2011 @@ -2253,7 +2253,7 @@ * SHParseDisplayName [shell version 6.0] */ EXTERN_C HRESULT WINAPI SHParseDisplayName(LPCWSTR pszName, IBindCtx *pbc, -LPITEMIDLIST *ppidl, SFGAOF sfgaoIn, SFGAOF *psfgaoOut) + LPITEMIDLIST *ppidl, SFGAOF sfgaoIn, SFGAOF *psfgaoOut) { CComPtr<IShellFolder> psfDesktop; HRESULT hr=E_FAIL; Modified: branches/shell32_new-bringup/dll/win32/shell32/shfldr_netplaces.cpp URL:
http://svn.reactos.org/svn/reactos/branches/shell32_new-bringup/dll/win32/s…
============================================================================== --- branches/shell32_new-bringup/dll/win32/shell32/shfldr_netplaces.cpp [iso-8859-1] (original) +++ branches/shell32_new-bringup/dll/win32/shell32/shfldr_netplaces.cpp [iso-8859-1] Wed Sep 7 01:33:31 2011 @@ -45,6 +45,7 @@ CNetFolder::CNetFolder() { + pidlRoot = NULL; } CNetFolder::~CNetFolder() Modified: branches/shell32_new-bringup/dll/win32/shell32/shfldr_printers.cpp URL:
http://svn.reactos.org/svn/reactos/branches/shell32_new-bringup/dll/win32/s…
============================================================================== --- branches/shell32_new-bringup/dll/win32/shell32/shfldr_printers.cpp [iso-8859-1] (original) +++ branches/shell32_new-bringup/dll/win32/shell32/shfldr_printers.cpp [iso-8859-1] Wed Sep 7 01:33:31 2011 @@ -325,6 +325,8 @@ CPrinterFolder::CPrinterFolder() { + pidlRoot = NULL; + dwAttributes = 0; } CPrinterFolder::~CPrinterFolder() Modified: branches/shell32_new-bringup/dll/win32/shell32/shlview.cpp URL:
http://svn.reactos.org/svn/reactos/branches/shell32_new-bringup/dll/win32/s…
============================================================================== --- branches/shell32_new-bringup/dll/win32/shell32/shlview.cpp [iso-8859-1] (original) +++ branches/shell32_new-bringup/dll/win32/shell32/shlview.cpp [iso-8859-1] Wed Sep 7 01:33:31 2011 @@ -781,13 +781,15 @@ TRACE("%p\n",this); + DbgPrint("[shell32, CDefView::FillList] Called\n"); + /* get the itemlist from the shfolder*/ hRes = pSFParent->EnumObjects(m_hWnd, SHCONTF_NONFOLDERS | SHCONTF_FOLDERS, &pEnumIDList); if (hRes != S_OK) { if (hRes==S_FALSE) return(NOERROR); - return(hRes); + return(hRes); } /* create a pointer array */ @@ -873,6 +875,8 @@ TRACE("%p\n",this); + DbgPrint("[shell32, CDefView::OnCreate] Called\n"); + if(CreateList()) { if(InitList()) @@ -881,7 +885,7 @@ } } - if (SUCCEEDED(this->QueryInterface(IID_IDropTarget, (LPVOID*)&pdt))) + if (SUCCEEDED(this->QueryInterface(IID_IDropTarget, (LPVOID*)&pdt))) RegisterDragDrop(m_hWnd, pdt); /* register for receiving notifications */ @@ -1014,6 +1018,7 @@ lvItem.stateMask = LVIS_SELECTED; lvItem.iItem = 0; lvItem.iSubItem = 0; + lvItem.state = 0; while(SendMessageW(hWndList, LVM_GETITEMW, 0, (LPARAM)&lvItem) && (i < cidl)) { @@ -2139,6 +2144,8 @@ TRACE("(%p)->(shlview=%p set=%p shlbrs=%p rec=%p hwnd=%p) incomplete\n",this, lpPrevView,lpfs, psb, prcView, phWnd); + DbgPrint("[shell32, CDefView::CreateViewWindow] Called lpfs = 0x%x, psb = 0x%x\n", lpfs, psb); + if (lpfs != NULL) TRACE("-- vmode=%x flags=%x\n", lpfs->ViewMode, lpfs->fFlags); if (prcView != NULL) @@ -2161,6 +2168,8 @@ { TRACE("-- CommDlgBrowser\n"); } + + DbgPrint("[shell32, CDefView::CreateViewWindow] About to call the create function\n"); Create(hWndParent, prcView, NULL, WS_CHILD | WS_TABSTOP, 0, 0U); if (m_hWnd == NULL) Modified: branches/shell32_new-bringup/dll/win32/shell32/shv_def_cmenu.cpp URL:
http://svn.reactos.org/svn/reactos/branches/shell32_new-bringup/dll/win32/s…
============================================================================== --- branches/shell32_new-bringup/dll/win32/shell32/shv_def_cmenu.cpp [iso-8859-1] (original) +++ branches/shell32_new-bringup/dll/win32/shell32/shv_def_cmenu.cpp [iso-8859-1] Wed Sep 7 01:33:31 2011 @@ -619,6 +619,7 @@ mii.fType = MFT_STRING; mii.fState = MFS_ENABLED; mii.wID = 0x4000; + mii.dwTypeData = NULL; iIdSCMFirst = mii.wID; curEntry = shead; @@ -657,6 +658,10 @@ szVerb[(sizeof(szVerb)/sizeof(WCHAR))-1] = L'\0'; mii.dwTypeData = szVerb; } + else + { + TRACE("Failed to laod string, defaulting to default (NULL) value for mii.dwTypeData\n"); + } } else { @@ -752,7 +757,7 @@ UINT indexMenu; SFGAOF rfg; HRESULT hr; - BOOL bAddSep; + BOOL bAddSep = FALSE; GUID * guid; BOOL bClipboardData; STRRET strFile; Modified: branches/shell32_new-bringup/dll/win32/shell32/shv_item_new.cpp URL:
http://svn.reactos.org/svn/reactos/branches/shell32_new-bringup/dll/win32/s…
============================================================================== --- branches/shell32_new-bringup/dll/win32/shell32/shv_item_new.cpp [iso-8859-1] (original) +++ branches/shell32_new-bringup/dll/win32/shell32/shv_item_new.cpp [iso-8859-1] Wed Sep 7 01:33:31 2011 @@ -28,6 +28,7 @@ CNewMenu::CNewMenu() { s_SnHead = NULL; + szPath = NULL; } CNewMenu::~CNewMenu()
13 years, 3 months
1
0
0
0
[cmihail] 53612: [shell32.dll] - Initialize uninitialized variables in constructors. [atl] - Initialize uninitialized variables in constructors. All spotted by Amine Khaldi.
by cmihail@svn.reactos.org
Author: cmihail Date: Tue Sep 6 23:52:38 2011 New Revision: 53612 URL:
http://svn.reactos.org/svn/reactos?rev=53612&view=rev
Log: [shell32.dll] - Initialize uninitialized variables in constructors. [atl] - Initialize uninitialized variables in constructors. All spotted by Amine Khaldi. Modified: branches/shell32_new-bringup/dll/win32/shell32/autocomplete.cpp branches/shell32_new-bringup/dll/win32/shell32/she_ocmenu.cpp branches/shell32_new-bringup/dll/win32/shell32/shellole.cpp branches/shell32_new-bringup/dll/win32/shell32/shfldr_desktop.cpp branches/shell32_new-bringup/dll/win32/shell32/shfldr_fonts.cpp branches/shell32_new-bringup/dll/win32/shell32/shfldr_mydocuments.cpp branches/shell32_new-bringup/dll/win32/shell32/shlfolder.cpp branches/shell32_new-bringup/lib/atl/atlbase.h Modified: branches/shell32_new-bringup/dll/win32/shell32/autocomplete.cpp URL:
http://svn.reactos.org/svn/reactos/branches/shell32_new-bringup/dll/win32/s…
============================================================================== --- branches/shell32_new-bringup/dll/win32/shell32/autocomplete.cpp [iso-8859-1] (original) +++ branches/shell32_new-bringup/dll/win32/shell32/autocomplete.cpp [iso-8859-1] Tue Sep 6 23:52:38 2011 @@ -50,6 +50,7 @@ hwndListBox = NULL; txtbackup = NULL; quickComplete = NULL; + hwndEdit = NULL; } /************************************************************************** Modified: branches/shell32_new-bringup/dll/win32/shell32/she_ocmenu.cpp URL:
http://svn.reactos.org/svn/reactos/branches/shell32_new-bringup/dll/win32/s…
============================================================================== --- branches/shell32_new-bringup/dll/win32/shell32/she_ocmenu.cpp [iso-8859-1] (original) +++ branches/shell32_new-bringup/dll/win32/shell32/she_ocmenu.cpp [iso-8859-1] Tue Sep 6 23:52:38 2011 @@ -67,6 +67,7 @@ COpenWithMenu::COpenWithMenu() { + count = 0; } COpenWithMenu::~COpenWithMenu() Modified: branches/shell32_new-bringup/dll/win32/shell32/shellole.cpp URL:
http://svn.reactos.org/svn/reactos/branches/shell32_new-bringup/dll/win32/s…
============================================================================== --- branches/shell32_new-bringup/dll/win32/shell32/shellole.cpp [iso-8859-1] (original) +++ branches/shell32_new-bringup/dll/win32/shell32/shellole.cpp [iso-8859-1] Tue Sep 6 23:52:38 2011 @@ -329,6 +329,7 @@ lpfnCI = NULL; riidInst = NULL; pcRefDll = NULL; + rclsid = NULL; } HRESULT IDefClFImpl::Initialize(LPFNCREATEINSTANCE lpfnCIx, PLONG pcRefDllx, const IID *riidInstx) Modified: branches/shell32_new-bringup/dll/win32/shell32/shfldr_desktop.cpp URL:
http://svn.reactos.org/svn/reactos/branches/shell32_new-bringup/dll/win32/s…
============================================================================== --- branches/shell32_new-bringup/dll/win32/shell32/shfldr_desktop.cpp [iso-8859-1] (original) +++ branches/shell32_new-bringup/dll/win32/shell32/shfldr_desktop.cpp [iso-8859-1] Tue Sep 6 23:52:38 2011 @@ -22,7 +22,7 @@ #include <precomp.h> -WINE_DEFAULT_DEBUG_CHANNEL (shell); +WINE_DEFAULT_DEBUG_CHANNEL(shell); /* CDesktopFolder should create two file system folders internally, one representing the @@ -140,6 +140,7 @@ static WCHAR MyDocumentsClassString[] = L"{450D8FBA-AD25-11D0-98A8-0800361B1103}"; TRACE("(%p)->(flags=0x%08x)\n", this, dwFlags); + DbgPrint("[shell32, CDesktopFolderEnum::Initialize] Called with flags = %d\n", dwFlags); /* enumerate the root folders */ if (dwFlags & SHCONTF_FOLDERS) @@ -262,6 +263,7 @@ CDesktopFolder::CDesktopFolder() { + pidlRoot = NULL; } CDesktopFolder::~CDesktopFolder() @@ -393,20 +395,25 @@ HRESULT hResult; TRACE ("(%p)->(HWND=%p flags=0x%08x pplist=%p)\n", this, hwndOwner, dwFlags, ppEnumIDList); + DbgPrint("[shell32, CDesktopFolder::EnumObjects] Called with flags = %d\n", dwFlags); if (ppEnumIDList == NULL) return E_POINTER; *ppEnumIDList = NULL; - ATLTRY (theEnumerator = new CComObject<CDesktopFolderEnum>); - if (theEnumerator == NULL) + + ATLTRY (theEnumerator = new CComObject<CDesktopFolderEnum>); + + if (theEnumerator == NULL) return E_OUTOFMEMORY; - hResult = theEnumerator->QueryInterface (IID_IEnumIDList, (void **)&result); + + hResult = theEnumerator->QueryInterface (IID_IEnumIDList, (void **)&result); if (FAILED (hResult)) { delete theEnumerator; return hResult; } - hResult = theEnumerator->Initialize (this, hwndOwner, dwFlags); + + hResult = theEnumerator->Initialize (this, hwndOwner, dwFlags); if (FAILED (hResult)) return hResult; *ppEnumIDList = result.Detach (); Modified: branches/shell32_new-bringup/dll/win32/shell32/shfldr_fonts.cpp URL:
http://svn.reactos.org/svn/reactos/branches/shell32_new-bringup/dll/win32/s…
============================================================================== --- branches/shell32_new-bringup/dll/win32/shell32/shfldr_fonts.cpp [iso-8859-1] (original) +++ branches/shell32_new-bringup/dll/win32/shell32/shfldr_fonts.cpp [iso-8859-1] Tue Sep 6 23:52:38 2011 @@ -174,6 +174,7 @@ CFontsFolder::CFontsFolder() { + pidlRoot = NULL; } CFontsFolder::~CFontsFolder() Modified: branches/shell32_new-bringup/dll/win32/shell32/shfldr_mydocuments.cpp URL:
http://svn.reactos.org/svn/reactos/branches/shell32_new-bringup/dll/win32/s…
============================================================================== --- branches/shell32_new-bringup/dll/win32/shell32/shfldr_mydocuments.cpp [iso-8859-1] (original) +++ branches/shell32_new-bringup/dll/win32/shell32/shfldr_mydocuments.cpp [iso-8859-1] Tue Sep 6 23:52:38 2011 @@ -76,6 +76,7 @@ CMyDocsFolder::CMyDocsFolder() { + pidlRoot = NULL; } CMyDocsFolder::~CMyDocsFolder() Modified: branches/shell32_new-bringup/dll/win32/shell32/shlfolder.cpp URL:
http://svn.reactos.org/svn/reactos/branches/shell32_new-bringup/dll/win32/s…
============================================================================== --- branches/shell32_new-bringup/dll/win32/shell32/shlfolder.cpp [iso-8859-1] (original) +++ branches/shell32_new-bringup/dll/win32/shell32/shlfolder.cpp [iso-8859-1] Tue Sep 6 23:52:38 2011 @@ -23,7 +23,7 @@ #include <precomp.h> -WINE_DEFAULT_DEBUG_CHANNEL (shell); +WINE_DEFAULT_DEBUG_CHANNEL(shell); static const WCHAR wszDotShellClassInfo[] = { '.','S','h','e','l','l','C','l','a','s','s','I','n','f','o',0}; @@ -177,42 +177,45 @@ hr = SHCoCreateInstance(NULL, &clsid, NULL, IID_IShellFolder, ppvOut); if (SUCCEEDED (hr)) { - LPITEMIDLIST pidlAbsolute = ILCombine (pidlRoot, pidlChild); - IPersistFolder *pPF; - IPersistFolder3 *ppf; + LPITEMIDLIST pidlAbsolute = ILCombine (pidlRoot, pidlChild); + IPersistFolder *pPF; + IPersistFolder3 *ppf; if (_ILIsFolder(pidlChild) && SUCCEEDED (((IUnknown *)(*ppvOut))->QueryInterface(IID_IPersistFolder3, (LPVOID *) & ppf))) { - PERSIST_FOLDER_TARGET_INFO ppfti; - - ZeroMemory (&ppfti, sizeof (ppfti)); - - /* fill the PERSIST_FOLDER_TARGET_INFO */ - ppfti.dwAttributes = -1; - ppfti.csidl = -1; - - /* build path */ - if (pathRoot) { - lstrcpynW (ppfti.szTargetParsingName, pathRoot, MAX_PATH - 1); - PathAddBackslashW(ppfti.szTargetParsingName); /* FIXME: why have drives a backslash here ? */ + PERSIST_FOLDER_TARGET_INFO ppfti; + + ZeroMemory (&ppfti, sizeof (ppfti)); + + /* fill the PERSIST_FOLDER_TARGET_INFO */ + ppfti.dwAttributes = -1; + ppfti.csidl = -1; + + /* build path */ + if (pathRoot) + { + lstrcpynW (ppfti.szTargetParsingName, pathRoot, MAX_PATH - 1); + PathAddBackslashW(ppfti.szTargetParsingName); /* FIXME: why have drives a backslash here ? */ + } + + if (pidlChild) + { + int len = wcslen(ppfti.szTargetParsingName); + + if (!_ILSimpleGetTextW(pidlChild, ppfti.szTargetParsingName + len, MAX_PATH - len)) + hr = E_INVALIDARG; + } + + ppf->InitializeEx(NULL, pidlAbsolute, &ppfti); + ppf->Release(); } - - if (pidlChild) { - int len = wcslen(ppfti.szTargetParsingName); - - if (!_ILSimpleGetTextW(pidlChild, ppfti.szTargetParsingName + len, MAX_PATH - len)) - hr = E_INVALIDARG; + else if (SUCCEEDED ((hr = ((IUnknown *)(*ppvOut))->QueryInterface (IID_IPersistFolder, (LPVOID *) & pPF)))) + { + pPF->Initialize(pidlAbsolute); + pPF->Release(); } - - ppf->InitializeEx(NULL, pidlAbsolute, &ppfti); - ppf->Release(); - } - else if (SUCCEEDED ((hr = ((IUnknown *)(*ppvOut))->QueryInterface (IID_IPersistFolder, (LPVOID *) & pPF)))) { - pPF->Initialize(pidlAbsolute); - pPF->Release(); - } - ILFree (pidlAbsolute); + ILFree (pidlAbsolute); } TRACE ("-- (%p) ret=0x%08x\n", *ppvOut, hr); return hr; Modified: branches/shell32_new-bringup/lib/atl/atlbase.h URL:
http://svn.reactos.org/svn/reactos/branches/shell32_new-bringup/lib/atl/atl…
============================================================================== --- branches/shell32_new-bringup/lib/atl/atlbase.h [iso-8859-1] (original) +++ branches/shell32_new-bringup/lib/atl/atlbase.h [iso-8859-1] Tue Sep 6 23:52:38 2011 @@ -538,6 +538,7 @@ { ATLASSERT(_pModule == NULL); _pModule = this; + _pModule->m_pObjMap = NULL; } ~CComModule()
13 years, 3 months
1
0
0
0
[tkreuzer] 53611: [HAL] Start implementing APIC support, which is needed for both SMP and x64. It will use the local APIC + I/O APIC for interrupt control, the RTC instead of the PIT for the timer ...
by tkreuzer@svn.reactos.org
Author: tkreuzer Date: Tue Sep 6 21:01:49 2011 New Revision: 53611 URL:
http://svn.reactos.org/svn/reactos?rev=53611&view=rev
Log: [HAL] Start implementing APIC support, which is needed for both SMP and x64. It will use the local APIC + I/O APIC for interrupt control, the RTC instead of the PIT for the timer interrupt (PIT doesn't always work with I/O APIC), the APIC timer for profiling and finally the TSC for the performance counter and KeStallExecutionProcessor. The code is incomplete and doesn't work yet Added: trunk/reactos/hal/halx86/apic/ (with props) trunk/reactos/hal/halx86/apic/apic.c (with props) trunk/reactos/hal/halx86/apic/apic.h (with props) trunk/reactos/hal/halx86/apic/apictimer.c (with props) trunk/reactos/hal/halx86/apic/apictrap.S (with props) trunk/reactos/hal/halx86/apic/rtctimer.c (with props) trunk/reactos/hal/halx86/apic/tsc.c (with props) trunk/reactos/hal/halx86/apic/tsc.h (with props) trunk/reactos/hal/halx86/apic/tsccal.S (with props) Propchange: trunk/reactos/hal/halx86/apic/ ------------------------------------------------------------------------------ --- bugtraq:logregex (added) +++ bugtraq:logregex Tue Sep 6 21:01:49 2011 @@ -1,0 +1,2 @@ +([Ii]ssue|[Bb]ug)s? #?(\d+)(,? ?#?(\d+))*(,? ?(and |or )?#?(\d+))? +(\d+) Propchange: trunk/reactos/hal/halx86/apic/ ------------------------------------------------------------------------------ bugtraq:message = See issue #%BUGID% for more details. Propchange: trunk/reactos/hal/halx86/apic/ ------------------------------------------------------------------------------ bugtraq:url =
http://www.reactos.org/bugzilla/show_bug.cgi?id=%BUGID%
Propchange: trunk/reactos/hal/halx86/apic/ ------------------------------------------------------------------------------ tsvn:logminsize = 10 Added: trunk/reactos/hal/halx86/apic/apic.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/hal/halx86/apic/apic.c?rev…
============================================================================== --- trunk/reactos/hal/halx86/apic/apic.c (added) +++ trunk/reactos/hal/halx86/apic/apic.c [iso-8859-1] Tue Sep 6 21:01:49 2011 @@ -1,0 +1,693 @@ +/* + * PROJECT: ReactOS HAL + * LICENSE: GNU GPL - See COPYING in the top level directory + * FILE: hal/halx86/generic/apic.c + * PURPOSE: HAL APIC Management and Control Code + * PROGRAMMERS: Timo Kreuzer (timo.kreuzer(a)reactos.org) + * REFERENCES:
http://www.joseflores.com/docs/ExploringIrql.html
+ *
http://www.codeproject.com/KB/system/soviet_kernel_hack.aspx
+ *
http://bbs.unixmap.net/thread-2022-1-1.html
+ */ + +/* INCLUDES *******************************************************************/ + +#include <hal.h> +#define NDEBUG +#include <debug.h> + +#include "apic.h" + +/* GLOBALS ********************************************************************/ + +UCHAR HalpVectorToIndex[256]; + +#ifndef _M_AMD64 +static const UCHAR +HalpIRQLtoTPR[32] = +{ + 0x00, /* 0 PASSIVE_LEVEL */ + 0x3d, /* 1 APC_LEVEL */ + 0x41, /* 2 DISPATCH_LEVEL */ + 0x41, /* 3 \ */ + 0x51, /* 4 \ */ + 0x61, /* 5 | */ + 0x71, /* 6 | */ + 0x81, /* 7 | */ + 0x91, /* 8 | */ + 0xa1, /* 9 | */ + 0xb1, /* 10 | */ + 0xb1, /* 11 | */ + 0xb1, /* 12 | */ + 0xb1, /* 13 | */ + 0xb1, /* 14 | */ + 0xb1, /* 15 DEVICE IRQL */ + 0xb1, /* 16 | */ + 0xb1, /* 17 | */ + 0xb1, /* 18 | */ + 0xb1, /* 19 | */ + 0xb1, /* 20 | */ + 0xb1, /* 21 | */ + 0xb1, /* 22 | */ + 0xb1, /* 23 | */ + 0xb1, /* 24 | */ + 0xb1, /* 25 / */ + 0xb1, /* 26 / */ + 0xc1, /* 27 PROFILE_LEVEL */ + 0xd1, /* 28 CLOCK2_LEVEL */ + 0xe1, /* 29 IPI_LEVEL */ + 0xef, /* 30 POWER_LEVEL */ + 0xff, /* 31 HIGH_LEVEL */ +}; + +static const KIRQL +HalVectorToIRQL[16] = +{ + 0, /* 00 PASSIVE_LEVEL */ + 0xff, /* 10 */ + 0xff, /* 20 */ + 1, /* 3D APC_LEVEL */ + 2, /* 41 DISPATCH_LEVEL */ + 4, /* 50 \ */ + 5, /* 60 \ */ + 6, /* 70 | */ + 7, /* 80 DEVICE IRQL */ + 8, /* 90 | */ + 9, /* A0 / */ + 10, /* B0 / */ + 27, /* C1 PROFILE_LEVEL */ + 28, /* D1 CLOCK2_LEVEL */ + 29, /* E1 IPI_LEVEL / EF POWER_LEVEL */ + 31, /* FF HIGH_LEVEL */ +}; +#endif + +/* PRIVATE FUNCTIONS **********************************************************/ + +ULONG +FORCEINLINE +IOApicRead(UCHAR Register) +{ + /* Select the register, then do the read */ + *(volatile ULONG *)(IOAPIC_BASE + IOAPIC_IOREGSEL) = Register; + return *(volatile ULONG *)(IOAPIC_BASE + IOAPIC_IOWIN); +} + +VOID +FORCEINLINE +IOApicWrite(UCHAR Register, ULONG Value) +{ + /* Select the register, then do the write */ + *(volatile ULONG *)(IOAPIC_BASE + IOAPIC_IOREGSEL) = Register; + *(volatile ULONG *)(IOAPIC_BASE + IOAPIC_IOWIN) = Value; +} + +KIRQL +FORCEINLINE +ApicGetProcessorIrql(VOID) +{ + /* Read the TPR and convert it to an IRQL */ + return TprToIrql(ApicRead(APIC_PPR)); +} + +KIRQL +FORCEINLINE +ApicGetCurrentIrql(VOID) +{ + /* Read the TPR and convert it to an IRQL */ + return TprToIrql(ApicRead(APIC_TPR)); +} + +VOID +FORCEINLINE +ApicSetCurrentIrql(KIRQL Irql) +{ + /* Convert IRQL and write the TPR */ + ApicWrite(APIC_TPR, IrqlToTpr(Irql)); +} + +UCHAR +FASTCALL +HalpIrqToVector(UCHAR Irq) +{ + IOAPIC_REDIRECTION_REGISTER ReDirReg; + + /* Read low dword of the redirection entry */ + ReDirReg.Long0 = IOApicRead(IOAPIC_REDTBL + 2 * Irq); + + /* Return the vector */ + return (UCHAR)ReDirReg.Vector; +} + +KIRQL +FASTCALL +HalpVectorToIrql(UCHAR Vector) +{ + return TprToIrql(Vector >> 2); +} + +UCHAR +FASTCALL +HalpVectorToIrq(UCHAR Vector) +{ + return HalpVectorToIndex[Vector]; +} + +VOID +NTAPI +HalpInitializeLegacyPIC(VOID) +{ + I8259_ICW1 Icw1; + I8259_ICW2 Icw2; + I8259_ICW3 Icw3; + I8259_ICW4 Icw4; + + /* Initialize ICW1 for master, interval 8, edge-triggered mode with ICW4 */ + Icw1.NeedIcw4 = TRUE; + Icw1.OperatingMode = Cascade; + Icw1.Interval = Interval8; + Icw1.InterruptMode = EdgeTriggered; + Icw1.Init = TRUE; + Icw1.InterruptVectorAddress = 0; + __outbyte(PIC1_CONTROL_PORT, Icw1.Bits); + + /* ICW2 - interrupt vector offset */ + Icw2.Bits = PRIMARY_VECTOR_BASE; + __outbyte(PIC1_DATA_PORT, Icw2.Bits); + + /* Connect slave to IRQ 2 */ + Icw3.Bits = 0; + Icw3.SlaveIrq2 = TRUE; + __outbyte(PIC1_DATA_PORT, Icw3.Bits); + + /* Enable 8086 mode, non-automatic EOI, non-buffered mode, non special fully nested mode */ + Icw4.SystemMode = New8086Mode; + Icw4.EoiMode = NormalEoi; + Icw4.BufferedMode = NonBuffered; + Icw4.SpecialFullyNestedMode = FALSE; + Icw4.Reserved = 0; + __outbyte(PIC1_DATA_PORT, Icw4.Bits); + + /* Mask all interrupts */ + __outbyte(PIC1_DATA_PORT, 0xFF); + + /* Initialize ICW1 for slave, interval 8, edge-triggered mode with ICW4 */ + Icw1.NeedIcw4 = TRUE; + Icw1.InterruptMode = EdgeTriggered; + Icw1.OperatingMode = Cascade; + Icw1.Interval = Interval8; + Icw1.Init = TRUE; + Icw1.InterruptVectorAddress = 0; /* This is only used in MCS80/85 mode */ + __outbyte(PIC2_CONTROL_PORT, Icw1.Bits); + + /* Set interrupt vector base */ + Icw2.Bits = PRIMARY_VECTOR_BASE + 8; + __outbyte(PIC2_DATA_PORT, Icw2.Bits); + + /* Slave ID */ + Icw3.Bits = 0; + Icw3.SlaveId = 2; + __outbyte(PIC2_DATA_PORT, Icw3.Bits); + + /* Enable 8086 mode, non-automatic EOI, non-buffered mode, non special fully nested mode */ + Icw4.SystemMode = New8086Mode; + Icw4.EoiMode = NormalEoi; + Icw4.BufferedMode = NonBuffered; + Icw4.SpecialFullyNestedMode = FALSE; + Icw4.Reserved = 0; + __outbyte(PIC2_DATA_PORT, Icw4.Bits); + + /* Mask all interrupts */ + __outbyte(PIC2_DATA_PORT, 0xFF); +} + + +VOID +ApicInitializeLocalApic(ULONG Cpu) +{ + APIC_BASE_ADRESS_REGISTER BaseRegister; + APIC_SPURIOUS_INERRUPT_REGISTER SpIntRegister; + LVT_REGISTER LvtEntry; + + /* Enable the APIC if it wasn't yet */ + BaseRegister.Long = __readmsr(MSR_APIC_BASE); + BaseRegister.Enable = 1; + BaseRegister.BootStrapCPUCore = (Cpu == 0); + __writemsr(MSR_APIC_BASE, BaseRegister.Long); + + DPRINT1("ApicBase for Cpu %u PhysicalAddress = %p\n", Cpu, BaseRegister.BaseAddress); + DPRINT1("ApicVersion = 0x%lx\n", ApicRead(0x30)); + + /* Set spurious vector and SoftwareEnable to 1 */ + SpIntRegister.Long = ApicRead(APIC_SIVR); + SpIntRegister.Vector = APIC_SPURIOUS_VECTOR; + SpIntRegister.SoftwareEnable = 1; + SpIntRegister.FocusCPUCoreChecking = 0; + ApicWrite(APIC_SIVR, SpIntRegister.Long); + + /* Set the spurious ISR */ + KeRegisterInterruptHandler(APIC_SPURIOUS_VECTOR, ApicSpuriousService); + + /* Create a template LVT */ + LvtEntry.Long = 0; + LvtEntry.Vector = 0xFF; + LvtEntry.MessageType = APIC_MT_Fixed; + LvtEntry.DeliveryStatus = 0; + LvtEntry.RemoteIRR = 0; + LvtEntry.TriggerMode = APIC_TGM_Edge; + LvtEntry.Mask = 1; + LvtEntry.TimerMode = 0; + + /* Initalize and mask LVTs */ + ApicWrite(APIC_TMRLVTR, LvtEntry.Long); + ApicWrite(APIC_THRMLVTR, LvtEntry.Long); + ApicWrite(APIC_PCLVTR, LvtEntry.Long); + ApicWrite(APIC_EXT0LVTR, LvtEntry.Long); + ApicWrite(APIC_EXT1LVTR, LvtEntry.Long); + ApicWrite(APIC_EXT2LVTR, LvtEntry.Long); + ApicWrite(APIC_EXT3LVTR, LvtEntry.Long); + + /* LINT0 */ + LvtEntry.Vector = APIC_SPURIOUS_VECTOR; + LvtEntry.MessageType = APIC_MT_ExtInt; + ApicWrite(APIC_LINT0, LvtEntry.Long); + + /* Enable LINT1 (NMI) */ + LvtEntry.Mask = 0; + LvtEntry.Vector = APIC_NMI_VECTOR; + LvtEntry.MessageType = APIC_MT_NMI; + LvtEntry.TriggerMode = APIC_TGM_Level; + ApicWrite(APIC_LINT1, LvtEntry.Long); + + /* Enable error LVTR */ + LvtEntry.Vector = APIC_ERROR_VECTOR; + LvtEntry.MessageType = APIC_MT_Fixed; + ApicWrite(APIC_ERRLVTR, LvtEntry.Long); + + DPRINT1("Error code = 0x%lx\n", ApicRead(0x280)); +} + +VOID +NTAPI +ApicInitializeProcessor( + IN ULONG ProcessorNumber, + IN PLOADER_PARAMETER_BLOCK LoaderBlock) +{ + DPRINT1("ApicInitializeProcessor(%ld)\n", ProcessorNumber); + + /* Initialize the local APIC for this cpu */ + ApicInitializeLocalApic(ProcessorNumber); + + /* Initialize the timer */ + ApicInitializeTimer(ProcessorNumber); + +} + +VOID +FORCEINLINE +ApicWriteIORedirectionEntry( + UCHAR Index, + IOAPIC_REDIRECTION_REGISTER ReDirReg) +{ + IOApicWrite(IOAPIC_REDTBL + 2 * Index, ReDirReg.Long0); + IOApicWrite(IOAPIC_REDTBL + 2 * Index + 1, ReDirReg.Long1); +} + +IOAPIC_REDIRECTION_REGISTER +FORCEINLINE +ApicReadIORedirectionEntry( + UCHAR Index) +{ + IOAPIC_REDIRECTION_REGISTER ReDirReg; + + ReDirReg.Long0 = IOApicRead(IOAPIC_REDTBL + 2 * Index); + ReDirReg.Long1 = IOApicRead(IOAPIC_REDTBL + 2 * Index + 1); + + return ReDirReg; +} + +UCHAR +NTAPI +HalpAllocateSystemInterrupt( + IN UCHAR Irq, + IN KIRQL Irql) +{ + IOAPIC_REDIRECTION_REGISTER ReDirReg; + IN UCHAR Vector; + + /* Start with low vector */ + Vector = IrqlToTpr(Irql); + + /* Find an empty vector */ + while (HalpVectorToIndex[Vector] != 0xFF) + { + Vector++; + + /* Check if we went over the edge */ + if (TprToIrql(Vector) > Irql) + { + /* Nothing free, return failure */ + return 0; + } + } + + /* Save irq in the table */ + HalpVectorToIndex[Vector] = Irq; + + /* Setup a redirection entry */ + ReDirReg.Vector = Vector; + ReDirReg.DeliveryMode = APIC_MT_LowestPriority; + ReDirReg.DestinationMode = APIC_DM_Logical; + ReDirReg.DeliveryStatus = 0; + ReDirReg.Polarity = 0; + ReDirReg.RemoteIRR = 0; + ReDirReg.TriggerMode = APIC_TGM_Edge; + ReDirReg.Mask = 1; + ReDirReg.Reserved = 0; + ReDirReg.Destination = 0; + + /* Initialize entry */ + IOApicWrite(IOAPIC_REDTBL + 2 * Irq, ReDirReg.Long0); + IOApicWrite(IOAPIC_REDTBL + 2 * Irq + 1, ReDirReg.Long1); + + return Vector; +} + +VOID +NTAPI +ApicInitializeIOApic(VOID) +{ + PHARDWARE_PTE Pte; + IOAPIC_REDIRECTION_REGISTER ReDirReg; + UCHAR Index; + ULONG Vector; + + /* Map the I/O Apic page */ + Pte = HalAddressToPte(IOAPIC_BASE); + Pte->PageFrameNumber = IOAPIC_PHYS_BASE / PAGE_SIZE; + Pte->Valid = 1; + Pte->Write = 1; + Pte->Owner = 1; + Pte->CacheDisable = 1; + Pte->Global = 1; + _ReadWriteBarrier(); + + /* Setup a redirection entry */ + ReDirReg.Vector = 0xFF; + ReDirReg.DeliveryMode = APIC_MT_Fixed; + ReDirReg.DestinationMode = APIC_DM_Physical; + ReDirReg.DeliveryStatus = 0; + ReDirReg.Polarity = 0; + ReDirReg.RemoteIRR = 0; + ReDirReg.TriggerMode = APIC_TGM_Edge; + ReDirReg.Mask = 1; + ReDirReg.Reserved = 0; + ReDirReg.Destination = 0; + + /* Loop all table entries */ + for (Index = 0; Index < 24; Index++) + { + /* Initialize entry */ + IOApicWrite(IOAPIC_REDTBL + 2 * Index, ReDirReg.Long0); + IOApicWrite(IOAPIC_REDTBL + 2 * Index + 1, ReDirReg.Long1); + } + + /* Init the vactor to index table */ + for (Vector = 0; Vector <= 255; Vector++) + { + HalpVectorToIndex[Vector] = 0xFF; + } + + // HACK: Allocate all IRQs, should rather do that on demand + for (Index = 0; Index <= 15; Index++) + { + /* Map the IRQs to IRQLs like with the PIC */ + HalpAllocateSystemInterrupt(Index, 27 - Index); + } + + /* Enable the timer interrupt */ + ReDirReg.Vector = APIC_CLOCK_VECTOR; + ReDirReg.DestinationMode = APIC_DM_Logical; + ReDirReg.TriggerMode = APIC_TGM_Edge; + ReDirReg.Mask = 0; + IOApicWrite(IOAPIC_REDTBL + 2 * APIC_CLOCK_INDEX, ReDirReg.Long0); + +} + +VOID +NTAPI +HalpInitializePICs(IN BOOLEAN EnableInterrupts) +{ + ULONG_PTR EFlags; + + /* Save EFlags and disable interrupts */ + EFlags = __readeflags(); + _disable(); + + /* Initialize the local APIC for this cpu */ + ApicInitializeLocalApic(0); + + /* Initialize and mask the PIC */ + HalpInitializeLegacyPIC(); + + /* Initialize the I/O APIC */ + ApicInitializeIOApic(); + ApicWrite(APIC_EOI, 0); + + /* Register interrupt handlers */ + KeRegisterInterruptHandler(APIC_CLOCK_VECTOR, HalpClockInterrupt); + KeRegisterInterruptHandler(APC_VECTOR, HalpApcInterrupt); + KeRegisterInterruptHandler(DPC_VECTOR, HalpDispatchInterrupt); + + // HACK, since we messed with the value, should init the local apic in + // HalInitializeProcessor instead + ApicSetCurrentIrql(APC_LEVEL); + ASSERT(ApicGetProcessorIrql() <= APC_LEVEL); + +__debugbreak(); + +HalpInitializeClock(); +//HalpCalibrateStallExecution(); +_enable(); +for (;;); + + + /* Restore interrupt state */ + if (EnableInterrupts) EFlags |= EFLAGS_INTERRUPT_MASK; + __writeeflags(EFlags); +} + +VOID +DECLSPEC_NORETURN +FASTCALL +HalpApcInterruptHandler(IN PKTRAP_FRAME TrapFrame) +{ + ASSERT(ApicGetCurrentIrql() < APC_LEVEL); + ASSERT(ApicGetProcessorIrql() == APC_LEVEL); + + UNIMPLEMENTED; + ASSERT(FALSE); +} + +VOID +DECLSPEC_NORETURN +FASTCALL +HalpDispatchInterruptHandler(IN PKTRAP_FRAME TrapFrame) +{ + KIRQL OldIrql = ApicGetCurrentIrql(); +__debugbreak(); + ASSERT(OldIrql < DISPATCH_LEVEL); + ASSERT(ApicGetProcessorIrql() == DISPATCH_LEVEL); + + ApicSetCurrentIrql(DISPATCH_LEVEL); + + /* Enable interrupts and call the kernel's DPC interrupt handler */ + _enable(); + KiDispatchInterrupt(); + _disable(); + + ApicSetCurrentIrql(OldIrql); + + ApicWrite(APIC_EOI, 0); + + /* Exit the interrupt */ + KiEoiHelper(TrapFrame); +} + + +/* PUBLIC FUNCTIONS ***********************************************************/ + +VOID +FASTCALL +HalRequestSoftwareInterrupt(IN KIRQL Irql) +{ + APIC_COMMAND_REGISTER CommandRegister; + + /* Setup the command register */ + CommandRegister.Long0 = 0; + CommandRegister.Vector = IrqlToTpr(Irql); + CommandRegister.MessageType = APIC_MT_Fixed; + CommandRegister.TriggerMode = APIC_TGM_Edge; + CommandRegister.DestinationShortHand = APIC_DSH_Self; + + /* Write the low dword to send the interrupt */ + ApicWrite(APIC_ICR0, CommandRegister.Long0); +} + +VOID +FASTCALL +HalClearSoftwareInterrupt( + IN KIRQL Irql) +{ + /* Nothing to do */ +} + +BOOLEAN +NTAPI +HalEnableSystemInterrupt( + IN UCHAR Vector, + IN KIRQL Irql, + IN KINTERRUPT_MODE InterruptMode) +{ + IOAPIC_REDIRECTION_REGISTER ReDirReg; + UCHAR Index; + ASSERT(Irql <= HIGH_LEVEL); + ASSERT((IrqlToTpr(Irql) & 0xF0) == (Vector & 0xF0)); + + Index = HalpVectorToIndex[Vector]; + + /* Read lower dword of redirection entry */ + ReDirReg.Long0 = IOApicRead(IOAPIC_REDTBL + 2 * Index); + + ReDirReg.Vector = Vector; + ReDirReg.DeliveryMode = APIC_MT_LowestPriority; + ReDirReg.DestinationMode = APIC_DM_Logical; + ReDirReg.TriggerMode = 1 - InterruptMode; + ReDirReg.Mask = FALSE; + + /* Write back lower dword */ + IOApicWrite(IOAPIC_REDTBL + 2 * Irql, ReDirReg.Long0); + + return TRUE; +} + +VOID +NTAPI +HalDisableSystemInterrupt( + IN UCHAR Vector, + IN KIRQL Irql) +{ + IOAPIC_REDIRECTION_REGISTER ReDirReg; + UCHAR Index; + ASSERT(Irql <= HIGH_LEVEL); + + Index = HalpVectorToIndex[Vector]; + + /* Read lower dword of redirection entry */ + ReDirReg.Long0 = IOApicRead(IOAPIC_REDTBL + 2 * Index); + + /* Mask it */ + ReDirReg.Mask = 1; + + /* Write back lower dword */ + IOApicWrite(IOAPIC_REDTBL + 2 * Irql, ReDirReg.Long0); +} + +BOOLEAN +NTAPI +HalBeginSystemInterrupt( + IN KIRQL Irql, + IN UCHAR Vector, + OUT PKIRQL OldIrql) +{ + /* Get the current IRQL */ + *OldIrql = ApicGetCurrentIrql(); + + /* Set the new IRQL */ + ApicSetCurrentIrql(Irql); + + /* Turn on interrupts */ + _enable(); + + /* Success */ + return TRUE; +} + +VOID +NTAPI +HalEndSystemInterrupt( + IN KIRQL OldIrql, + IN PKTRAP_FRAME TrapFrame) +{ + /* Restore the old IRQL */ + ApicSetCurrentIrql(OldIrql); + + /* Write 0 to the EndOfInterruptRegister for level triggered ints */ + ApicWrite(APIC_EOI, 0); +} + +#ifndef _M_AMD64 + +KIRQL +NTAPI +KeGetCurrentIrql(VOID) +{ + /* Read the current TPR and convert it to an IRQL */ + return ApicGetCurrentIrql(); +} + +VOID +FASTCALL +KfLowerIrql( + IN KIRQL OldIrql) +{ +#if DBG + /* Validate correct lower */ + if (OldIrql > ApicGetCurrentIrql()) + { + /* Crash system */ + KeBugCheck(IRQL_NOT_LESS_OR_EQUAL); + } +#endif + /* Convert the new IRQL to a TPR value and write the register */ + ApicSetCurrentIrql(OldIrql); +} + +KIRQL +FASTCALL +KfRaiseIrql( + IN KIRQL NewIrql) +{ + KIRQL OldIrql; + + /* Read the current TPR and convert it to an IRQL */ + OldIrql = ApicGetCurrentIrql(); +#if DBG + /* Validate correct raise */ + if (OldIrql > NewIrql) + { + /* Crash system */ + KeBugCheck(IRQL_NOT_GREATER_OR_EQUAL); + } +#endif + /* Convert the new IRQL to a TPR value and write the register */ + ApicSetCurrentIrql(NewIrql); + + return OldIrql; +} + +KIRQL +NTAPI +KeRaiseIrqlToDpcLevel(VOID) +{ + return KfRaiseIrql(DISPATCH_LEVEL); +} + +KIRQL +NTAPI +KeRaiseIrqlToSynchLevel(VOID) +{ + return KfRaiseIrql(SYNCH_LEVEL); +} + +#endif /* !_M_AMD64 */ + Propchange: trunk/reactos/hal/halx86/apic/apic.c ------------------------------------------------------------------------------ svn:eol-style = native Added: trunk/reactos/hal/halx86/apic/apic.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/hal/halx86/apic/apic.h?rev…
============================================================================== --- trunk/reactos/hal/halx86/apic/apic.h (added) +++ trunk/reactos/hal/halx86/apic/apic.h [iso-8859-1] Tue Sep 6 21:01:49 2011 @@ -1,0 +1,271 @@ + +#ifdef _M_AMD64 +#define APIC_BASE 0xfffffffffee00000ULL; +#define ZERO_VECTOR 0x00 // IRQL 00 +#define APC_VECTOR 0x3D // IRQL 01 +#define APIC_SPURIOUS_VECTOR 0x3f +#define DPC_VECTOR 0x41 // IRQL 02 +#define APIC_GENERIC_VECTOR 0xC1 // IRQL 27 +#define APIC_CLOCK_VECTOR 0xD1 // IRQL 28 +#define APIC_SYNCH_VECTOR 0xD1 // IRQL 28 +#define APIC_IPI_VECTOR 0xE1 // IRQL 29 +#define APIC_ERROR_VECTOR 0xE3 +#define POWERFAIL_VECTOR 0xEF // IRQL 30 +#define APIC_PROFILE_VECTOR 0xFD // IRQL 31 +#define APIC_NMI_VECTOR 0xFF +#define IrqlToTpr(Irql) (Irql << 4) +#define TprToIrql(Tpr) (Tpr >> 4) +#else +#define APIC_BASE 0xFFFE0000 +#define IOAPIC_BASE 0xFFFE1000 // checkme +#define IOAPIC_PHYS_BASE 0xFEC00000 +#define ZERO_VECTOR 0x00 // IRQL 00 +#define APIC_SPURIOUS_VECTOR 0x1f +#define APC_VECTOR 0x3D // IRQL 01 +#define DPC_VECTOR 0x41 // IRQL 02 +#define APIC_GENERIC_VECTOR 0xC1 // IRQL 27 +#define APIC_CLOCK_VECTOR 0xD1 // IRQL 28 +#define APIC_SYNCH_VECTOR 0xD1 // IRQL 28 +#define APIC_IPI_VECTOR 0xE1 // IRQL 29 +#define APIC_ERROR_VECTOR 0xE3 +#define POWERFAIL_VECTOR 0xEF // IRQL 30 +#define APIC_PROFILE_VECTOR 0xFD // IRQL 31 +#define APIC_NMI_VECTOR 0xFF +#define IrqlToTpr(Irql) (HalpIRQLtoTPR[Irql]) +#define TprToIrql(Tpr) (HalVectorToIRQL[Tpr >> 4]) +#endif + +#define MSR_APIC_BASE 0x0000001B +#define APIC_CLOCK_INDEX 8 + + +/* APIC Register Address Map */ +#define APIC_ID 0x0020 /* Local APIC ID Register (R/W) */ +#define APIC_VER 0x0030 /* Local APIC Version Register (R) */ +#define APIC_TPR 0x0080 /* Task Priority Register (R/W) */ +#define APIC_APR 0x0090 /* Arbitration Priority Register (R) */ +#define APIC_PPR 0x00A0 /* Processor Priority Register (R) */ +#define APIC_EOI 0x00B0 /* EOI Register (W) */ +#define APIC_RRR 0x00C0 /* Remote Read Register () */ +#define APIC_LDR 0x00D0 /* Logical Destination Register (R/W) */ +#define APIC_DFR 0x00E0 /* Destination Format Register (0-27 R, 28-31 R/W) */ +#define APIC_SIVR 0x00F0 /* Spurious Interrupt Vector Register (0-3 R, 4-9 R/W) */ +#define APIC_ISR 0x0100 /* Interrupt Service Register 0-255 (R) */ +#define APIC_TMR 0x0180 /* Trigger Mode Register 0-255 (R) */ +#define APIC_IRR 0x0200 /* Interrupt Request Register 0-255 (r) */ +#define APIC_ESR 0x0280 /* Error Status Register (R) */ +#define APIC_ICR0 0x0300 /* Interrupt Command Register 0-31 (R/W) */ +#define APIC_ICR1 0x0310 /* Interrupt Command Register 32-63 (R/W) */ +#define APIC_TMRLVTR 0x0320 /* Timer Local Vector Table (R/W) */ +#define APIC_THRMLVTR 0x0330 /* Thermal Local Vector Table */ +#define APIC_PCLVTR 0x0340 /* Performance Counter Local Vector Table (R/W) */ +#define APIC_LINT0 0x0350 /* LINT0 Local Vector Table (R/W) */ +#define APIC_LINT1 0x0360 /* LINT1 Local Vector Table (R/W) */ +#define APIC_ERRLVTR 0x0370 /* Error Local Vector Table (R/W) */ +#define APIC_TICR 0x0380 /* Initial Count Register for Timer (R/W) */ +#define APIC_TCCR 0x0390 /* Current Count Register for Timer (R) */ +#define APIC_TDCR 0x03E0 /* Timer Divide Configuration Register (R/W) */ +#define APIC_EAFR 0x0400 /* extended APIC Feature register (R/W) */ +#define APIC_EACR 0x0410 /* Extended APIC Control Register (R/W) */ +#define APIC_SEOI 0x0420 /* Specific End Of Interrupt Register (W) */ +#define APIC_EXT0LVTR 0x0500 /* Extended Interrupt 0 Local Vector Table */ +#define APIC_EXT1LVTR 0x0510 /* Extended Interrupt 1 Local Vector Table */ +#define APIC_EXT2LVTR 0x0520 /* Extended Interrupt 2 Local Vector Table */ +#define APIC_EXT3LVTR 0x0530 /* Extended Interrupt 3 Local Vector Table */ + +enum +{ + APIC_MT_Fixed = 0, + APIC_MT_LowestPriority = 1, + APIC_MT_SMI = 2, + APIC_MT_RemoteRead = 3, + APIC_MT_NMI = 4, + APIC_MT_INIT = 5, + APIC_MT_Startup = 6, + APIC_MT_ExtInt = 7, +}; + +enum +{ + APIC_TGM_Edge, + APIC_TGM_Level +}; + +enum +{ + APIC_DM_Physical, + APIC_DM_Logical +}; + +enum +{ + APIC_DSH_Destination, + APIC_DSH_Self, + APIC_DSH_AllIncludingSelf, + APIC_DSH_AllExclusingSelf +}; + +enum +{ + TIMER_DV_DivideBy2 = 0, + TIMER_DV_DivideBy4 = 1, + TIMER_DV_DivideBy8 = 2, + TIMER_DV_DivideBy16 = 3, + TIMER_DV_DivideBy32 = 8, + TIMER_DV_DivideBy64 = 9, + TIMER_DV_DivideBy128 = 10, + TIMER_DV_DivideBy1 = 11, +}; + + +typedef union _APIC_BASE_ADRESS_REGISTER +{ + ULONG64 Long; + struct + { + ULONG64 Reserved1:8; + ULONG64 BootStrapCPUCore:1; + ULONG64 Reserved2:2; + ULONG64 Enable:1; + ULONG64 BaseAddress:40; + ULONG64 ReservedMBZ:12; + }; +} APIC_BASE_ADRESS_REGISTER; + +typedef union _APIC_SPURIOUS_INERRUPT_REGISTER +{ + ULONG Long; + struct + { + ULONG Vector:8; + ULONG SoftwareEnable:1; + ULONG FocusCPUCoreChecking:1; + ULONG ReservedMBZ:22; + }; +} APIC_SPURIOUS_INERRUPT_REGISTER; + +typedef union +{ + ULONG Long; + struct + { + ULONG Version:8; + ULONG ReservedMBZ:8; + ULONG MaxLVT:8; + ULONG ReservedMBZ1:7; + ULONG ExtRegSpacePresent:1; + }; +} APIC_VERSION_REGISTER; + +typedef union +{ + ULONG Long; + struct + { + ULONG Version:1; + ULONG SEOIEnable:1; + ULONG ExtApicIdEnable:1; + ULONG ReservedMBZ:29; + }; +} APIC_EXTENDED_CONTROL_REGISTER; + +typedef union _APIC_COMMAND_REGISTER +{ + ULONGLONG LongLong; + struct + { + ULONG Long0; + ULONG Long1; + }; + struct + { + ULONGLONG Vector:8; + ULONGLONG MessageType:3; + ULONGLONG DestinationMode:1; + ULONGLONG DeliveryStatus:1; + ULONGLONG ReservedMBZ:1; + ULONGLONG Level:1; + ULONGLONG TriggerMode:1; + ULONGLONG RemoteReadStatus:2; + ULONGLONG DestinationShortHand:2; + ULONGLONG Reserved2MBZ:36; + ULONGLONG Destination:8; + }; +} APIC_COMMAND_REGISTER; + +typedef union +{ + ULONG Long; + struct + { + ULONG Vector:8; + ULONG MessageType:3; + ULONG ReservedMBZ:1; + ULONG DeliveryStatus:1; + ULONG Reserved1MBZ:1; + ULONG RemoteIRR:1; + ULONG TriggerMode:1; + ULONG Mask:1; + ULONG TimerMode:1; + ULONG Reserved2MBZ:13; + }; +} LVT_REGISTER; + + +enum +{ + IOAPIC_IOREGSEL = 0x00, + IOAPIC_IOWIN = 0x10 +}; + +enum +{ + IOAPIC_ID = 0x00, + IOAPIC_VER = 0x01, + IOAPIC_ARB = 0x02, + IOAPIC_REDTBL = 0x28 +}; + +typedef union _IOAPIC_REDIRECTION_REGISTER +{ + ULONGLONG LongLong; + struct + { + ULONG Long0; + ULONG Long1; + }; + struct + { + ULONGLONG Vector:8; + ULONGLONG DeliveryMode:3; + ULONGLONG DestinationMode:1; + ULONGLONG DeliveryStatus:1; + ULONGLONG Polarity:1; + ULONGLONG RemoteIRR:1; + ULONGLONG TriggerMode:1; + ULONGLONG Mask:1; + ULONGLONG Reserved:39; + ULONGLONG Destination:8; + }; +} IOAPIC_REDIRECTION_REGISTER; + +ULONG +FORCEINLINE +ApicRead(ULONG Offset) +{ + return *(volatile ULONG *)(APIC_BASE + Offset); +} + +VOID +FORCEINLINE +ApicWrite(ULONG Offset, ULONG Value) +{ + *(volatile ULONG *)(APIC_BASE + Offset) = Value; +} + +VOID +NTAPI +ApicInitializeTimer(ULONG Cpu); + +VOID ApicSpuriousService(VOID); + Propchange: trunk/reactos/hal/halx86/apic/apic.h ------------------------------------------------------------------------------ svn:eol-style = native Added: trunk/reactos/hal/halx86/apic/apictimer.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/hal/halx86/apic/apictimer.…
============================================================================== --- trunk/reactos/hal/halx86/apic/apictimer.c (added) +++ trunk/reactos/hal/halx86/apic/apictimer.c [iso-8859-1] Tue Sep 6 21:01:49 2011 @@ -1,0 +1,84 @@ +/* + * PROJECT: ReactOS HAL + * LICENSE: GPL - See COPYING in the top level directory + * FILE: hal/halx86/apic/apictimer.c + * PURPOSE: System Profiling + * PROGRAMMERS: Timo Kreuzer (timo.kreuzer(a)reactos.org) + */ + +/* INCLUDES ******************************************************************/ + +#include <hal.h> +#define NDEBUG +#include <debug.h> + +#include "apic.h" + +extern LARGE_INTEGER HalpCpuClockFrequency; + +/* TIMER FUNCTIONS ************************************************************/ + +VOID +NTAPI +ApicSetTimerInterval(ULONG MicroSeconds) +{ + LVT_REGISTER LvtEntry; + ULONGLONG TimerInterval; + + /* Calculate the Timer interval */ + TimerInterval = HalpCpuClockFrequency.QuadPart * MicroSeconds / 1000000; + + /* Set the count interval */ + ApicWrite(APIC_TICR, (ULONG)TimerInterval); + + /* Set to periodic */ + LvtEntry.Long = 0; + LvtEntry.TimerMode = 1; + LvtEntry.Vector = APIC_PROFILE_VECTOR; + LvtEntry.Mask = 0; + ApicWrite(APIC_TMRLVTR, LvtEntry.Long); + +} + +VOID +NTAPI +ApicInitializeTimer(ULONG Cpu) +{ + + /* Initialize the TSC */ + //HalpInitializeTsc(); + + /* Set clock multiplier to 1 */ + ApicWrite(APIC_TDCR, TIMER_DV_DivideBy1); + + ApicSetTimerInterval(1000); + +// KeSetTimeIncrement +} + + +/* PUBLIC FUNCTIONS ***********************************************************/ + +VOID +NTAPI +HalStartProfileInterrupt(IN KPROFILE_SOURCE ProfileSource) +{ + UNIMPLEMENTED; + return; +} + +VOID +NTAPI +HalStopProfileInterrupt(IN KPROFILE_SOURCE ProfileSource) +{ + UNIMPLEMENTED; + return; +} + +ULONG_PTR +NTAPI +HalSetProfileInterval(IN ULONG_PTR Interval) +{ + UNIMPLEMENTED; + return Interval; +} Propchange: trunk/reactos/hal/halx86/apic/apictimer.c ------------------------------------------------------------------------------ svn:eol-style = native Added: trunk/reactos/hal/halx86/apic/apictrap.S URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/hal/halx86/apic/apictrap.S…
============================================================================== --- trunk/reactos/hal/halx86/apic/apictrap.S (added) +++ trunk/reactos/hal/halx86/apic/apictrap.S [iso-8859-1] Tue Sep 6 21:01:49 2011 @@ -1,0 +1,36 @@ +/* + * FILE: hal/halx86/apic/apictrap.S + * COPYRIGHT: See COPYING in the top level directory + * PURPOSE: System Traps, Entrypoints and Exitpoints + * PROGRAMMER: Timo Kreuzer (timo.kreuzer(a)reactos.org) + * NOTE: See asmmacro.S for the shared entry/exit code. + */ + +/* INCLUDES ******************************************************************/ + +#include <asm.inc> +#include <internal/i386/asmmacro.S> + +#ifdef _M_AMD64 +#include <ksamd64.inc> +PUBLIC ApicSpuriousService +#else +#include <ks386.inc> +PUBLIC _ApicSpuriousService +#endif + +.code + +TRAP_ENTRY HalpTrap0D, 0 +TRAP_ENTRY HalpApcInterrupt, KI_SOFTWARE_TRAP +TRAP_ENTRY HalpDispatchInterrupt, KI_PUSH_FAKE_ERROR_CODE +TRAP_ENTRY HalpClockInterrupt, KI_PUSH_FAKE_ERROR_CODE +TRAP_ENTRY HalpProfileInterrupt, KI_PUSH_FAKE_ERROR_CODE + +FUNC ApicSpuriousService + int 3 + iret +ENDFUNC ApicSpuriousService + + +END Propchange: trunk/reactos/hal/halx86/apic/apictrap.S ------------------------------------------------------------------------------ svn:eol-style = native Added: trunk/reactos/hal/halx86/apic/rtctimer.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/hal/halx86/apic/rtctimer.c…
============================================================================== --- trunk/reactos/hal/halx86/apic/rtctimer.c (added) +++ trunk/reactos/hal/halx86/apic/rtctimer.c [iso-8859-1] Tue Sep 6 21:01:49 2011 @@ -1,0 +1,144 @@ +/* + * PROJECT: ReactOS HAL + * LICENSE: GNU GPL - See COPYING in the top level directory + * FILE: hal/halx86/generic/apic.c + * PURPOSE: HAL APIC Management and Control Code + * PROGRAMMERS: Timo Kreuzer (timo.kreuzer(a)reactos.org) + * REFERENCES: + */ + +/* INCLUDES *******************************************************************/ + +#include <hal.h> +#define NDEBUG +#include <debug.h> + + +/* GLOBALS ********************************************************************/ + +const UCHAR HalpClockVector = 0xD1; +BOOLEAN HalpClockSetMSRate; +UCHAR HalpNextMSRate; +UCHAR HalpCurrentRate = 9; +ULONG HalpCurrentTimeIncrement; +static UCHAR RtcLargestClockRate = 10; + + +ULONG +FORCEINLINE +RtcClockRateToIncrement(UCHAR Rate) +{ + ULONG Freqency = ((32768 << 1) >> Rate); + return (1000000 + (Freqency/2)) / Freqency; +} + +VOID +RtcSetClockRate(UCHAR ClockRate) +{ + ULONG_PTR EFlags; + UCHAR RegisterA; + + /* Disable interrupts */ + EFlags = __readeflags(); + _disable(); + + // TODO: disable NMI + + /* Read value of register A */ + RegisterA = HalpReadCmos(RTC_REGISTER_A); + + /* Change lower 4 bits to new rate */ + RegisterA &= 0xF0; + RegisterA |= ClockRate; + + /* Write the new value */ + HalpWriteCmos(RTC_REGISTER_A, RegisterA); + + /* Restore interrupts if they were previously enabled */ + __writeeflags(EFlags); +} + + +VOID +NTAPI +INIT_FUNCTION +HalpInitializeClock(VOID) +{ + UCHAR RegisterB; + // TODO: disable NMI + + /* Enable the periodic interrupt in the CMOS */ + RegisterB = HalpReadCmos(RTC_REGISTER_B); + HalpWriteCmos(RTC_REGISTER_B, RegisterB | RTC_REG_B_PI); + + // RtcSetClockRate(HalpCurrentRate); +} + +VOID +FASTCALL +HalpClockInterruptHandler(IN PKTRAP_FRAME TrapFrame) +{ + ULONG LastIncrement; + KIRQL Irql; + + /* Enter trap */ + KiEnterInterruptTrap(TrapFrame); +__debugbreak(); + /* Start the interrupt */ + if (HalBeginSystemInterrupt(CLOCK2_LEVEL, PRIMARY_VECTOR_BASE, &Irql)) + { + /* Read register C, so that the next interrupt can happen */ + HalpReadCmos(RTC_REGISTER_C);; + + /* Save increment */ + LastIncrement = HalpCurrentTimeIncrement; + + /* Check if someone changed the time rate */ + if (HalpClockSetMSRate) + { + /* Update the global values */ + HalpCurrentRate = HalpNextMSRate; + HalpCurrentTimeIncrement = RtcClockRateToIncrement(HalpCurrentRate); + + /* Set new clock rate */ + RtcSetClockRate(HalpCurrentRate); + + /* We're done */ + HalpClockSetMSRate = FALSE; + } + + /* Update the system time -- the kernel will exit this trap */ + KeUpdateSystemTime(TrapFrame, LastIncrement, Irql); + } + + /* Spurious, just end the interrupt */ + KiEoiHelper(TrapFrame); +} + +VOID +FASTCALL +HalpProfileInterruptHandler(IN PKTRAP_FRAME TrapFrame) +{ + __debugbreak(); +} + +ULONG +NTAPI +HalSetTimeIncrement(IN ULONG Increment) +{ + UCHAR Rate; + + /* Lookup largest value below given Increment */ + for (Rate = 2; Rate < RtcLargestClockRate; Rate++) + { + /* Check if this is the largest rate possible */ + if (RtcClockRateToIncrement(Rate + 1) > Increment) break; + } + + /* Set the rate and tell HAL we want to change it */ + HalpNextMSRate = Rate; + HalpClockSetMSRate = TRUE; + + /* Return the real increment */ + return RtcClockRateToIncrement(Rate); +} Propchange: trunk/reactos/hal/halx86/apic/rtctimer.c ------------------------------------------------------------------------------ svn:eol-style = native Added: trunk/reactos/hal/halx86/apic/tsc.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/hal/halx86/apic/tsc.c?rev=…
============================================================================== --- trunk/reactos/hal/halx86/apic/tsc.c (added) +++ trunk/reactos/hal/halx86/apic/tsc.c [iso-8859-1] Tue Sep 6 21:01:49 2011 @@ -1,0 +1,140 @@ +/* + * PROJECT: ReactOS HAL + * LICENSE: GPL - See COPYING in the top level directory + * FILE: hal/halamd64/generic/tsc.c + * PURPOSE: HAL Routines for TSC handling + * PROGRAMMERS: Timo Kreuzer (timo.kreuzer(a)reactos.org) + */ + +/* INCLUDES ******************************************************************/ + +#include <hal.h> +#define NDEBUG +#include <debug.h> + +#include "tsc.h" + +LARGE_INTEGER HalpCpuClockFrequency = {INITIAL_STALL_COUNT * 1000000}; + +UCHAR TscCalibrationPhase; +LARGE_INTEGER TscCalibrationArray[NUM_SAMPLES]; +extern const UCHAR HalpClockVector; + +/* PRIVATE FUNCTIONS *********************************************************/ + +VOID +NTAPI +HalpInitializeTsc() +{ + ULONG_PTR Flags; + KIDTENTRY OldIdtEntry, *IdtPointer; + PKPCR Pcr = KeGetPcr(); + + /* Check if the CPU supports RDTSC */ + if (!(KeGetCurrentPrcb()->FeatureBits & KF_RDTSC)) + { + KeBugCheck(HAL_INITIALIZATION_FAILED); + } + + /* Save flags and disable interrupts */ + Flags = __readeflags(); + _disable(); + +__debugbreak(); + + /* Initialze the PIT */ + //HalpInitializePIT(); + + /* Save old IDT entry */ + IdtPointer = KiGetIdtEntry(Pcr, HalpClockVector); + OldIdtEntry = *IdtPointer; + + /* Set the calibration ISR */ + KeRegisterInterruptHandler(HalpClockVector, TscCalibrationISR); + + /* Reset TSC value to 0 */ + __writemsr(MSR_RDTSC, 0); + + /* Enable the timer interupt */ + HalEnableSystemInterrupt(HalpClockVector, CLOCK_LEVEL, Latched); + + /* Wait for completion */ + _enable(); + while (TscCalibrationPhase < NUM_SAMPLES) _ReadWriteBarrier(); + _disable(); + + /* Disable the timer interupt */ + HalDisableSystemInterrupt(HalpClockVector, CLOCK_LEVEL); + + /* Restore old IDT entry */ + *IdtPointer = OldIdtEntry; + + // do linear regression + + + /* Restore flags */ + __writeeflags(Flags); + +} + +VOID +NTAPI +HalpCalibrateStallExecution(VOID) +{ + // Timer interrupt is now active + + HalpInitializeTsc(); + + KeGetPcr()->StallScaleFactor = (ULONG)(HalpCpuClockFrequency.QuadPart / 1000000); +} + +/* PUBLIC FUNCTIONS ***********************************************************/ + +LARGE_INTEGER +NTAPI +KeQueryPerformanceCounter( + OUT PLARGE_INTEGER PerformanceFrequency OPTIONAL) +{ + LARGE_INTEGER Result; + + /* Make sure it's calibrated */ + ASSERT(HalpCpuClockFrequency.QuadPart != 0); + + /* Does the caller want the frequency? */ + if (PerformanceFrequency) + { + /* Return tsc frequency */ + *PerformanceFrequency = HalpCpuClockFrequency; + } + + /* Return the current value */ + Result.QuadPart = __rdtsc(); + return Result; +} + +VOID +NTAPI +KeStallExecutionProcessor(ULONG MicroSeconds) +{ + ULONG64 StartTime, EndTime; + + /* Get the initial time */ + StartTime = __rdtsc(); + + /* Calculate the ending time */ + EndTime = StartTime + HalpCpuClockFrequency.QuadPart * MicroSeconds; + + /* Loop until time is elapsed */ + while (__rdtsc() < EndTime); +} + +VOID +NTAPI +HalCalibratePerformanceCounter( + IN volatile PLONG Count, + IN ULONGLONG NewCount) +{ + UNIMPLEMENTED; + ASSERT(FALSE); +} + Propchange: trunk/reactos/hal/halx86/apic/tsc.c ------------------------------------------------------------------------------ svn:eol-style = native Added: trunk/reactos/hal/halx86/apic/tsc.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/hal/halx86/apic/tsc.h?rev=…
============================================================================== --- trunk/reactos/hal/halx86/apic/tsc.h (added) +++ trunk/reactos/hal/halx86/apic/tsc.h [iso-8859-1] Tue Sep 6 21:01:49 2011 @@ -1,0 +1,15 @@ + + +#define NUM_SAMPLES 4 +#define MSR_RDTSC 0x10 + +#ifndef __ASM__ + +void TscCalibrationISR(void); +extern LARGE_INTEGER HalpCpuClockFrequency; +VOID NTAPI HalpInitializeTsc(); + + +#define KiGetIdtEntry(Pcr, Vector) &((Pcr)->IDT[Vector]) + +#endif Propchange: trunk/reactos/hal/halx86/apic/tsc.h ------------------------------------------------------------------------------ svn:eol-style = native Added: trunk/reactos/hal/halx86/apic/tsccal.S URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/hal/halx86/apic/tsccal.S?r…
============================================================================== --- trunk/reactos/hal/halx86/apic/tsccal.S (added) +++ trunk/reactos/hal/halx86/apic/tsccal.S [iso-8859-1] Tue Sep 6 21:01:49 2011 @@ -1,0 +1,39 @@ + +#include <asm.inc> +#include "tsc.h" + +.code + +EXTERN _TscCalibrationPhase:BYTE +EXTERN _TscCalibrationArray:QWORD + +PUBLIC _TscCalibrationISR +_TscCalibrationISR: + push eax + push ecx + push edx + + /* The first thing we do is read the current TSC value */ + rdtsc + + /* Read the current phase */ + movzx ecx, byte ptr ds:[_TscCalibrationPhase] + + /* Check if we're already done */ + cmp cl, NUM_SAMPLES + jnb _CalibrationISR_Exit + + /* Store the current value */ + mov dword ptr _TscCalibrationArray[ecx * 2], eax + mov dword ptr _TscCalibrationArray[ecx * 2 + 4], edx + + /* Advance phase */ + inc byte ptr ds:[_TscCalibrationPhase] + +_CalibrationISR_Exit: + pop edx + pop ecx + pop eax + iretd + +END Propchange: trunk/reactos/hal/halx86/apic/tsccal.S ------------------------------------------------------------------------------ svn:eol-style = native
13 years, 3 months
1
0
0
0
← Newer
1
...
27
28
29
30
31
32
33
...
40
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
Results per page:
10
25
50
100
200