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
December 2009
----- 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
22 participants
501 discussions
Start a n
N
ew thread
[gschneider] 44672: [win32k] Initialize Information contexts too, fixes eight more mapping tests
by gschneider@svn.reactos.org
Author: gschneider Date: Sun Dec 20 18:18:36 2009 New Revision: 44672 URL:
http://svn.reactos.org/svn/reactos?rev=44672&view=rev
Log: [win32k] Initialize Information contexts too, fixes eight more mapping tests Modified: trunk/reactos/subsystems/win32/win32k/objects/dclife.c Modified: trunk/reactos/subsystems/win32/win32k/objects/dclife.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ob…
============================================================================== --- trunk/reactos/subsystems/win32/win32k/objects/dclife.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/objects/dclife.c [iso-8859-1] Sun Dec 20 18:18:36 2009 @@ -331,7 +331,6 @@ DC_UnlockDc(pdc); /* Initialize the DC state */ - DC_InitDC(hdc); IntGdiSetTextColor(hdc, RGB(0, 0, 0)); IntGdiSetBkColor(hdc, RGB(255, 255, 255)); } @@ -350,6 +349,7 @@ pdcattr->crForegroundClr = RGB(0, 0, 0); DC_UnlockDc(pdc); } + DC_InitDC(hdc); if (hVisRgn) {
15 years
1
0
0
0
[gschneider] 44671: [win32k] - Mapping mode works with the virtual device resolution - Initialize virtual resolution when initializing the DC - Fixes ~30 gdi32 mapping tests
by gschneider@svn.reactos.org
Author: gschneider Date: Sun Dec 20 14:55:45 2009 New Revision: 44671 URL:
http://svn.reactos.org/svn/reactos?rev=44671&view=rev
Log: [win32k] - Mapping mode works with the virtual device resolution - Initialize virtual resolution when initializing the DC - Fixes ~30 gdi32 mapping tests Modified: trunk/reactos/subsystems/win32/win32k/objects/coord.c trunk/reactos/subsystems/win32/win32k/objects/dclife.c Modified: trunk/reactos/subsystems/win32/win32k/objects/coord.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ob…
============================================================================== --- trunk/reactos/subsystems/win32/win32k/objects/coord.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/objects/coord.c [iso-8859-1] Sun Dec 20 14:55:45 2009 @@ -688,38 +688,38 @@ /* Fall through */ case MM_LOMETRIC: - pdcattr->szlWindowExt.cx = dc->ppdev->gdiinfo.ulHorzSize * 10; - pdcattr->szlWindowExt.cy = dc->ppdev->gdiinfo.ulVertSize * 10; - pdcattr->szlViewportExt.cx = dc->ppdev->gdiinfo.ulHorzRes; - pdcattr->szlViewportExt.cy = -dc->ppdev->gdiinfo.ulVertRes; + pdcattr->szlWindowExt.cx = pdcattr->szlVirtualDeviceMm.cx * 10; + pdcattr->szlWindowExt.cy = pdcattr->szlVirtualDeviceMm.cy * 10; + pdcattr->szlViewportExt.cx = pdcattr->szlVirtualDevicePixel.cx; + pdcattr->szlViewportExt.cy = -pdcattr->szlVirtualDevicePixel.cy; break; case MM_HIMETRIC: - pdcattr->szlWindowExt.cx = dc->ppdev->gdiinfo.ulHorzSize * 100; - pdcattr->szlWindowExt.cy = dc->ppdev->gdiinfo.ulVertSize * 100; - pdcattr->szlViewportExt.cx = dc->ppdev->gdiinfo.ulHorzRes; - pdcattr->szlViewportExt.cy = -dc->ppdev->gdiinfo.ulVertRes; + pdcattr->szlWindowExt.cx = pdcattr->szlVirtualDeviceMm.cx * 100; + pdcattr->szlWindowExt.cy = pdcattr->szlVirtualDeviceMm.cy * 100; + pdcattr->szlViewportExt.cx = pdcattr->szlVirtualDevicePixel.cx; + pdcattr->szlViewportExt.cy = -pdcattr->szlVirtualDevicePixel.cy; break; case MM_LOENGLISH: - pdcattr->szlWindowExt.cx = MulDiv(1000, dc->ppdev->gdiinfo.ulHorzSize, 254); - pdcattr->szlWindowExt.cy = MulDiv(1000, dc->ppdev->gdiinfo.ulVertSize, 254); - pdcattr->szlViewportExt.cx = dc->ppdev->gdiinfo.ulHorzRes; - pdcattr->szlViewportExt.cy = -dc->ppdev->gdiinfo.ulVertRes; + pdcattr->szlWindowExt.cx = MulDiv(1000, pdcattr->szlVirtualDeviceMm.cx, 254); + pdcattr->szlWindowExt.cy = MulDiv(1000, pdcattr->szlVirtualDeviceMm.cy, 254); + pdcattr->szlViewportExt.cx = pdcattr->szlVirtualDevicePixel.cx; + pdcattr->szlViewportExt.cy = -pdcattr->szlVirtualDevicePixel.cy; break; case MM_HIENGLISH: - pdcattr->szlWindowExt.cx = MulDiv(10000, dc->ppdev->gdiinfo.ulHorzSize, 254); - pdcattr->szlWindowExt.cy = MulDiv(10000, dc->ppdev->gdiinfo.ulVertSize, 254); - pdcattr->szlViewportExt.cx = dc->ppdev->gdiinfo.ulHorzRes; - pdcattr->szlViewportExt.cy = -dc->ppdev->gdiinfo.ulVertRes; + pdcattr->szlWindowExt.cx = MulDiv(10000, pdcattr->szlVirtualDeviceMm.cx, 254); + pdcattr->szlWindowExt.cy = MulDiv(10000, pdcattr->szlVirtualDeviceMm.cy, 254); + pdcattr->szlViewportExt.cx = pdcattr->szlVirtualDevicePixel.cx; + pdcattr->szlViewportExt.cy = -pdcattr->szlVirtualDevicePixel.cy; break; case MM_TWIPS: - pdcattr->szlWindowExt.cx = MulDiv(14400, dc->ppdev->gdiinfo.ulHorzSize, 254); - pdcattr->szlWindowExt.cy = MulDiv(14400, dc->ppdev->gdiinfo.ulVertSize, 254); - pdcattr->szlViewportExt.cx = dc->ppdev->gdiinfo.ulHorzRes; - pdcattr->szlViewportExt.cy = -dc->ppdev->gdiinfo.ulVertRes; + pdcattr->szlWindowExt.cx = MulDiv(14400, pdcattr->szlVirtualDeviceMm.cx, 254); + pdcattr->szlWindowExt.cy = MulDiv(14400, pdcattr->szlVirtualDeviceMm.cy, 254); + pdcattr->szlViewportExt.cx = pdcattr->szlVirtualDevicePixel.cx; + pdcattr->szlViewportExt.cy = -pdcattr->szlVirtualDevicePixel.cy; break; case MM_ANISOTROPIC: Modified: trunk/reactos/subsystems/win32/win32k/objects/dclife.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ob…
============================================================================== --- trunk/reactos/subsystems/win32/win32k/objects/dclife.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/objects/dclife.c [iso-8859-1] Sun Dec 20 14:55:45 2009 @@ -568,6 +568,9 @@ ASSERT ( res != ERROR ); } */ + + /* Set virtual resolution */ + NtGdiSetVirtualResolution(DCHandle, 0, 0, 0, 0); } /*
15 years
1
0
0
0
[gschneider] 44670: [userenv] Print the directory name when GetShortPathNameW fails
by gschneider@svn.reactos.org
Author: gschneider Date: Sun Dec 20 14:47:20 2009 New Revision: 44670 URL:
http://svn.reactos.org/svn/reactos?rev=44670&view=rev
Log: [userenv] Print the directory name when GetShortPathNameW fails Modified: trunk/reactos/dll/win32/userenv/environment.c Modified: trunk/reactos/dll/win32/userenv/environment.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/userenv/environm…
============================================================================== --- trunk/reactos/dll/win32/userenv/environment.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/userenv/environment.c [iso-8859-1] Sun Dec 20 14:47:20 2009 @@ -85,7 +85,7 @@ { if (!GetShortPathNameW(DstValue.Buffer, ShortName, MAX_PATH)) { - DPRINT1("GetShortPathNameW() failed (Error %lu)\n", GetLastError()); + DPRINT1("GetShortPathNameW() failed for %S (Error %lu)\n", DstValue.Buffer, GetLastError()); if (Buffer) LocalFree(Buffer); return FALSE; }
15 years
1
0
0
0
[tkreuzer] 44669: Merge from amd64 branch: [NTOSKRNL] 44415 Move architecture specific inline functions in into the respective headers. [FREELDR] 39639 Fix 2 small typos. 40247 Fix a number of ULONG / ULONG_PTR issues, remove LoadReactOSSetup2 for non-x86 builds. 40324 Fix switching from long mode to real mode, by jumping into a compatibility segment first. 43566 move wlmemory.c into arch specific folder. add wlmemory.c and ntsetup.c for amd64 (stubbed) 43574 Enable winldr style boot for amd64 4
by tkreuzer@svn.reactos.org
Author: tkreuzer Date: Sun Dec 20 14:30:35 2009 New Revision: 44669 URL:
http://svn.reactos.org/svn/reactos?rev=44669&view=rev
Log: Merge from amd64 branch: [NTOSKRNL] 44415 Move architecture specific inline functions in into the respective headers. [FREELDR] 39639 Fix 2 small typos. 40247 Fix a number of ULONG / ULONG_PTR issues, remove LoadReactOSSetup2 for non-x86 builds. 40324 Fix switching from long mode to real mode, by jumping into a compatibility segment first. 43566 move wlmemory.c into arch specific folder. add wlmemory.c and ntsetup.c for amd64 (stubbed) 43574 Enable winldr style boot for amd64 43598 Split wlmemory into portable and arch specific code. Partly implement amd64 version. 43600 Fix a bug. 43601 Move definition of KIP0PCRADDRESS into arch specific header. Implement WinLdrSetupForNt for amd64. Fix mapping of PCR and KI_USER_SHARED_DATA. Don't enable paging again on amd64. Fix WinLdrSetProcessorContext to take a ULONG_PTR not ULONG for Pcr and Tss 43602 Round up to pages when updating LoaderPagesSpanned to avoid a bug when the last memory region is not mapped. 43604 Add MempIsPageMapped for debugging puposes. Map pages for kernel, too in amd64 version of MempSetupPaging. 43605 Include the intrinsics from the kernel. Set segement selectors 43757 Pass pointer to debugprint function to the kernel in LoaderBlock->u.I386.CommonDataArea. Comment out __lldt 43775 Fixed build with MinGW-w64 4.4.3 44065 Use LoaderMemoryData instead of LoaderSpecialMemory for page tables 44095 Use the kernel mode address for the gdt/idt 44123 Fix a typo 44144 Share some more inline functions between the kernel and freeldr. Use __ltr instead of Ke386SetTr. refactor KiInitializeTss. Update some Mm constants. Halfplement KeFlushEntireTb. Clean the mapping of page 0 in KiSystemStartup, as long as we don't clean mappings in freeldr. Fix a bug in KiPageFault, where ebp was used instead of rbp. Refactor MmArmInitSystem and related. 44205 Improve the code in wlmemory.c, no real functional change. 44426 remove unused variables. 44530 Don't include i386/ke.h from ntoskrnl. 44540 Detect if this is a amd64 CPU before attempting to boot. (Basil Gello) Added: trunk/reactos/boot/freeldr/freeldr/windows/amd64/ (props changed) - copied from r43566, branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/windows/amd64/ trunk/reactos/boot/freeldr/freeldr/windows/i386/wlmemory.c - copied, changed from r43566, branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/windows/i386/wlmemory.c trunk/reactos/boot/freeldr/freeldr/windows/wlmemory.c - copied, changed from r43598, branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/windows/wlmemory.c Modified: trunk/reactos/ (props changed) trunk/reactos/boot/freeldr/freeldr/arch/amd64/arch.S trunk/reactos/boot/freeldr/freeldr/arch/amd64/fathelp.S trunk/reactos/boot/freeldr/freeldr/bootmgr.c trunk/reactos/boot/freeldr/freeldr/freeldr_arch.rbuild trunk/reactos/boot/freeldr/freeldr/freeldr_base.rbuild trunk/reactos/boot/freeldr/freeldr/include/arch/amd64/amd64.h trunk/reactos/boot/freeldr/freeldr/include/arch/i386/i386.h trunk/reactos/boot/freeldr/freeldr/include/freeldr.h trunk/reactos/boot/freeldr/freeldr/mm/mm.c trunk/reactos/boot/freeldr/freeldr/setupldr_main.rbuild trunk/reactos/boot/freeldr/freeldr/windows/amd64/ntsetup.c trunk/reactos/boot/freeldr/freeldr/windows/amd64/wlmemory.c trunk/reactos/boot/freeldr/freeldr/windows/peloader.c trunk/reactos/boot/freeldr/freeldr/windows/winldr.c trunk/reactos/dll/directx/d3d8/d3d8.spec (props changed) trunk/reactos/dll/directx/dsound_new/classfactory.c (props changed) trunk/reactos/dll/directx/dsound_new/dsound.spec (props changed) trunk/reactos/dll/directx/dsound_new/regsvr.c (props changed) trunk/reactos/dll/shellext/devcpux/devcpux.spec (props changed) trunk/reactos/dll/shellext/slayer/slayer.spec (props changed) trunk/reactos/include/ndk/amd64/ (props changed) trunk/reactos/include/ndk/amd64/asmmacro.S (props changed) trunk/reactos/lib/sdk/crt/time/ (props changed) trunk/reactos/ntoskrnl/include/internal/arm/ke.h trunk/reactos/ntoskrnl/include/internal/i386/ke.h trunk/reactos/ntoskrnl/include/internal/ke_x.h trunk/reactos/ntoskrnl/include/internal/powerpc/ke.h trunk/reactos/subsystems/win32/win32k/include/engobjects.h (props changed) trunk/reactos/tools/rsym/log2lines.c (props changed) trunk/reactos/tools/rsym/log2lines.mak (props changed) trunk/reactos/tools/rsym/rsym.c (props changed) trunk/reactos/tools/rsym/rsym.h (props changed) trunk/reactos/tools/rsym/rsym.mak (props changed) trunk/reactos/tools/rsym/rsym_common.c (props changed) Propchange: trunk/reactos/ ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Sun Dec 20 14:30:35 2009 @@ -1,1 +1,1 @@ -/branches/ros-amd64-bringup/reactos:34711-34712,34743,34812,34839,34842,34917,35323-35324,35347-35348,35361,35436,35509,35515,35588,35683,35739,35746,35762,35771,35777,35789,35823,35827,35902,35904-35906,35942,35947-35949,35952-35953,35966,36013,36172,36360,36388-36389,36445,36502-36503,36505,36570,36614,36899,36930,36936,37323,37434,37472,37475,37536,37820-37821,37868-37869,37873,37990-37991,38013-38014,38148-38151,38264-38265,38268,38355,39151,39333,39345,40122-40123,40125,40128,40155,40753,40928,40986-40987,40989,40991,40993,40995-40996,41000-41001,41027-41030,41044-41045,41047-41050,41052,41082-41086,41097-41098,41101,41449,41484,41499,41549,43080,43426,43454,43506,43677,43682,43839-43840,43857-43858,43860,43905-43907,44002,44037,44039-44040,44044-44045,44294,44338,44389,44391,44460,44601 +/branches/ros-amd64-bringup/reactos:34711-34712,34743,34812,34839,34842,34917,35323-35324,35347-35348,35361,35436,35509,35515,35588,35683,35739,35746,35762,35771,35777,35789,35823,35827,35902,35904-35906,35942,35947-35949,35952-35953,35966,36013,36172,36360,36388-36389,36445,36502-36503,36505,36570,36614,36899,36930,36936,37323,37434,37472,37475,37536,37820-37821,37868-37869,37873,37990-37991,38013-38014,38148-38151,38264-38265,38268,38355,39151,39333,39345,39639,40122-40123,40125,40128,40155,40247,40324,40753,40928,40986-40987,40989,40991,40993,40995-40996,41000-41001,41027-41030,41044-41045,41047-41050,41052,41082-41086,41097-41098,41101,41449,41484,41499,41549,43080,43426,43454,43506,43566,43574,43598,43600-43602,43604-43605,43677,43682,43757,43775,43839-43840,43857-43858,43860,43905-43907,44002,44037,44039-44040,44044-44045,44065,44095,44123,44144,44205,44294,44338,44389,44391,44426,44460,44530,44540,44601 Modified: trunk/reactos/boot/freeldr/freeldr/arch/amd64/arch.S URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/arch/…
============================================================================== --- trunk/reactos/boot/freeldr/freeldr/arch/amd64/arch.S [iso-8859-1] (original) +++ trunk/reactos/boot/freeldr/freeldr/arch/amd64/arch.S [iso-8859-1] Sun Dec 20 14:30:35 2009 @@ -20,6 +20,10 @@ mov gs, ax mov ss, ax + /* checkPoint Charlie - where it all began... */ + mov si, offset _CheckPoint0 + call writestr + /* Setup a real mode stack */ mov sp, stack16 @@ -41,17 +45,88 @@ call x86_16_EnableA20 + /* checkPoint Charlie - where it all began... */ + mov si, offset _CheckPoint1 + call writestr + call x86_16_BuildPageTables - - /* Switch to long mode */ + + /* checkPoint Charlie - where it all began... */ + mov si, offset _CheckPoint2 + call writestr + + /* Check if CPU supports CPUID */ + + pushfd + pop eax + mov ebx, eax + xor eax, 0x00200000 + push eax + popfd + pushfd + pop eax + cmp eax,ebx + jz NO_CPUID_SUPPORT_DETECTED + + /* CPUID support detected - getting the PAE/PGE */ + + mov eax,1 // Fn0000_0001 - PAE in EDX[6] + cpuid + xor eax,eax + and edx,0x00a0 + test edx,edx // are PAE and PGE bits set? + jz NO_X64_SUPPORT_DETECTED + + /* PAE and PGE are here */ + + xor edx, edx + mov eax, 0x80000001 + cpuid + and edx, 0x20000000 + test edx,edx + jz NO_X64_SUPPORT_DETECTED + + /* X64 Processor */ + + /* checkPoint Charlie - where it all began... */ + mov si, offset _CheckPoint3 + call writestr + + jmp _switch64 + +NO_X64_SUPPORT_DETECTED: + mov si, offset _NotAnX64Processor // Loading message + call writestr + jmp _fail + +NO_CPUID_SUPPORT_DETECTED: + mov si, offset _NoCPUIDSupport // Loading message + call writestr + +_fail: + jmp _fail + nop + nop + +_switch64: call x86_16_SwitchToLong .code64 + +// mov ax, LMODE_DS +// mov ds, ax +// mov word ptr ds:[0xb8000], 0x0e00 + '1' /* GO! */ xor rcx, rcx call _BootMain + /* Checkpoint */ +// mov ax, LMODE_DS +// mov ds, ax +// mov word ptr ds:[0xb8002], 0x0e02 + '2' + + /* Return into real mode */ call x86_64_SwitchToReal .code16 @@ -90,7 +165,6 @@ popa ret - /* * We define 512 2MB pages at the start of memory, so we can access the first * 1 GB as if paging was disabled @@ -143,9 +217,39 @@ popa ret +/* + * writechr,writestr + * + * + */ +writestr: + pushfd + pushad +.top: + lodsb + and al, al + jz .end + call writechr + jmp short .top +.end: + popad + popfd + ret + + +writechr: + pushf + pusha + mov ah, 0x0E + xor bx, bx + int 0x10 + popa + popf + ret //.global x86_16_SwitchToLong x86_16_SwitchToLong: + cli xor ax,ax @@ -190,8 +294,7 @@ /* Now return in long mode! */ ret - -/** 64 But functions **********************************************************/ +/** 64 Bit functions **********************************************************/ .code64 .global x86_64_SwitchToReal @@ -203,25 +306,40 @@ /* Save 64-bit stack pointer */ mov stack64, rsp - /* Step 1 - deactivate long mode, by disabling paging */ - mov rax, cr0 - and rax, 0x000000007fffffff //~0x80000000 - mov cr0, rax +// mov ax, LMODE_DS +// mov ds, ax +// mov word ptr ds:[0xb8004], 0x0e00 + '3' + + /* Step 1 - jump to compatibility segment */ + ljmp jumpvector + +jumpvector: + .long SwitchToReal1 + .word CMODE_CS + +SwitchToReal1: +.code32 + +// mov word ptr ds:[0xb8006], 0x0e00 + '4' + + /* Step 2 - deactivate long mode, by disabling paging */ + mov eax, cr0 + and eax, 0x000000007fffffff //~0x80000000 + mov cr0, eax /* Step 2 - disable long mode in EFER MSR */ - mov rcx, 0xC0000080 // Specify EFER MSR - rdmsr - and eax, ~0x00000100 // Disable EFER.LME - wrmsr - - .code32 - /* jmp to 16-bit segment to set the limit correctly */ +// mov ecx, 0xC0000080 // Specify EFER MSR +// rdmsr +// and eax, ~0x00000100 // Disable EFER.LME +// wrmsr + + /* Step 3 - jump to 16-bit segment to set the limit correctly */ jmp RMODE_CS: offset SwitchToReal2 SwitchToReal2: .code16 - /* Step 3 - Disable Protected Mode */ + /* Step 4 - Disable Protected Mode */ mov eax, cr0 and eax, ~0x00000001 mov cr0, eax @@ -230,6 +348,11 @@ jmp 0:offset BeReal BeReal: + /* Checkpoint */ +// mov ax, 0xb800 +// mov fs, ax +// mov word ptr fs:[0x0C], 0x0e00 + '7' + /* Restore segment registers */ mov ax, 0 mov ds, ax @@ -238,7 +361,7 @@ mov gs, ax mov ss, ax - /* Rstore 16 bit stack */ + /* Restore 16 bit stack */ mov sp, stack16 // lidt rmode_idtptr /* Load IDTR with real mode value */ @@ -266,17 +389,19 @@ code64ret: .quad 0 +.p2align 2 gdt: .quad 0x0000000000000000 /* 00: NULL descriptor */ .quad 0x0000000000000000 /* 08: */ .quad 0x0020980000000000 /* 10: long mode cs */ - .quad 0x0000900000000000 /* 18: long mode ds */ + .quad 0x00cff3000000ffff /* 18: long mode ds */ .word 0xFFFF, 0x0000, 0x9E00, 0x0000 /* 16-bit real mode CS */ .word 0xFFFF, 0x0000, 0x9200, 0x0000 /* 16-bit real mode DS */ + .quad 0x00CF9B000000FFFF /* 30: compat mode cs */ /* GDT table pointer */ gdtptr: - .word 0x2f /* Limit */ + .word 0x37 /* Limit */ .long gdt /* Base Address */ @@ -288,6 +413,36 @@ _BootPartition: .long 0 +.global _NotAnX64Processor +_NotAnX64Processor: + .ascii "FreeLoader: No x64-compatible CPU detected! Exiting..." + .byte 0x0d, 0x0a, 0 + +.global _NoCPUIDSupport +_NoCPUIDSupport: + .ascii "FreeLoader: No CPUID instruction support detected! Exiting..." + .byte 0x0d, 0x0a, 0 + +/////////////////////////// Checkpoint messages /////////////////////////////// +.global _CheckPoint0 +_CheckPoint0: + .ascii "Starting FreeLoader..." + .byte 0x0d, 0x0a, 0 + +.global _CheckPoint1 +_CheckPoint1: + .ascii "FreeLoader[16-bit]: building page tables..." + .byte 0x0d, 0x0a, 0 + +.global _CheckPoint2 +_CheckPoint2: + .ascii "FreeLoader[16-bit]: checking CPU for x64 long mode..." + .byte 0x0d, 0x0a, 0 + +.global _CheckPoint3 +_CheckPoint3: + .ascii "FreeLoader: Switching to x64 long mode..." + .byte 0x0d, 0x0a, 0 /////////////////////////////////////////////////////////////////////////////// Modified: trunk/reactos/boot/freeldr/freeldr/arch/amd64/fathelp.S URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/arch/…
============================================================================== --- trunk/reactos/boot/freeldr/freeldr/arch/amd64/fathelp.S [iso-8859-1] (original) +++ trunk/reactos/boot/freeldr/freeldr/arch/amd64/fathelp.S [iso-8859-1] Sun Dec 20 14:30:35 2009 @@ -155,7 +155,7 @@ add bx,dx mov es,bx mov bx,ax // Restore FAT entry offset - mov ax, [es:bx] // Get FAT entry + mov ax, es:[bx] // Get FAT entry ret @@ -173,7 +173,7 @@ mov bx,0x7000 mov es,bx mov bx,ax // Put FAT entry offset into BX - mov ax, [es:bx] // Get FAT entry + mov ax, es:[bx] // Get FAT entry pop cx // Get cluster number from stack and cx,1 jz UseLow12Bits Modified: trunk/reactos/boot/freeldr/freeldr/bootmgr.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/bootm…
============================================================================== --- trunk/reactos/boot/freeldr/freeldr/bootmgr.c [iso-8859-1] (original) +++ trunk/reactos/boot/freeldr/freeldr/bootmgr.c [iso-8859-1] Sun Dec 20 14:30:35 2009 @@ -233,7 +233,7 @@ // to have different install methods, etc. LoadReactOSSetup(); } -#ifdef __i386__ +#if defined(__i386__) || defined(__x86_64__) else if (_stricmp(BootType, "ReactOSSetup2") == 0) { // WinLdr-style boot Modified: trunk/reactos/boot/freeldr/freeldr/freeldr_arch.rbuild URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/freel…
============================================================================== --- trunk/reactos/boot/freeldr/freeldr/freeldr_arch.rbuild [iso-8859-1] (original) +++ trunk/reactos/boot/freeldr/freeldr/freeldr_arch.rbuild [iso-8859-1] Sun Dec 20 14:30:35 2009 @@ -108,6 +108,13 @@ <if property="ARCH" value="i386"> <directory name="i386"> <file>ntsetup.c</file> + <file>wlmemory.c</file> + </directory> + </if> + <if property="ARCH" value="amd64"> + <directory name="amd64"> + <file>ntsetup.c</file> + <file>wlmemory.c</file> </directory> </if> </directory> Modified: trunk/reactos/boot/freeldr/freeldr/freeldr_base.rbuild URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/freel…
============================================================================== --- trunk/reactos/boot/freeldr/freeldr/freeldr_base.rbuild [iso-8859-1] (original) +++ trunk/reactos/boot/freeldr/freeldr/freeldr_base.rbuild [iso-8859-1] Sun Dec 20 14:30:35 2009 @@ -77,6 +77,15 @@ <file>wlregistry.c</file> </directory> </if> + <if property="ARCH" value="amd64"> + <directory name="windows"> + <file>conversion.c</file> + <file>peloader.c</file> + <file>winldr.c</file> + <file>wlmemory.c</file> + <file>wlregistry.c</file> + </directory> + </if> <file>freeldr.c</file> <file>debug.c</file> <file>version.c</file> Modified: trunk/reactos/boot/freeldr/freeldr/include/arch/amd64/amd64.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/inclu…
============================================================================== --- trunk/reactos/boot/freeldr/freeldr/include/arch/amd64/amd64.h [iso-8859-1] (original) +++ trunk/reactos/boot/freeldr/freeldr/include/arch/amd64/amd64.h [iso-8859-1] Sun Dec 20 14:30:35 2009 @@ -21,6 +21,10 @@ #ifndef __AMD64_AMD64_H_ #define __AMD64_AMD64_H_ +// This is needed because headers define wrong one for ReactOS +#undef KIP0PCRADDRESS +#define KIP0PCRADDRESS 0xFFFFF78000001000ULL /* FIXME!!! */ + #define STACK64ADDR 0x74000 /* The 64-bit stack top will be at 0x74000 */ /* Long mode selectors */ @@ -28,6 +32,7 @@ #define LMODE_DS 0x18 #define RMODE_CS 0x20 /* RMode code selector, base 0 limit 64k */ #define RMODE_DS 0x28 /* RMode data selector, base 0 limit 64k */ +#define CMODE_CS 0x30 #define VA_MASK 0x0000FFFFFFFFFFFFUL @@ -53,35 +58,6 @@ HARDWARE_PTE Pde[512]; } PAGE_DIRECTORY_AMD64, *PPAGE_DIRECTORY_AMD64; -VOID -FORCEINLINE -__lgdt(void *gdt) -{ - asm volatile ("lgdt %0\n" : : "m"(*(short*)gdt)); -} - -PKGDTENTRY64 -FORCEINLINE -KiGetGdtEntry(PVOID pGdt, USHORT Index) -{ - return (PKGDTENTRY64)((ULONG64)pGdt + (Index & ~RPL_MASK)); -} - -VOID -FORCEINLINE -KiInitGdtEntry(PKGDTENTRY64 Entry, ULONG64 Base, ULONG Limit, UCHAR Type, UCHAR Dpl) -{ - Entry->Bits.Type = Type; - Entry->Bits.Present = 1; - Entry->Bits.Dpl = Dpl; - Entry->BaseLow = (USHORT)(Base & 0xFFFF); - Entry->Bytes.BaseMiddle = (UCHAR)(Base >> 16); - Entry->Bytes.BaseHigh = (UCHAR)(Base >> 24); - Entry->BaseUpper = (ULONG)(Base >> 32); - Entry->LimitLow = (USHORT)(Limit & 0xFFFF); - Entry->Bits.LimitHigh = (ULONG)((Limit >> 16) & 0xf); - Entry->MustBeZero = 0; -} VOID FrLdrSetupGdtIdt(); Modified: trunk/reactos/boot/freeldr/freeldr/include/arch/i386/i386.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/inclu…
============================================================================== --- trunk/reactos/boot/freeldr/freeldr/include/arch/i386/i386.h [iso-8859-1] (original) +++ trunk/reactos/boot/freeldr/freeldr/include/arch/i386/i386.h [iso-8859-1] Sun Dec 20 14:30:35 2009 @@ -21,6 +21,9 @@ #ifndef __I386_I386_H_ #define __I386_I386_H_ +// This is needed because headers define wrong one for ReactOS +#undef KIP0PCRADDRESS +#define KIP0PCRADDRESS 0xffdff000 #endif /* __I386_I386_H_ */ Modified: trunk/reactos/boot/freeldr/freeldr/include/freeldr.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/inclu…
============================================================================== --- trunk/reactos/boot/freeldr/freeldr/include/freeldr.h [iso-8859-1] (original) +++ trunk/reactos/boot/freeldr/freeldr/include/freeldr.h [iso-8859-1] Sun Dec 20 14:30:35 2009 @@ -80,7 +80,6 @@ #include <arch/i386/machxbox.h> #include <arch/i386/miscboot.h> #include <internal/i386/intrin_i.h> -#include <internal/i386/ke.h> #elif defined(_M_PPC) #include <arch/powerpc/hardware.h> #elif defined(_M_ARM) @@ -90,6 +89,7 @@ #elif defined(_M_AMD64) #include <arch/amd64/hardware.h> #include <arch/amd64/machpc.h> +#include <internal/amd64/intrin_i.h> #endif /* misc files */ #include <keycodes.h> Modified: trunk/reactos/boot/freeldr/freeldr/mm/mm.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/mm/mm…
============================================================================== --- trunk/reactos/boot/freeldr/freeldr/mm/mm.c [iso-8859-1] (original) +++ trunk/reactos/boot/freeldr/freeldr/mm/mm.c [iso-8859-1] Sun Dec 20 14:30:35 2009 @@ -75,8 +75,8 @@ #endif // DBG // Update LoaderPagesSpanned count - if ((((ULONG_PTR)MemPointer + MemorySize) >> PAGE_SHIFT) > LoaderPagesSpanned) - LoaderPagesSpanned = (((ULONG_PTR)MemPointer + MemorySize) >> PAGE_SHIFT); + if ((((ULONG_PTR)MemPointer + MemorySize + PAGE_SIZE - 1) >> PAGE_SHIFT) > LoaderPagesSpanned) + LoaderPagesSpanned = (((ULONG_PTR)MemPointer + MemorySize + PAGE_SIZE - 1) >> PAGE_SHIFT); // Now return the pointer return MemPointer; @@ -175,8 +175,8 @@ #endif // DBG // Update LoaderPagesSpanned count - if ((((ULONG_PTR)MemPointer + MemorySize) >> PAGE_SHIFT) > LoaderPagesSpanned) - LoaderPagesSpanned = (((ULONG_PTR)MemPointer + MemorySize) >> PAGE_SHIFT); + if ((((ULONG_PTR)MemPointer + MemorySize + PAGE_SIZE - 1) >> PAGE_SHIFT) > LoaderPagesSpanned) + LoaderPagesSpanned = (((ULONG_PTR)MemPointer + MemorySize + PAGE_SIZE - 1) >> PAGE_SHIFT); // Now return the pointer return MemPointer; Modified: trunk/reactos/boot/freeldr/freeldr/setupldr_main.rbuild URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/setup…
============================================================================== --- trunk/reactos/boot/freeldr/freeldr/setupldr_main.rbuild [iso-8859-1] (original) +++ trunk/reactos/boot/freeldr/freeldr/setupldr_main.rbuild [iso-8859-1] Sun Dec 20 14:30:35 2009 @@ -20,8 +20,13 @@ <file>setupldr.c</file> </directory> <if property="ARCH" value="i386"> - <directory name="windows"> - <file>setupldr2.c</file> - </directory> - </if> + <directory name="windows"> + <file>setupldr2.c</file> + </directory> + </if> + <if property="ARCH" value="amd64"> + <directory name="windows"> + <file>setupldr2.c</file> + </directory> + </if> </module> Propchange: trunk/reactos/boot/freeldr/freeldr/windows/amd64/ ------------------------------------------------------------------------------ --- bugtraq:logregex (added) +++ bugtraq:logregex Sun Dec 20 14:30:35 2009 @@ -1,0 +1,2 @@ +([Ii]ssue|[Bb]ug)s? #?(\d+)(,? ?#?(\d+))*(,? ?(and |or )?#?(\d+))? +(\d+) Propchange: trunk/reactos/boot/freeldr/freeldr/windows/amd64/ ------------------------------------------------------------------------------ bugtraq:message = See issue #%BUGID% for more details. Propchange: trunk/reactos/boot/freeldr/freeldr/windows/amd64/ ------------------------------------------------------------------------------ bugtraq:url =
http://www.reactos.org/bugzilla/show_bug.cgi?id=%BUGID%
Propchange: trunk/reactos/boot/freeldr/freeldr/windows/amd64/ ------------------------------------------------------------------------------ tsvn:logminsize = 10 Modified: trunk/reactos/boot/freeldr/freeldr/windows/amd64/ntsetup.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/windo…
============================================================================== --- trunk/reactos/boot/freeldr/freeldr/windows/amd64/ntsetup.c [iso-8859-1] (original) +++ trunk/reactos/boot/freeldr/freeldr/windows/amd64/ntsetup.c [iso-8859-1] Sun Dec 20 14:30:35 2009 @@ -40,5 +40,45 @@ ULONG *PcrBasePage, ULONG *TssBasePage) { + ULONG TssSize; + ULONG TssPages; + ULONG_PTR Pcr = 0; + ULONG_PTR Tss = 0; + ULONG BlockSize, NumPages; + LoaderBlock->u.I386.CommonDataArea = (PVOID)DbgPrint; // HACK + LoaderBlock->u.I386.MachineType = MACHINE_TYPE_ISA; + + /* Allocate 2 pages for PCR */ + Pcr = (ULONG_PTR)MmAllocateMemoryWithType(2 * MM_PAGE_SIZE, LoaderStartupPcrPage); + *PcrBasePage = Pcr >> MM_PAGE_SHIFT; + RtlZeroMemory((PVOID)Pcr, 2 * MM_PAGE_SIZE); + + if (Pcr == 0) + { + UiMessageBox("Can't allocate PCR\n"); + return; + } + + /* Allocate TSS */ + TssSize = (sizeof(KTSS) + MM_PAGE_SIZE) & ~(MM_PAGE_SIZE - 1); + TssPages = TssSize / MM_PAGE_SIZE; + + Tss = (ULONG_PTR)MmAllocateMemoryWithType(TssSize, LoaderMemoryData); + + *TssBasePage = Tss >> MM_PAGE_SHIFT; + + /* Allocate space for new GDT + IDT */ + BlockSize = NUM_GDT*sizeof(KGDTENTRY) + NUM_IDT*sizeof(KIDTENTRY);//FIXME: Use GDT/IDT limits here? + NumPages = (BlockSize + MM_PAGE_SIZE - 1) >> MM_PAGE_SHIFT; + *GdtIdt = (PKGDTENTRY)MmAllocateMemoryWithType(NumPages * MM_PAGE_SIZE, LoaderMemoryData); + + if (*GdtIdt == NULL) + { + UiMessageBox("Can't allocate pages for GDT+IDT!\n"); + return; + } + + /* Zero newly prepared GDT+IDT */ + RtlZeroMemory(*GdtIdt, NumPages << MM_PAGE_SHIFT); } Modified: trunk/reactos/boot/freeldr/freeldr/windows/amd64/wlmemory.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/windo…
============================================================================== --- trunk/reactos/boot/freeldr/freeldr/windows/amd64/wlmemory.c [iso-8859-1] (original) +++ trunk/reactos/boot/freeldr/freeldr/windows/amd64/wlmemory.c [iso-8859-1] Sun Dec 20 14:30:35 2009 @@ -1,9 +1,9 @@ /* * PROJECT: EFI Windows Loader * LICENSE: GPL - See COPYING in the top level directory - * FILE: freeldr/winldr/wlmemory.c + * FILE: freeldr/amd64/wlmemory.c * PURPOSE: Memory related routines - * PROGRAMMERS: Aleksey Bragin (aleksey(a)reactos.org) + * PROGRAMMERS: Timo Kreuzer (timo.kreuzer(a)reactos.org) */ /* INCLUDES ***************************************************************/ @@ -13,82 +13,14 @@ #include <ndk/asm.h> #include <debug.h> -extern ULONG TotalNLSSize; -extern ULONG LoaderPagesSpanned; - -// This is needed because headers define wrong one for ReactOS -#undef KIP0PCRADDRESS -#define KIP0PCRADDRESS 0xffdff000 - -#define HYPER_SPACE_ENTRY 0x300 - -PCHAR MemTypeDesc[] = { - "ExceptionBlock ", // ? - "SystemBlock ", // ? - "Free ", - "Bad ", // used - "LoadedProgram ", // == Free - "FirmwareTemporary ", // == Free - "FirmwarePermanent ", // == Bad - "OsloaderHeap ", // used - "OsloaderStack ", // == Free - "SystemCode ", - "HalCode ", - "BootDriver ", // not used - "ConsoleInDriver ", // ? - "ConsoleOutDriver ", // ? - "StartupDpcStack ", // ? - "StartupKernelStack", // ? - "StartupPanicStack ", // ? - "StartupPcrPage ", // ? - "StartupPdrPage ", // ? - "RegistryData ", // used - "MemoryData ", // not used - "NlsData ", // used - "SpecialMemory ", // == Bad - "BBTMemory " // == Bad - }; - -VOID -WinLdrpDumpMemoryDescriptors(PLOADER_PARAMETER_BLOCK LoaderBlock); - - -VOID -MempAddMemoryBlock(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock, - ULONG BasePage, - ULONG PageCount, - ULONG Type); -VOID -WinLdrInsertDescriptor(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock, - IN PMEMORY_ALLOCATION_DESCRIPTOR NewDescriptor); - -VOID -WinLdrRemoveDescriptor(IN PMEMORY_ALLOCATION_DESCRIPTOR Descriptor); - -VOID -WinLdrSetProcessorContext(PVOID GdtIdt, IN ULONG Pcr, IN ULONG Tss); - -// This is needed only for SetProcessorContext routine -#pragma pack(2) - typedef struct - { - USHORT Limit; - ULONG Base; - } GDTIDT; -#pragma pack(4) +//extern ULONG LoaderPagesSpanned; + +#define HYPER_SPACE_ENTRY 0x1EE /* GLOBALS ***************************************************************/ -PHARDWARE_PTE PDE; -PHARDWARE_PTE HalPageTable; - -PUCHAR PhysicalPageTablesBuffer; -PUCHAR KernelPageTablesBuffer; -ULONG PhysicalPageTables; -ULONG KernelPageTables; - -MEMORY_ALLOCATION_DESCRIPTOR *Mad; -ULONG MadCount = 0; +PHARDWARE_PTE PxeBase; +//PHARDWARE_PTE HalPageTable; /* FUNCTIONS **************************************************************/ @@ -96,74 +28,326 @@ BOOLEAN MempAllocatePageTables() { + DPRINTM(DPRINT_WINDOWS,">>> MempAllocatePageTables\n"); + + /* Allocate a page for the PML4 */ + PxeBase = MmAllocateMemoryWithType(PAGE_SIZE, LoaderMemoryData); + if (!PxeBase) + { + DPRINTM(DPRINT_WINDOWS,"failed to allocate PML4\n"); + return FALSE; + } + + // FIXME: Physical PTEs = FirmwareTemporary ? + + /* Zero the PML4 */ + RtlZeroMemory(PxeBase, PAGE_SIZE); + + /* The page tables are located at 0xfffff68000000000 + * We create a recursive self mapping through all 4 levels at + * virtual address 0xfffff6fb7dbedf68 */ + PxeBase[VAtoPXI(PXE_BASE)].Valid = 1; + PxeBase[VAtoPXI(PXE_BASE)].Write = 1; + PxeBase[VAtoPXI(PXE_BASE)].PageFrameNumber = PtrToPfn(PxeBase); + + // FIXME: map PDE's for hals memory mapping + + DPRINTM(DPRINT_WINDOWS,">>> leave MempAllocatePageTables\n"); return TRUE; } -VOID -MempAllocatePTE(ULONG Entry, PHARDWARE_PTE *PhysicalPT, PHARDWARE_PTE *KernelPT) -{ - +PHARDWARE_PTE +MempGetOrCreatePageDir(PHARDWARE_PTE PdeBase, ULONG Index) +{ + PHARDWARE_PTE SubDir; + + if (!PdeBase) + return NULL; + + if (!PdeBase[Index].Valid) + { + SubDir = MmAllocateMemoryWithType(PAGE_SIZE, LoaderMemoryData); + if (!SubDir) + return NULL; + RtlZeroMemory(SubDir, PAGE_SIZE); + PdeBase[Index].PageFrameNumber = PtrToPfn(SubDir); + PdeBase[Index].Valid = 1; + PdeBase[Index].Write = 1; + } + else + { + SubDir = (PVOID)((ULONG64)(PdeBase[Index].PageFrameNumber) * PAGE_SIZE); + } + return SubDir; +} + +BOOLEAN +MempMapSinglePage(ULONG64 VirtualAddress, ULONG64 PhysicalAddress) +{ + PHARDWARE_PTE PpeBase, PdeBase, PteBase; + ULONG Index; + + PpeBase = MempGetOrCreatePageDir(PxeBase, VAtoPXI(VirtualAddress)); + PdeBase = MempGetOrCreatePageDir(PpeBase, VAtoPPI(VirtualAddress)); + PteBase = MempGetOrCreatePageDir(PdeBase, VAtoPDI(VirtualAddress)); + + if (!PteBase) + { + DPRINTM(DPRINT_WINDOWS,"!!!No Dir %p, %p, %p, %p\n", PxeBase, PpeBase, PdeBase, PteBase); + return FALSE; + } + + Index = VAtoPTI(VirtualAddress); + if (PteBase[Index].Valid) + { + DPRINTM(DPRINT_WINDOWS,"!!!Already mapped %ld\n", Index); + return FALSE; + } + + PteBase[Index].Valid = 1; + PteBase[Index].Write = 1; + PteBase[Index].PageFrameNumber = PhysicalAddress / PAGE_SIZE; + + return TRUE; +} + +BOOLEAN +MempIsPageMapped(PVOID VirtualAddress) +{ + PHARDWARE_PTE PpeBase, PdeBase, PteBase; + ULONG Index; + + Index = VAtoPXI(VirtualAddress); + if (!PxeBase[Index].Valid) + return FALSE; + + PpeBase = (PVOID)((ULONG64)(PxeBase[Index].PageFrameNumber) * PAGE_SIZE); + Index = VAtoPPI(VirtualAddress); + if (!PpeBase[Index].Valid) + return FALSE; + + PdeBase = (PVOID)((ULONG64)(PpeBase[Index].PageFrameNumber) * PAGE_SIZE); + Index = VAtoPDI(VirtualAddress); + if (!PdeBase[Index].Valid) + return FALSE; + + PteBase = (PVOID)((ULONG64)(PdeBase[Index].PageFrameNumber) * PAGE_SIZE); + Index = VAtoPTI(VirtualAddress); + if (!PteBase[Index].Valid) + return FALSE; + + return TRUE; +} + +ULONG +MempMapRangeOfPages(ULONG64 VirtualAddress, ULONG64 PhysicalAddress, ULONG cPages) +{ + ULONG i; + + for (i = 0; i < cPages; i++) + { + if (!MempMapSinglePage(VirtualAddress, PhysicalAddress)) + { + return i; + } + VirtualAddress += PAGE_SIZE; + PhysicalAddress += PAGE_SIZE; + } + return i; } BOOLEAN MempSetupPaging(IN ULONG StartPage, IN ULONG NumberOfPages) { + DPRINTM(DPRINT_WINDOWS,">>> MempSetupPaging(0x%lx, %ld, %p)\n", + StartPage, NumberOfPages, StartPage * PAGE_SIZE + KSEG0_BASE); + + /* Identity mapping */ + if (MempMapRangeOfPages(StartPage * PAGE_SIZE, + StartPage * PAGE_SIZE, + NumberOfPages) != NumberOfPages) + { + DPRINTM(DPRINT_WINDOWS,"Failed to map pages 1\n"); + return FALSE; + } + + /* Kernel mapping */ + if (MempMapRangeOfPages(StartPage * PAGE_SIZE + KSEG0_BASE, + StartPage * PAGE_SIZE, + NumberOfPages) != NumberOfPages) + { + DPRINTM(DPRINT_WINDOWS,"Failed to map pages 2\n"); + return FALSE; + } return TRUE; } VOID -MempDisablePages() -{ - -} - -VOID -MempAddMemoryBlock(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock, - ULONG BasePage, - ULONG PageCount, - ULONG Type) -{ - -} - -#ifdef _M_IX86 +MempUnmapPage(ULONG Page) +{ + // DPRINTM(DPRINT_WINDOWS,">>> MempUnmapPage\n"); +} + VOID WinLdrpMapApic() { - -} -#else -VOID -WinLdrpMapApic() -{ - /* Implement it for another arch */ -} -#endif - -BOOLEAN -WinLdrTurnOnPaging(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock, - ULONG PcrBasePage, - ULONG TssBasePage, - PVOID GdtIdt) -{ -return 1; -} - -// Two special things this func does: it sorts descriptors, -// and it merges free ones -VOID -WinLdrInsertDescriptor(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock, - IN PMEMORY_ALLOCATION_DESCRIPTOR NewDescriptor) -{ - -} - -VOID -WinLdrSetProcessorContext(PVOID GdtIdt, IN ULONG Pcr, IN ULONG Tss) -{ - -} - + BOOLEAN LocalAPIC; + LARGE_INTEGER MsrValue; + ULONG CpuInfo[4]; + ULONG64 APICAddress; + + DPRINTM(DPRINT_WINDOWS,">>> WinLdrpMapApic\n"); + + /* Check if we have a local APIC */ + __cpuid((int*)CpuInfo, 1); + LocalAPIC = (((CpuInfo[3] >> 9) & 1) != 0); + + /* If there is no APIC, just return */ + if (!LocalAPIC) + { + DPRINTM(DPRINT_WINDOWS,"No APIC found.\n"); + return; + } + + /* Read the APIC Address */ + MsrValue.QuadPart = __readmsr(0x1B); + APICAddress = (MsrValue.LowPart & 0xFFFFF000); + + DPRINTM(DPRINT_WINDOWS, "Local APIC detected at address 0x%x\n", + APICAddress); + + /* Map it */ + MempMapSinglePage(APIC_BASE, APICAddress); +} + +BOOLEAN +WinLdrMapSpecialPages(ULONG PcrBasePage) +{ + /* Map the PCR page */ + if (!MempMapSinglePage(KIP0PCRADDRESS, PcrBasePage * PAGE_SIZE)) + { + DPRINTM(DPRINT_WINDOWS, "Could not map PCR @ %lx\n", PcrBasePage); + return FALSE; + } + + /* Map KI_USER_SHARED_DATA */ + if (!MempMapSinglePage(KI_USER_SHARED_DATA, (PcrBasePage+1) * PAGE_SIZE)) + { + DPRINTM(DPRINT_WINDOWS, "Could not map KI_USER_SHARED_DATA\n"); + return FALSE; + } + + /* Map the APIC page */ + WinLdrpMapApic(); + + return TRUE; +} + +VOID +WinLdrSetupGdt(PVOID GdtBase, ULONG64 TssBase) +{ + PKGDTENTRY64 Entry; + KDESCRIPTOR GdtDesc; + + /* Setup KGDT_64_R0_CODE */ + Entry = KiGetGdtEntry(GdtBase, KGDT_64_R0_CODE); + *(PULONG64)Entry = 0x00209b0000000000ULL; + + /* Setup KGDT_64_R0_SS */ + Entry = KiGetGdtEntry(GdtBase, KGDT_64_R0_SS); + *(PULONG64)Entry = 0x00cf93000000ffffULL; + + /* Setup KGDT_64_DATA */ + Entry = KiGetGdtEntry(GdtBase, KGDT_64_DATA); + *(PULONG64)Entry = 0x00cff3000000ffffULL; + + /* Setup KGDT_64_R3_CODE */ + Entry = KiGetGdtEntry(GdtBase, KGDT_64_R3_CODE); + *(PULONG64)Entry = 0x0020fb0000000000ULL; + + /* Setup KGDT_32_R3_TEB */ + Entry = KiGetGdtEntry(GdtBase, KGDT_32_R3_TEB); + *(PULONG64)Entry = 0xff40f3fd50003c00ULL; + + /* Setup TSS entry */ + Entry = KiGetGdtEntry(GdtBase, KGDT_TSS); + KiInitGdtEntry(Entry, TssBase, sizeof(KTSS), I386_TSS, 0); + + /* Setup GDT descriptor */ + GdtDesc.Base = GdtBase; + GdtDesc.Limit = NUM_GDT * sizeof(KGDTENTRY) - 1; + + /* Set the new Gdt */ + __lgdt(&GdtDesc.Limit); + DbgPrint("Gdtr.Base = %p, num = %ld\n", GdtDesc.Base, NUM_GDT); + +} + +VOID +WinLdrSetupIdt(PVOID IdtBase) +{ + KDESCRIPTOR IdtDesc, OldIdt; + + /* Get old IDT */ + __sidt(&OldIdt); + + /* Copy the old IDT */ + RtlCopyMemory(IdtBase, (PVOID)OldIdt.Base, OldIdt.Limit + 1); + + /* Setup the new IDT descriptor */ + IdtDesc.Base = IdtBase; + IdtDesc.Limit = NUM_IDT * sizeof(KIDTENTRY) - 1; + + /* Set the new IDT */ + __lidt(&IdtDesc.Limit); + DbgPrint("Idtr.Base = %p\n", IdtDesc.Base); + +} + +VOID +WinLdrSetProcessorContext(PVOID GdtIdt, IN ULONG64 Pcr, IN ULONG64 Tss) +{ + DPRINTM(DPRINT_WINDOWS, "WinLdrSetProcessorContext %p\n", Pcr); + + /* Disable Interrupts */ + _disable(); + + /* Re-initalize EFLAGS */ + __writeeflags(0); + + /* Set the new PML4 */ + __writecr3((ULONG64)PxeBase); + + /* Get kernel mode address of gdt / idt */ + GdtIdt = (PVOID)((ULONG64)GdtIdt + KSEG0_BASE); + + /* Create gdt entries and load gdtr */ + WinLdrSetupGdt(GdtIdt, Tss); + + /* Copy old Idt and set idtr */ + WinLdrSetupIdt((PVOID)((ULONG64)GdtIdt + 2048)); // HACK! + + /* LDT is unused */ +// __lldt(0); + + /* Load selectors for DS/ES/FS/GS/SS */ + Ke386SetDs(KGDT_64_DATA | RPL_MASK); // 0x2b + Ke386SetEs(KGDT_64_DATA | RPL_MASK); // 0x2b + Ke386SetFs(KGDT_32_R3_TEB | RPL_MASK); // 0x53 + Ke386SetGs(KGDT_64_DATA | RPL_MASK); // 0x2b + Ke386SetSs(KGDT_64_R0_SS); // 0x18 + + /* Load TSR */ + __ltr(KGDT_TSS); + + DPRINTM(DPRINT_WINDOWS, "leave WinLdrSetProcessorContext\n"); +} + +VOID +MempDump() +{ +} + Copied: trunk/reactos/boot/freeldr/freeldr/windows/i386/wlmemory.c (from r43566, branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/windows/i386/wlmemory.c) URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/windo…
============================================================================== --- branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/windows/i386/wlmemory.c [iso-8859-1] (original) +++ trunk/reactos/boot/freeldr/freeldr/windows/i386/wlmemory.c [iso-8859-1] Sun Dec 20 14:30:35 2009 @@ -1,7 +1,7 @@ /* * PROJECT: EFI Windows Loader * LICENSE: GPL - See COPYING in the top level directory - * FILE: freeldr/winldr/wlmemory.c + * FILE: freeldr/winldr/i386/wlmemory.c * PURPOSE: Memory related routines * PROGRAMMERS: Aleksey Bragin (aleksey(a)reactos.org) */ @@ -21,52 +21,6 @@ #define KIP0PCRADDRESS 0xffdff000 #define HYPER_SPACE_ENTRY 0x300 - -PCHAR MemTypeDesc[] = { - "ExceptionBlock ", // ? - "SystemBlock ", // ? - "Free ", - "Bad ", // used - "LoadedProgram ", // == Free - "FirmwareTemporary ", // == Free - "FirmwarePermanent ", // == Bad - "OsloaderHeap ", // used - "OsloaderStack ", // == Free - "SystemCode ", - "HalCode ", - "BootDriver ", // not used - "ConsoleInDriver ", // ? - "ConsoleOutDriver ", // ? - "StartupDpcStack ", // ? - "StartupKernelStack", // ? - "StartupPanicStack ", // ? - "StartupPcrPage ", // ? - "StartupPdrPage ", // ? - "RegistryData ", // used - "MemoryData ", // not used - "NlsData ", // used - "SpecialMemory ", // == Bad - "BBTMemory " // == Bad - }; - -VOID -WinLdrpDumpMemoryDescriptors(PLOADER_PARAMETER_BLOCK LoaderBlock); - - -VOID -MempAddMemoryBlock(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock, - ULONG BasePage, - ULONG PageCount, - ULONG Type); -VOID -WinLdrInsertDescriptor(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock, - IN PMEMORY_ALLOCATION_DESCRIPTOR NewDescriptor); - -VOID -WinLdrRemoveDescriptor(IN PMEMORY_ALLOCATION_DESCRIPTOR Descriptor); - -VOID -WinLdrSetProcessorContext(PVOID GdtIdt, IN ULONG Pcr, IN ULONG Tss); // This is needed only for SetProcessorContext routine #pragma pack(2) @@ -86,10 +40,6 @@ PUCHAR KernelPageTablesBuffer; ULONG PhysicalPageTables; ULONG KernelPageTables; - -MEMORY_ALLOCATION_DESCRIPTOR *Mad; -ULONG MadCount = 0; - /* FUNCTIONS **************************************************************/ @@ -253,133 +203,24 @@ } VOID -MempDisablePages() -{ - ULONG i; - - // - // We need to delete kernel mapping from memory areas which are - // marked as Special or Permanent memory (thus non-accessible) - // - - for (i=0; i<MadCount; i++) - { - ULONG StartPage, EndPage, Page; - - StartPage = Mad[i].BasePage; - EndPage = Mad[i].BasePage + Mad[i].PageCount; - - if (Mad[i].MemoryType == LoaderFirmwarePermanent || - Mad[i].MemoryType == LoaderSpecialMemory || - Mad[i].MemoryType == LoaderFree || - (Mad[i].MemoryType == LoaderFirmwareTemporary && EndPage <= LoaderPagesSpanned) || - Mad[i].MemoryType == LoaderOsloaderStack || - Mad[i].MemoryType == LoaderLoadedProgram) - { - // - // But, the first megabyte of memory always stays! - // And, to tell the truth, we don't care about what's higher - // than LoaderPagesSpanned - if (Mad[i].MemoryType == LoaderFirmwarePermanent || - Mad[i].MemoryType == LoaderSpecialMemory) - { - if (StartPage < 0x100) - StartPage = 0x100; - - if (EndPage > LoaderPagesSpanned) - EndPage = LoaderPagesSpanned; - } - - for (Page = StartPage; Page < EndPage; Page++) - { - PHARDWARE_PTE KernelPT; - ULONG Entry = (Page >> 10) + (KSEG0_BASE >> 22); - - if (PDE[Entry].Valid) - { - KernelPT = (PHARDWARE_PTE)(PDE[Entry].PageFrameNumber << MM_PAGE_SHIFT); - - if (KernelPT) - { - KernelPT[Page & 0x3ff].PageFrameNumber = 0; - KernelPT[Page & 0x3ff].Valid = 0; - KernelPT[Page & 0x3ff].Write = 0; - } - } - } - } - } -} - -VOID -MempAddMemoryBlock(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock, - ULONG BasePage, - ULONG PageCount, - ULONG Type) -{ - BOOLEAN Status; - - // - // Check for some weird stuff at the top - // - if (BasePage + PageCount > 0xF0000) - { - // - // Just skip this, without even adding to MAD list - // - return; - } - - // - // Set Base page, page count and type - // - Mad[MadCount].BasePage = BasePage; - Mad[MadCount].PageCount = PageCount; - Mad[MadCount].MemoryType = Type; - - // - // Check if it's more than the allowed for OS loader - // if yes - don't map the pages, just add as FirmwareTemporary - // - if (BasePage + PageCount > LoaderPagesSpanned) - { - if (Mad[MadCount].MemoryType != LoaderSpecialMemory && - Mad[MadCount].MemoryType != LoaderFirmwarePermanent && - Mad[MadCount].MemoryType != LoaderFree) - { - DPRINTM(DPRINT_WINDOWS, "Setting page %x %x to Temporary from %d\n", - BasePage, PageCount, Mad[MadCount].MemoryType); - Mad[MadCount].MemoryType = LoaderFirmwareTemporary; - } - - WinLdrInsertDescriptor(LoaderBlock, &Mad[MadCount]); - MadCount++; - - return; - } - - // - // Add descriptor - // - WinLdrInsertDescriptor(LoaderBlock, &Mad[MadCount]); - MadCount++; - - // - // Map it (don't map low 1Mb because it was already contigiously - // mapped in WinLdrTurnOnPaging) - // - if (BasePage >= 0x100) - { - Status = MempSetupPaging(BasePage, PageCount); - if (!Status) - { - DPRINTM(DPRINT_WINDOWS, "Error during MempSetupPaging\n"); - return; - } - } -} - -#ifdef _M_IX86 +MempUnmapPage(ULONG Page) +{ + PHARDWARE_PTE KernelPT; + ULONG Entry = (Page >> 10) + (KSEG0_BASE >> 22); + + if (PDE[Entry].Valid) + { + KernelPT = (PHARDWARE_PTE)(PDE[Entry].PageFrameNumber << MM_PAGE_SHIFT); + + if (KernelPT) + { + KernelPT[Page & 0x3ff].PageFrameNumber = 0; + KernelPT[Page & 0x3ff].Valid = 0; + KernelPT[Page & 0x3ff].Write = 0; + } + } +} + VOID WinLdrpMapApic() { @@ -410,149 +251,10 @@ HalPageTable[(APIC_BASE - 0xFFC00000) >> MM_PAGE_SHIFT].WriteThrough = 1; HalPageTable[(APIC_BASE - 0xFFC00000) >> MM_PAGE_SHIFT].CacheDisable = 1; } -#else -VOID -WinLdrpMapApic() -{ - /* Implement it for another arch */ -} -#endif BOOLEAN -WinLdrTurnOnPaging(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock, - ULONG PcrBasePage, - ULONG TssBasePage, - PVOID GdtIdt) -{ - ULONG i, PagesCount, MemoryMapSizeInPages; - ULONG LastPageIndex, LastPageType, MemoryMapStartPage; - PPAGE_LOOKUP_TABLE_ITEM MemoryMap; - ULONG NoEntries; - PKTSS Tss; - BOOLEAN Status; - - // - // Creating a suitable memory map for the Windows can be tricky, so let's - // give a few advices: - // 1) One must not map the whole available memory pages to PDE! - // Map only what's needed - 16Mb, 24Mb, 32Mb max I think, - // thus occupying 4, 6 or 8 PDE entries for identical mapping, - // the same quantity for KSEG0_BASE mapping, one more entry for - // hyperspace and one more entry for HAL physical pages mapping. - // 2) Memory descriptors must map *the whole* physical memory - // showing any memory above 16/24/32 as FirmwareTemporary - // - // 3) Overall memory blocks count must not exceed 30 (?? why?) - // - - // - // During MmInitMachineDependent, the kernel zeroes PDE at the following address - // 0xC0300000 - 0xC03007FC - // - // Then it finds the best place for non-paged pool: - // StartPde C0300F70, EndPde C0300FF8, NumberOfPages C13, NextPhysPage 3AD - // - - // Before we start mapping pages, create a block of memory, which will contain - // PDE and PTEs - if (MempAllocatePageTables() == FALSE) - return FALSE; - - // Allocate memory for memory allocation descriptors - Mad = MmHeapAlloc(sizeof(MEMORY_ALLOCATION_DESCRIPTOR) * 1024); - - // Setup an entry for each descriptor - MemoryMap = MmGetMemoryMap(&NoEntries); - if (MemoryMap == NULL) - { - UiMessageBox("Can not retrieve the current memory map"); - return FALSE; - } - - // Calculate parameters of the memory map - MemoryMapStartPage = (ULONG_PTR)MemoryMap >> MM_PAGE_SHIFT; - MemoryMapSizeInPages = NoEntries * sizeof(PAGE_LOOKUP_TABLE_ITEM); - - DPRINTM(DPRINT_WINDOWS, "Got memory map with %d entries\n", NoEntries); - - // Always contigiously map low 1Mb of memory - Status = MempSetupPaging(0, 0x100); - if (!Status) - { - DPRINTM(DPRINT_WINDOWS, "Error during MempSetupPaging of low 1Mb\n"); - return FALSE; - } - - // Construct a good memory map from what we've got, - // but mark entries which the memory allocation bitmap takes - // as free entries (this is done in order to have the ability - // to place mem alloc bitmap outside lower 16Mb zone) - PagesCount = 1; - LastPageIndex = 0; - LastPageType = MemoryMap[0].PageAllocated; - for(i=1;i<NoEntries;i++) - { - // Check if its memory map itself - if (i >= MemoryMapStartPage && - i < (MemoryMapStartPage+MemoryMapSizeInPages)) - { - // Exclude it if current page belongs to the memory map - MemoryMap[i].PageAllocated = LoaderFree; - } - - // Process entry - if (MemoryMap[i].PageAllocated == LastPageType && - (i != NoEntries-1) ) - { - PagesCount++; - } - else - { - // Add the resulting region - MempAddMemoryBlock(LoaderBlock, LastPageIndex, PagesCount, LastPageType); - - // Reset our counter vars - LastPageIndex = i; - LastPageType = MemoryMap[i].PageAllocated; - PagesCount = 1; - } - } - - // TEMP, DEBUG! - // adding special reserved memory zones for vmware workstation -#if 0 - { - Mad[MadCount].BasePage = 0xfec00; - Mad[MadCount].PageCount = 0x10; - Mad[MadCount].MemoryType = LoaderSpecialMemory; - WinLdrInsertDescriptor(LoaderBlock, &Mad[MadCount]); - MadCount++; - - Mad[MadCount].BasePage = 0xfee00; - Mad[MadCount].PageCount = 0x1; - Mad[MadCount].MemoryType = LoaderSpecialMemory; - WinLdrInsertDescriptor(LoaderBlock, &Mad[MadCount]); - MadCount++; - - Mad[MadCount].BasePage = 0xfffe0; - Mad[MadCount].PageCount = 0x20; - Mad[MadCount].MemoryType = LoaderSpecialMemory; - WinLdrInsertDescriptor(LoaderBlock, &Mad[MadCount]); - MadCount++; - } -#endif - - DPRINTM(DPRINT_WINDOWS, "MadCount: %d\n", MadCount); - - WinLdrpDumpMemoryDescriptors(LoaderBlock); //FIXME: Delete! - - // Map our loader image, so we can continue running - /*Status = MempSetupPaging(OsLoaderBase >> MM_PAGE_SHIFT, OsLoaderSize >> MM_PAGE_SHIFT); - if (!Status) - { - UiMessageBox("Error during MempSetupPaging"); - return; - }*/ +WinLdrMapSpecialPages(ULONG PcrBasePage) +{ //VideoDisplayString(L"Hello from VGA, going into the kernel\n"); DPRINTM(DPRINT_WINDOWS, "HalPageTable: 0x%X\n", HalPageTable); @@ -574,127 +276,9 @@ //VideoMemoryBase = MmMapIoSpace(0xb8000, 4000, MmNonCached); //DPRINTM(DPRINT_WINDOWS, "VideoMemoryBase: 0x%X\n", VideoMemoryBase); - Tss = (PKTSS)(KSEG0_BASE | (TssBasePage << MM_PAGE_SHIFT)); - - // Unmap what is not needed from kernel page table - MempDisablePages(); - - // Fill the memory descriptor list and - //PrepareMemoryDescriptorList(); - DPRINTM(DPRINT_WINDOWS, "Memory Descriptor List prepared, printing PDE\n"); - List_PaToVa(&LoaderBlock->MemoryDescriptorListHead); - -#if DBG - { - ULONG *PDE_Addr=(ULONG *)PDE;//0xC0300000; - int j; - - DPRINTM(DPRINT_WINDOWS, "\nPDE\n"); - - for (i=0; i<128; i++) - { - DPRINTM(DPRINT_WINDOWS, "0x%04X | ", i*8); - - for (j=0; j<8; j++) - { - DPRINTM(DPRINT_WINDOWS, "0x%08X ", PDE_Addr[i*8+j]); - } - - DPRINTM(DPRINT_WINDOWS, "\n"); - } - } -#endif - - - // Enable paging - //BS->ExitBootServices(ImageHandle,MapKey); - - // Disable Interrupts - _disable(); - - // Re-initalize EFLAGS - __writeeflags(0); - - // Set the PDBR - __writecr3((ULONG_PTR)PDE); - - // Enable paging by modifying CR0 - __writecr0(__readcr0() | CR0_PG); - - // Set processor context - WinLdrSetProcessorContext(GdtIdt, KIP0PCRADDRESS, KSEG0_BASE | (TssBasePage << MM_PAGE_SHIFT)); - - // Zero KI_USER_SHARED_DATA page - memset((PVOID)KI_USER_SHARED_DATA, 0, MM_PAGE_SIZE); - - return TRUE; -} - -// Two special things this func does: it sorts descriptors, -// and it merges free ones -VOID -WinLdrInsertDescriptor(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock, - IN PMEMORY_ALLOCATION_DESCRIPTOR NewDescriptor) -{ - PLIST_ENTRY ListHead = &LoaderBlock->MemoryDescriptorListHead; - PLIST_ENTRY PreviousEntry, NextEntry; - PMEMORY_ALLOCATION_DESCRIPTOR PreviousDescriptor = NULL, NextDescriptor = NULL; - - DPRINTM(DPRINT_WINDOWS, "BP=0x%X PC=0x%X %s\n", NewDescriptor->BasePage, - NewDescriptor->PageCount, MemTypeDesc[NewDescriptor->MemoryType]); - - /* Find a place where to insert the new descriptor to */ - PreviousEntry = ListHead; - NextEntry = ListHead->Flink; - while (NextEntry != ListHead) - { - NextDescriptor = CONTAINING_RECORD(NextEntry, - MEMORY_ALLOCATION_DESCRIPTOR, - ListEntry); - if (NewDescriptor->BasePage < NextDescriptor->BasePage) - break; - - PreviousEntry = NextEntry; - PreviousDescriptor = NextDescriptor; - NextEntry = NextEntry->Flink; - } - - /* Don't forget about merging free areas */ - if (NewDescriptor->MemoryType != LoaderFree) - { - /* Just insert, nothing to merge */ - InsertHeadList(PreviousEntry, &NewDescriptor->ListEntry); - } - else - { - /* Previous block also free? */ - if ((PreviousEntry != ListHead) && (PreviousDescriptor->MemoryType == LoaderFree) && - ((PreviousDescriptor->BasePage + PreviousDescriptor->PageCount) == - NewDescriptor->BasePage)) - { - /* Just enlarge previous descriptor's PageCount */ - PreviousDescriptor->PageCount += NewDescriptor->PageCount; - NewDescriptor = PreviousDescriptor; - } - else - { - /* Nope, just insert */ - InsertHeadList(PreviousEntry, &NewDescriptor->ListEntry); - } - - /* Next block is free ?*/ - if ((NextEntry != ListHead) && - (NextDescriptor->MemoryType == LoaderFree) && - ((NewDescriptor->BasePage + NewDescriptor->PageCount) == NextDescriptor->BasePage)) - { - /* Enlarge next descriptor's PageCount */ - NewDescriptor->PageCount += NextDescriptor->PageCount; - RemoveEntryList(&NextDescriptor->ListEntry); - } - } - - return; -} + return TRUE; +} + VOID WinLdrSetProcessorContext(PVOID GdtIdt, IN ULONG Pcr, IN ULONG Tss) @@ -707,6 +291,21 @@ DPRINTM(DPRINT_WINDOWS, "GDtIdt %p, Pcr %p, Tss 0x%08X\n", GdtIdt, Pcr, Tss); + + // Enable paging + //BS->ExitBootServices(ImageHandle,MapKey); + + // Disable Interrupts + _disable(); + + // Re-initalize EFLAGS + __writeeflags(0); + + // Set the PDBR + __writecr3((ULONG_PTR)PDE); + + // Enable paging by modifying CR0 + __writecr0(__readcr0() | CR0_PG); // Kernel expects the PCR to be zero-filled on startup // FIXME: Why zero it here when we can zero it right after allocation? @@ -937,3 +536,25 @@ ret */ } + +VOID +MempDump() +{ + ULONG *PDE_Addr=(ULONG *)PDE;//0xC0300000; + int i, j; + + DPRINTM(DPRINT_WINDOWS, "\nPDE\n"); + + for (i=0; i<128; i++) + { + DPRINTM(DPRINT_WINDOWS, "0x%04X | ", i*8); + + for (j=0; j<8; j++) + { + DPRINTM(DPRINT_WINDOWS, "0x%08X ", PDE_Addr[i*8+j]); + } + + DPRINTM(DPRINT_WINDOWS, "\n"); + } +} + Modified: trunk/reactos/boot/freeldr/freeldr/windows/peloader.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/windo…
============================================================================== --- trunk/reactos/boot/freeldr/freeldr/windows/peloader.c [iso-8859-1] (original) +++ trunk/reactos/boot/freeldr/freeldr/windows/peloader.c [iso-8859-1] Sun Dec 20 14:30:35 2009 @@ -413,7 +413,7 @@ if (SizeOfRawData < VirtualSize) { DPRINTM(DPRINT_PELOADER, "WinLdrLoadImage(): SORD %d < VS %d\n", SizeOfRawData, VirtualSize); - RtlZeroMemory((PVOID)(SectionHeader->VirtualAddress + (ULONG)PhysicalBase + SizeOfRawData), VirtualSize - SizeOfRawData); + RtlZeroMemory((PVOID)(SectionHeader->VirtualAddress + (ULONG_PTR)PhysicalBase + SizeOfRawData), VirtualSize - SizeOfRawData); } SectionHeader++; @@ -428,7 +428,7 @@ /* Relocate the image, if it needs it */ - if (NtHeaders->OptionalHeader.ImageBase != (ULONG)VirtualBase) + if (NtHeaders->OptionalHeader.ImageBase != (ULONG_PTR)VirtualBase) { DPRINTM(DPRINT_PELOADER, "Relocating %p -> %p\n", NtHeaders->OptionalHeader.ImageBase, VirtualBase); @@ -535,7 +535,7 @@ /* AddressOfData in thunk entry will become a virtual address (from relative) */ //DPRINTM(DPRINT_PELOADER, "WinLdrpBindImportName(): ThunkData->u1.AOD was %p\n", ThunkData->u1.AddressOfData); ThunkData->u1.AddressOfData = - (ULONG)RVA(ImageBase, ThunkData->u1.AddressOfData); + (ULONG_PTR)RVA(ImageBase, ThunkData->u1.AddressOfData); //DPRINTM(DPRINT_PELOADER, "WinLdrpBindImportName(): ThunkData->u1.AOD became %p\n", ThunkData->u1.AddressOfData); } @@ -637,11 +637,11 @@ FunctionTable = (PULONG)VaToPa(RVA(DllBase, ExportDirectory->AddressOfFunctions)); /* Save a pointer to the function */ - ThunkData->u1.Function = (ULONG)RVA(DllBase, FunctionTable[Ordinal]); + ThunkData->u1.Function = (ULONG_PTR)RVA(DllBase, FunctionTable[Ordinal]); /* Is it a forwarder? (function pointer isn't within the export directory) */ - if (((ULONG)VaToPa((PVOID)ThunkData->u1.Function) > (ULONG)ExportDirectory) && - ((ULONG)VaToPa((PVOID)ThunkData->u1.Function) < ((ULONG)ExportDirectory + ExportSize))) + if (((ULONG_PTR)VaToPa((PVOID)ThunkData->u1.Function) > (ULONG_PTR)ExportDirectory) && + ((ULONG_PTR)VaToPa((PVOID)ThunkData->u1.Function) < ((ULONG_PTR)ExportDirectory + ExportSize))) { PLDR_DATA_TABLE_ENTRY DataTableEntry; CHAR ForwardDllName[255]; @@ -692,7 +692,7 @@ ImportByName->Hint = 0; /* And finally point ThunkData's AddressOfData to that structure */ - RefThunkData.u1.AddressOfData = (ULONG)ImportByName; + RefThunkData.u1.AddressOfData = (ULONG_PTR)ImportByName; /* And recursively call ourselves */ Status = WinLdrpBindImportName( Modified: trunk/reactos/boot/freeldr/freeldr/windows/winldr.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/windo…
============================================================================== --- trunk/reactos/boot/freeldr/freeldr/windows/winldr.c [iso-8859-1] (original) +++ trunk/reactos/boot/freeldr/freeldr/windows/winldr.c [iso-8859-1] Sun Dec 20 14:30:35 2009 @@ -417,7 +417,7 @@ PCHAR PathSeparator; PVOID NtosBase = NULL, HalBase = NULL, KdComBase = NULL; BOOLEAN Status; - ULONG SectionId; + ULONG_PTR SectionId; PLOADER_PARAMETER_BLOCK LoaderBlock, LoaderBlockVA; KERNEL_ENTRY_POINT KiSystemStartup; PLDR_DATA_TABLE_ENTRY KernelDTE, HalDTE, KdComDTE = NULL; Copied: trunk/reactos/boot/freeldr/freeldr/windows/wlmemory.c (from r43598, branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/windows/wlmemory.c) URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/windo…
============================================================================== --- branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/windows/wlmemory.c [iso-8859-1] (original) +++ trunk/reactos/boot/freeldr/freeldr/windows/wlmemory.c [iso-8859-1] Sun Dec 20 14:30:35 2009 @@ -14,10 +14,6 @@ #include <debug.h> extern ULONG LoaderPagesSpanned; - -// This is needed because headers define wrong one for ReactOS -#undef KIP0PCRADDRESS -#define KIP0PCRADDRESS 0xffdff000 PCHAR MemTypeDesc[] = { "ExceptionBlock ", // ? @@ -63,7 +59,7 @@ WinLdrRemoveDescriptor(IN PMEMORY_ALLOCATION_DESCRIPTOR Descriptor); VOID -WinLdrSetProcessorContext(PVOID GdtIdt, IN ULONG Pcr, IN ULONG Tss); +WinLdrSetProcessorContext(PVOID GdtIdt, IN ULONG_PTR Pcr, IN ULONG_PTR Tss); BOOLEAN MempAllocatePageTables(); Propchange: trunk/reactos/dll/directx/d3d8/d3d8.spec ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Sun Dec 20 14:30:35 2009 @@ -1,1 +1,1 @@ -/branches/ros-amd64-bringup/reactos/dll/directx/d3d8/d3d8.spec:35683,35762,35777,35827,36172,36445,36502-36503,36505,36899,36930,36936,38148-38151,38264-38265,38268,38355,39333,39345,40122-40123,40125,40128,40155,40753,40928,40986-40987,40989,40991,40993,40995-40996,41000-41001,41027-41029,41044-41045,41047-41050,41052,41082-41086,41097-41098,41101,41449,41484,41549,43080,43506,43839-43840,43857-43858,43860,43905-43907,44002,44037,44039-44040,44044-44045,44294,44338,44389,44391,44460,44601 +/branches/ros-amd64-bringup/reactos/dll/directx/d3d8/d3d8.spec:35683,35762,35777,35827,36172,36445,36502-36503,36505,36899,36930,36936,38148-38151,38264-38265,38268,38355,39333,39345,39639,40122-40123,40125,40128,40155,40247,40324,40753,40928,40986-40987,40989,40991,40993,40995-40996,41000-41001,41027-41029,41044-41045,41047-41050,41052,41082-41086,41097-41098,41101,41449,41484,41549,43080,43506,43566,43574,43598,43600-43602,43604-43605,43757,43775,43839-43840,43857-43858,43860,43905-43907,44002,44037,44039-44040,44044-44045,44065,44095,44123,44144,44205,44294,44338,44389,44391,44426,44460,44530,44540,44601 Propchange: trunk/reactos/dll/directx/dsound_new/classfactory.c ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Sun Dec 20 14:30:35 2009 @@ -1,2 +1,2 @@ -/branches/ros-amd64-bringup/reactos/dll/directx/dsound_new/classfactory.c:35683,35762,35777,35827,36172,36502-36503,36505,36936,38149-38150,38264,38355,40122-40123,40125,40155,40753,40986-40987,40989,40993,40995-40996,41001,41029,41044-41045,41047-41049,41098,41101,41449,41484,43506,43839-43840,43857,43860,43905,43907,44037,44039-44040,44044-44045,44294,44338,44389,44391,44460,44601 +/branches/ros-amd64-bringup/reactos/dll/directx/dsound_new/classfactory.c:35683,35762,35777,35827,36172,36502-36503,36505,36936,38149-38150,38264,38355,39639,40122-40123,40125,40155,40247,40324,40753,40986-40987,40989,40993,40995-40996,41001,41029,41044-41045,41047-41049,41098,41101,41449,41484,43506,43566,43574,43598,43600-43602,43604-43605,43757,43775,43839-43840,43857,43860,43905,43907,44037,44039-44040,44044-44045,44065,44095,44123,44144,44205,44294,44338,44389,44391,44426,44460,44530,44540,44601 /branches/ros-amd64-bringup/reactos/dll/win32/netshell/classfactory.c:34711-34712,34743,34812,34839,34842,34917,35323-35324,35347-35348,35361,35436,35509,35515,35588,35739,35746,35771,35789,35823,35902,35904-35906,35942,35947-35949,35952-35953,35966,36013,36360,36388-36389,36570,36614,36930,37323,37434,37472,37475,37536,37820-37821,37868-37869,37873,37990-37991,38013-38014,38148,38151,38265,38268,39151,39333,39345,40991,41000,41027-41028,41030,41050,41052,41082-41086,41499,41549,43080,43426,43454,43677,43682 Propchange: trunk/reactos/dll/directx/dsound_new/dsound.spec ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Sun Dec 20 14:30:35 2009 @@ -1,2 +1,2 @@ /branches/ros-amd64-bringup/reactos/dll/directx/dsound/dsound.spec:34711-34712,34743,34812,34839,34842,34917,35323-35324,35347-35348,35361,35436,35509,35515,35588,35739,35746,35771,35789,35823,35902,35904-35906,35942,35947-35949,35952-35953,35966,36013,36360,36388-36389,36570,36614,36930,37323,37434,37472,37475,37536,37820-37821,37868-37869,37873,37990-37991,38013-38014,38148,38151,38265,38268,39151,39333,39345,40991,41000,41027-41028,41030,41050,41052,41082-41086,41499,41549,43080,43426,43454,43677,43682 -/branches/ros-amd64-bringup/reactos/dll/directx/dsound_new/dsound.spec:35683,35762,35777,35827,36172,36502-36503,36505,36936,38149-38150,38264,38355,40122-40123,40125,40155,40753,40986-40987,40989,40993,40995-40996,41001,41029,41044-41045,41047-41049,41098,41101,41449,41484,43506,43839-43840,43857,43860,43905,43907,44037,44039-44040,44044-44045,44294,44338,44389,44391,44460,44601 +/branches/ros-amd64-bringup/reactos/dll/directx/dsound_new/dsound.spec:35683,35762,35777,35827,36172,36502-36503,36505,36936,38149-38150,38264,38355,39639,40122-40123,40125,40155,40247,40324,40753,40986-40987,40989,40993,40995-40996,41001,41029,41044-41045,41047-41049,41098,41101,41449,41484,43506,43566,43574,43598,43600-43602,43604-43605,43757,43775,43839-43840,43857,43860,43905,43907,44037,44039-44040,44044-44045,44065,44095,44123,44144,44205,44294,44338,44389,44391,44426,44460,44530,44540,44601 Propchange: trunk/reactos/dll/directx/dsound_new/regsvr.c ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Sun Dec 20 14:30:35 2009 @@ -1,2 +1,2 @@ /branches/ros-amd64-bringup/reactos/dll/directx/dsound/regsvr.c:34711-34712,34743,34812,34839,34842,34917,35323-35324,35347-35348,35361,35436,35509,35515,35588,35739,35746,35771,35789,35823,35902,35904-35906,35942,35947-35949,35952-35953,35966,36013,36360,36388-36389,36570,36614,36930,37323,37434,37472,37475,37536,37820-37821,37868-37869,37873,37990-37991,38013-38014,38148,38151,38265,38268,39151,39333,39345,40991,41000,41027-41028,41030,41050,41052,41082-41086,41499,41549,43080,43426,43454,43677,43682 -/branches/ros-amd64-bringup/reactos/dll/directx/dsound_new/regsvr.c:35683,35762,35777,35827,36172,36502-36503,36505,36936,38149-38150,38264,38355,40122-40123,40125,40155,40753,40986-40987,40989,40993,40995-40996,41001,41029,41044-41045,41047-41049,41098,41101,41449,41484,43506,43839-43840,43857,43860,43905,43907,44037,44039-44040,44044-44045,44294,44338,44389,44391,44460,44601 +/branches/ros-amd64-bringup/reactos/dll/directx/dsound_new/regsvr.c:35683,35762,35777,35827,36172,36502-36503,36505,36936,38149-38150,38264,38355,39639,40122-40123,40125,40155,40247,40324,40753,40986-40987,40989,40993,40995-40996,41001,41029,41044-41045,41047-41049,41098,41101,41449,41484,43506,43566,43574,43598,43600-43602,43604-43605,43757,43775,43839-43840,43857,43860,43905,43907,44037,44039-44040,44044-44045,44065,44095,44123,44144,44205,44294,44338,44389,44391,44426,44460,44530,44540,44601 Propchange: trunk/reactos/dll/shellext/devcpux/devcpux.spec ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Sun Dec 20 14:30:35 2009 @@ -1,1 +1,1 @@ -/branches/ros-amd64-bringup/reactos/dll/shellext/devcpux/devcpux.spec:35683,35762,35777,35827,36172,36445,36502-36503,36505,36899,36936,38149-38150,38264,38268,38355,39333,39345,40122-40123,40125,40128,40155,40753,40928,40986-40987,40989,40991,40993,40995-40996,41000-41001,41027-41029,41044-41045,41047-41050,41052,41082-41086,41097-41098,41101,41449,41484,41549,43080,43506,43839-43840,43857-43858,43860,43905-43907,44002,44037,44039-44040,44044-44045,44294,44338,44389,44391,44460,44601 +/branches/ros-amd64-bringup/reactos/dll/shellext/devcpux/devcpux.spec:35683,35762,35777,35827,36172,36445,36502-36503,36505,36899,36936,38149-38150,38264,38268,38355,39333,39345,39639,40122-40123,40125,40128,40155,40247,40324,40753,40928,40986-40987,40989,40991,40993,40995-40996,41000-41001,41027-41029,41044-41045,41047-41050,41052,41082-41086,41097-41098,41101,41449,41484,41549,43080,43506,43566,43574,43598,43600-43602,43604-43605,43757,43775,43839-43840,43857-43858,43860,43905-43907,44002,44037,44039-44040,44044-44045,44065,44095,44123,44144,44205,44294,44338,44389,44391,44426,44460,44530,44540,44601 Propchange: trunk/reactos/dll/shellext/slayer/slayer.spec ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Sun Dec 20 14:30:35 2009 @@ -1,1 +1,1 @@ -/branches/ros-amd64-bringup/reactos/dll/shellext/slayer/slayer.spec:35683,35762,35777,35827,36172,36445,36502-36503,36505,36899,36936,38149-38150,38264,38268,38355,39333,39345,40122-40123,40125,40128,40155,40753,40928,40986-40987,40989,40991,40993,40995-40996,41000-41001,41027-41029,41044-41045,41047-41050,41052,41082-41086,41097-41098,41101,41449,41484,41549,43080,43506,43839-43840,43857-43858,43860,43905-43907,44002,44037,44039-44040,44044-44045,44294,44338,44389,44391,44460,44601 +/branches/ros-amd64-bringup/reactos/dll/shellext/slayer/slayer.spec:35683,35762,35777,35827,36172,36445,36502-36503,36505,36899,36936,38149-38150,38264,38268,38355,39333,39345,39639,40122-40123,40125,40128,40155,40247,40324,40753,40928,40986-40987,40989,40991,40993,40995-40996,41000-41001,41027-41029,41044-41045,41047-41050,41052,41082-41086,41097-41098,41101,41449,41484,41549,43080,43506,43566,43574,43598,43600-43602,43604-43605,43757,43775,43839-43840,43857-43858,43860,43905-43907,44002,44037,44039-44040,44044-44045,44065,44095,44123,44144,44205,44294,44338,44389,44391,44426,44460,44530,44540,44601 Propchange: trunk/reactos/include/ndk/amd64/ ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Sun Dec 20 14:30:35 2009 @@ -1,1 +1,1 @@ -/branches/ros-amd64-bringup/reactos/include/ndk/amd64:34925,34967,34970,35323-35324,35347-35348,35361,35436,35509,35588,35683,35739,35762,35777,35823,35827,35952,35966,36172,36360,36445,36502-36503,36505,36899,36936,37323,37434,37472,37475,37536,37820-37821,37868-37869,37990,38013-38014,38149-38150,38264,38355,39338,39347,40088,40122-40123,40125,40128,40155,40753,40928,40986-40987,40989,40993,40995-40996,41001,41029-41030,41044-41045,41047-41049,41071,41097-41098,41101,41449,41484,43426,43447,43454,43506,43777,43839-43840,43857-43858,43860,43905-43907,44002,44037,44039-44040,44044-44045,44178,44218,44294,44338,44389,44391,44460,44491,44500,44601,44623,44631 +/branches/ros-amd64-bringup/reactos/include/ndk/amd64:34925,34967,34970,35323-35324,35347-35348,35361,35436,35509,35588,35683,35739,35762,35777,35823,35827,35952,35966,36172,36360,36445,36502-36503,36505,36899,36936,37323,37434,37472,37475,37536,37820-37821,37868-37869,37990,38013-38014,38149-38150,38264,38355,39338,39347,39639,40088,40122-40123,40125,40128,40155,40247,40324,40753,40928,40986-40987,40989,40993,40995-40996,41001,41029-41030,41044-41045,41047-41049,41071,41097-41098,41101,41449,41484,43426,43447,43454,43506,43566,43574,43598,43600-43602,43604-43605,43757,43775,43777,43839-43840,43857-43858,43860,43905-43907,44002,44037,44039-44040,44044-44045,44065,44095,44123,44144,44178,44205,44218,44294,44338,44389,44391,44426,44460,44491,44500,44530,44540,44601,44623,44631 Propchange: trunk/reactos/include/ndk/amd64/asmmacro.S ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Sun Dec 20 14:30:35 2009 @@ -1,1 +1,1 @@ -/branches/ros-amd64-bringup/reactos/include/ndk/amd64/asmmacro.S:35683,35762,35777,35827,36172,36445,36502-36503,36505,36899,36936,37475,37536,37820-37821,37868-37869,37990,38013-38014,38149-38150,38264,38355,39338,39347,40088,40122-40123,40125,40128,40155,40753,40928,40986-40987,40989,40993,40995-40996,41001,41029-41030,41044-41045,41047-41049,41071,41097-41098,41101,41449,41484,43426,43447,43454,43506,43777,43839-43840,43857-43858,43860,43905-43907,44002,44037,44039-44040,44044-44045,44178,44218,44294,44338,44389,44391,44460,44491,44500,44601,44623,44631 +/branches/ros-amd64-bringup/reactos/include/ndk/amd64/asmmacro.S:35683,35762,35777,35827,36172,36445,36502-36503,36505,36899,36936,37475,37536,37820-37821,37868-37869,37990,38013-38014,38149-38150,38264,38355,39338,39347,39639,40088,40122-40123,40125,40128,40155,40247,40324,40753,40928,40986-40987,40989,40993,40995-40996,41001,41029-41030,41044-41045,41047-41049,41071,41097-41098,41101,41449,41484,43426,43447,43454,43506,43566,43574,43598,43600-43602,43604-43605,43757,43775,43777,43839-43840,43857-43858,43860,43905-43907,44002,44037,44039-44040,44044-44045,44065,44095,44123,44144,44178,44205,44218,44294,44338,44389,44391,44426,44460,44491,44500,44530,44540,44601,44623,44631 Propchange: trunk/reactos/lib/sdk/crt/time/ ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Sun Dec 20 14:30:35 2009 @@ -1,3 +1,3 @@ -/branches/ros-amd64-bringup/reactos/lib/sdk/crt/time:35683,35762,35777,35827,36172,36445,36502-36503,36505,36899,36936,38149-38150,38264,38268,38355,40122-40123,40125,40128,40155,40753,40928,40986-40987,40989,40993,40995-40996,41001,41028-41029,41044-41045,41047-41049,41097-41098,41101,41449,41484,43506,43839-43840,43857-43858,43860,43905-43907,44002,44037,44039-44040,44044-44045,44294,44338,44389,44391,44460,44601 +/branches/ros-amd64-bringup/reactos/lib/sdk/crt/time:35683,35762,35777,35827,36172,36445,36502-36503,36505,36899,36936,38149-38150,38264,38268,38355,39639,40122-40123,40125,40128,40155,40247,40324,40753,40928,40986-40987,40989,40993,40995-40996,41001,41028-41029,41044-41045,41047-41049,41097-41098,41101,41449,41484,43506,43566,43574,43598,43600-43602,43604-43605,43757,43775,43839-43840,43857-43858,43860,43905-43907,44002,44037,44039-44040,44044-44045,44065,44095,44123,44144,44205,44294,44338,44389,44391,44426,44460,44530,44540,44601 /branches/ros-amd64-bringup/reactos/lib/sdk/crt/time_new:42414 /trunk/reactos/lib/sdk/crt/time_new:39350-42241 Modified: trunk/reactos/ntoskrnl/include/internal/arm/ke.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
============================================================================== --- trunk/reactos/ntoskrnl/include/internal/arm/ke.h [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/include/internal/arm/ke.h [iso-8859-1] Sun Dec 20 14:30:35 2009 @@ -71,6 +71,23 @@ KeArmInvalidateTlbEntry(Address); } +FORCEINLINE +VOID +KeFlushProcessTb(VOID) +{ + // + // We need to implement this! + // + ASSERTMSG("Need ARM flush routine\n", FALSE); +} + +FORCEINLINE +VOID +KiRundownThread(IN PKTHREAD Thread) +{ + /* FIXME */ +} + VOID KiPassiveRelease( VOID Modified: trunk/reactos/ntoskrnl/include/internal/i386/ke.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
============================================================================== --- trunk/reactos/ntoskrnl/include/internal/i386/ke.h [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/include/internal/i386/ke.h [iso-8859-1] Sun Dec 20 14:30:35 2009 @@ -75,6 +75,39 @@ { /* Invalidate the TLB entry for this address */ __invlpg(Address); +} + +FORCEINLINE +VOID +KeFlushProcessTb(VOID) +{ + /* Flush the TLB by resetting CR3 */ + __writecr3(__readcr3()); +} + +FORCEINLINE +PRKTHREAD +KeGetCurrentThread(VOID) +{ + /* Return the current thread */ + return ((PKIPCR)KeGetPcr())->PrcbData.CurrentThread; +} + +FORCEINLINE +VOID +KiRundownThread(IN PKTHREAD Thread) +{ +#ifndef CONFIG_SMP + /* Check if this is the NPX Thread */ + if (KeGetCurrentPrcb()->NpxThread == Thread) + { + /* Clear it */ + KeGetCurrentPrcb()->NpxThread = NULL; + Ke386FnInit(); + } +#else + /* Nothing to do */ +#endif } VOID Modified: trunk/reactos/ntoskrnl/include/internal/ke_x.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
============================================================================== --- trunk/reactos/ntoskrnl/include/internal/ke_x.h [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/include/internal/ke_x.h [iso-8859-1] Sun Dec 20 14:30:35 2009 @@ -8,19 +8,6 @@ #ifndef _M_ARM FORCEINLINE -PRKTHREAD -KeGetCurrentThread(VOID) -{ -#ifdef _M_IX86 - /* Return the current thread */ - return ((PKIPCR)KeGetPcr())->PrcbData.CurrentThread; -#else - PKPRCB Prcb = KeGetCurrentPrcb(); - return Prcb->CurrentThread; -#endif -} - -FORCEINLINE UCHAR KeGetPreviousMode(VOID) { @@ -28,23 +15,6 @@ return KeGetCurrentThread()->PreviousMode; } #endif - -FORCEINLINE -VOID -KeFlushProcessTb(VOID) -{ - /* Flush the TLB by resetting CR3 */ -#ifdef _M_PPC - __asm__("sync\n\tisync\n\t"); -#elif _M_ARM - // - // We need to implement this! - // - ASSERTMSG("Need ARM flush routine\n", FALSE); -#else - __writecr3(__readcr3()); -#endif -} // // Enters a Guarded Region @@ -302,21 +272,6 @@ FORCEINLINE VOID -KiRundownThread(IN PKTHREAD Thread) -{ -#if defined(_M_IX86) || defined(_M_AMD64) - /* Check if this is the NPX Thread */ - if (KeGetCurrentPrcb()->NpxThread == Thread) - { - /* Clear it */ - KeGetCurrentPrcb()->NpxThread = NULL; - Ke386FnInit(); - } -#endif -} - -FORCEINLINE -VOID KiRequestApcInterrupt(IN BOOLEAN NeedApc, IN UCHAR Processor) { @@ -655,14 +610,6 @@ { /* Scan the deferred ready lists if required */ if (Prcb->DeferredReadyListHead.Next) KiProcessDeferredReadyList(Prcb); -} - -FORCEINLINE -VOID -KiRundownThread(IN PKTHREAD Thread) -{ - /* Nothing to do */ - return; } FORCEINLINE Modified: trunk/reactos/ntoskrnl/include/internal/powerpc/ke.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
============================================================================== --- trunk/reactos/ntoskrnl/include/internal/powerpc/ke.h [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/include/internal/powerpc/ke.h [iso-8859-1] Sun Dec 20 14:30:35 2009 @@ -77,6 +77,29 @@ return (struct _KPCR *)__readfsdword(0x1c); } +FORCEINLINE +VOID +KeFlushProcessTb(VOID) +{ + /* Flush the TLB */ + __asm__("sync\n\tisync\n\t"); +} + +FORCEINLINE +PRKTHREAD +KeGetCurrentThread(VOID) +{ + /* Return the current thread */ + return KeGetCurrentPrcb()->CurrentThread; +} + +FORCEINLINE +VOID +KiRundownThread(IN PKTHREAD Thread) +{ + /* FIXME */ +} + #ifdef _NTOSKRNL_ /* FIXME: Move flags above to NDK instead of here */ VOID NTAPI Propchange: trunk/reactos/subsystems/win32/win32k/include/engobjects.h ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Sun Dec 20 14:30:35 2009 @@ -1,1 +1,1 @@ -/branches/ros-amd64-bringup/reactos/subsystems/win32/win32k/include/engobjects.h:35683,35762,35777,35827,36172,36445,36502-36503,36505,36899,36936,38149-38150,38264,38268,38355,40095,40122-40123,40125,40128,40155,40753,40928,40986-40987,40989,40993,40995-40996,41001,41028-41029,41044-41045,41047-41049,41097-41098,41101,41449,41484,43506,43839-43840,43857-43858,43860,43905-43907,44002,44037,44039-44040,44044-44045,44294,44338,44389,44391,44460,44601 +/branches/ros-amd64-bringup/reactos/subsystems/win32/win32k/include/engobjects.h:35683,35762,35777,35827,36172,36445,36502-36503,36505,36899,36936,38149-38150,38264,38268,38355,39639,40095,40122-40123,40125,40128,40155,40247,40324,40753,40928,40986-40987,40989,40993,40995-40996,41001,41028-41029,41044-41045,41047-41049,41097-41098,41101,41449,41484,43506,43566,43574,43598,43600-43602,43604-43605,43757,43775,43839-43840,43857-43858,43860,43905-43907,44002,44037,44039-44040,44044-44045,44065,44095,44123,44144,44205,44294,44338,44389,44391,44426,44460,44530,44540,44601 Propchange: trunk/reactos/tools/rsym/log2lines.c ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Sun Dec 20 14:30:35 2009 @@ -1,1 +1,1 @@ -/branches/ros-amd64-bringup/reactos/tools/rsym/log2lines.c:35683,35762,35777,35827,36172,36445,36502-36503,36505,36899,36936,38149-38150,38264,38268,38355,40122-40123,40125,40128,40155,40753,40928,40986-40987,40989,40993,40995-40996,41001,41028-41029,41044-41045,41047-41049,41097-41098,41101,41449,41484,43506,43839-43840,43857-43858,43860,43905-43907,44002,44037,44039-44040,44044-44045,44294,44338,44389,44391,44460,44601 +/branches/ros-amd64-bringup/reactos/tools/rsym/log2lines.c:35683,35762,35777,35827,36172,36445,36502-36503,36505,36899,36936,38149-38150,38264,38268,38355,39639,40122-40123,40125,40128,40155,40247,40324,40753,40928,40986-40987,40989,40993,40995-40996,41001,41028-41029,41044-41045,41047-41049,41097-41098,41101,41449,41484,43506,43566,43574,43598,43600-43602,43604-43605,43757,43775,43839-43840,43857-43858,43860,43905-43907,44002,44037,44039-44040,44044-44045,44065,44095,44123,44144,44205,44294,44338,44389,44391,44426,44460,44530,44540,44601 Propchange: trunk/reactos/tools/rsym/log2lines.mak ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Sun Dec 20 14:30:35 2009 @@ -1,1 +1,1 @@ -/branches/ros-amd64-bringup/reactos/tools/rsym/log2lines.mak:35683,35762,35777,35827,36172,36445,36502-36503,36505,36899,36936,38149-38150,38264,38268,38355,40122-40123,40125,40128,40155,40753,40928,40986-40987,40989,40993,40995-40996,41001,41028-41029,41044-41045,41047-41049,41097-41098,41101,41449,41484,43506,43839-43840,43857-43858,43860,43905-43907,44002,44037,44039-44040,44044-44045,44294,44338,44389,44391,44460,44601 +/branches/ros-amd64-bringup/reactos/tools/rsym/log2lines.mak:35683,35762,35777,35827,36172,36445,36502-36503,36505,36899,36936,38149-38150,38264,38268,38355,39639,40122-40123,40125,40128,40155,40247,40324,40753,40928,40986-40987,40989,40993,40995-40996,41001,41028-41029,41044-41045,41047-41049,41097-41098,41101,41449,41484,43506,43566,43574,43598,43600-43602,43604-43605,43757,43775,43839-43840,43857-43858,43860,43905-43907,44002,44037,44039-44040,44044-44045,44065,44095,44123,44144,44205,44294,44338,44389,44391,44426,44460,44530,44540,44601 Propchange: trunk/reactos/tools/rsym/rsym.c ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Sun Dec 20 14:30:35 2009 @@ -1,1 +1,1 @@ -/branches/ros-amd64-bringup/reactos/tools/rsym/rsym.c:35683,35762,35777,35827,36172,36445,36502-36503,36505,36899,36936,37291,37302,37305,37320,37329,37462,37895,38129,38149-38150,38264,38268,38330-38331,38341,38355,38947,38973,39072,39114,39121,40122-40123,40125,40128,40155,40605,40753,40928,40986-40987,40989,40993,40995-40996,41001,41028-41029,41044-41045,41047-41049,41097-41098,41101,41449,41484,43506,43839-43840,43857-43858,43860,43905-43907,44002,44037,44039-44040,44044-44045,44294,44338,44389,44391,44460,44601 +/branches/ros-amd64-bringup/reactos/tools/rsym/rsym.c:35683,35762,35777,35827,36172,36445,36502-36503,36505,36899,36936,37291,37302,37305,37320,37329,37462,37895,38129,38149-38150,38264,38268,38330-38331,38341,38355,38947,38973,39072,39114,39121,39639,40122-40123,40125,40128,40155,40247,40324,40605,40753,40928,40986-40987,40989,40993,40995-40996,41001,41028-41029,41044-41045,41047-41049,41097-41098,41101,41449,41484,43506,43566,43574,43598,43600-43602,43604-43605,43757,43775,43839-43840,43857-43858,43860,43905-43907,44002,44037,44039-44040,44044-44045,44065,44095,44123,44144,44205,44294,44338,44389,44391,44426,44460,44530,44540,44601 Propchange: trunk/reactos/tools/rsym/rsym.h ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Sun Dec 20 14:30:35 2009 @@ -1,1 +1,1 @@ -/branches/ros-amd64-bringup/reactos/tools/rsym/rsym.h:35683,35762,35777,35827,36172,36445,36502-36503,36505,36899,36936,37291,37302,37305,37320,37329,37462,37895,38129,38149-38150,38264,38268,38330-38331,38341,38355,38947,38973,39072,39114,39121,40122-40123,40125,40128,40155,40605,40753,40928,40986-40987,40989,40993,40995-40996,41001,41028-41029,41044-41045,41047-41049,41097-41098,41101,41449,41484,43506,43839-43840,43857-43858,43860,43905-43907,44002,44037,44039-44040,44044-44045,44294,44338,44389,44391,44460,44601 +/branches/ros-amd64-bringup/reactos/tools/rsym/rsym.h:35683,35762,35777,35827,36172,36445,36502-36503,36505,36899,36936,37291,37302,37305,37320,37329,37462,37895,38129,38149-38150,38264,38268,38330-38331,38341,38355,38947,38973,39072,39114,39121,39639,40122-40123,40125,40128,40155,40247,40324,40605,40753,40928,40986-40987,40989,40993,40995-40996,41001,41028-41029,41044-41045,41047-41049,41097-41098,41101,41449,41484,43506,43566,43574,43598,43600-43602,43604-43605,43757,43775,43839-43840,43857-43858,43860,43905-43907,44002,44037,44039-44040,44044-44045,44065,44095,44123,44144,44205,44294,44338,44389,44391,44426,44460,44530,44540,44601 Propchange: trunk/reactos/tools/rsym/rsym.mak ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Sun Dec 20 14:30:35 2009 @@ -1,1 +1,1 @@ -/branches/ros-amd64-bringup/reactos/tools/rsym/rsym.mak:35683,35762,35777,35827,36172,36445,36502-36503,36505,36899,36936,37291,37302,37305,37320,37329,37462,37895,38129,38149-38150,38264,38268,38330-38331,38341,38355,38947,38973,39072,39114,39121,40122-40123,40125,40128,40155,40605,40753,40928,40986-40987,40989,40993,40995-40996,41001,41028-41029,41044-41045,41047-41049,41097-41098,41101,41449,41484,43506,43839-43840,43857-43858,43860,43905-43907,44002,44037,44039-44040,44044-44045,44294,44338,44389,44391,44460,44601 +/branches/ros-amd64-bringup/reactos/tools/rsym/rsym.mak:35683,35762,35777,35827,36172,36445,36502-36503,36505,36899,36936,37291,37302,37305,37320,37329,37462,37895,38129,38149-38150,38264,38268,38330-38331,38341,38355,38947,38973,39072,39114,39121,39639,40122-40123,40125,40128,40155,40247,40324,40605,40753,40928,40986-40987,40989,40993,40995-40996,41001,41028-41029,41044-41045,41047-41049,41097-41098,41101,41449,41484,43506,43566,43574,43598,43600-43602,43604-43605,43757,43775,43839-43840,43857-43858,43860,43905-43907,44002,44037,44039-44040,44044-44045,44065,44095,44123,44144,44205,44294,44338,44389,44391,44426,44460,44530,44540,44601 Propchange: trunk/reactos/tools/rsym/rsym_common.c ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Sun Dec 20 14:30:35 2009 @@ -1,1 +1,1 @@ -/branches/ros-amd64-bringup/reactos/tools/rsym/rsym_common.c:35683,35762,35777,35827,36172,36445,36502-36503,36505,36899,36936,37291,37302,37305,37320,37329,37462,37895,38129,38149-38150,38264,38268,38330-38331,38341,38355,38947,38973,39072,39114,39121,40122-40123,40125,40128,40155,40605,40753,40928,40986-40987,40989,40993,40995-40996,41001,41028-41029,41044-41045,41047-41049,41097-41098,41101,41449,41484,43506,43839-43840,43857-43858,43860,43905-43907,44002,44037,44039-44040,44044-44045,44294,44338,44389,44391,44460,44601 +/branches/ros-amd64-bringup/reactos/tools/rsym/rsym_common.c:35683,35762,35777,35827,36172,36445,36502-36503,36505,36899,36936,37291,37302,37305,37320,37329,37462,37895,38129,38149-38150,38264,38268,38330-38331,38341,38355,38947,38973,39072,39114,39121,39639,40122-40123,40125,40128,40155,40247,40324,40605,40753,40928,40986-40987,40989,40993,40995-40996,41001,41028-41029,41044-41045,41047-41049,41097-41098,41101,41449,41484,43506,43566,43574,43598,43600-43602,43604-43605,43757,43775,43839-43840,43857-43858,43860,43905-43907,44002,44037,44039-44040,44044-44045,44065,44095,44123,44144,44205,44294,44338,44389,44391,44426,44460,44530,44540,44601
15 years
1
0
0
0
[dgorbachev] 44668: Update log2lines to the latest version. Jan Roeloffzen, bug #4342.
by dgorbachev@svn.reactos.org
Author: dgorbachev Date: Sun Dec 20 13:36:26 2009 New Revision: 44668 URL:
http://svn.reactos.org/svn/reactos?rev=44668&view=rev
Log: Update log2lines to the latest version. Jan Roeloffzen, bug #4342. Modified: trunk/reactos/tools/rsym/log2lines.c Modified: trunk/reactos/tools/rsym/log2lines.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/rsym/log2lines.c?rev…
============================================================================== --- trunk/reactos/tools/rsym/log2lines.c [iso-8859-1] (original) +++ trunk/reactos/tools/rsym/log2lines.c [iso-8859-1] Sun Dec 20 13:36:26 2009 @@ -3,6 +3,7 @@ * Written by Jan Roeloffzen */ +#include <errno.h> #include <stdio.h> #include <string.h> #include <stdlib.h> @@ -10,21 +11,30 @@ #include "rsym.h" -#define LOG2LINES_VERSION "1.8" +#define LOG2LINES_VERSION "1.9" /* Assume if an offset > ABS_TRESHOLD, then it must be absolute */ #define ABS_TRESHOLD 0x00400000L #define INVALID_BASE 0xFFFFFFFFL +#define LOGBOTTOM "--------" +#define SVNDB "svndb.log" +#define SVNDB_INX "svndb.inx" +#define DEF_RANGE 500 +#define MAGIC_INX 0x494E585F //'INX_' #define DEF_OPT_DIR "output-i386" #define SOURCES_ENV "_ROSBE_ROSSOURCEDIR" #define CACHEFILE "log2lines.cache" #define TRKBUILDPREFIX "bootcd-" +#define SVN_PREFIX "/trunk/reactos/" #if defined (__DJGPP__) || defined (__WIN32__) + +#include <direct.h> #define POPEN _popen #define PCLOSE _pclose +#define MKDIR(d) _mkdir(d) #define DEV_NULL "NUL" #define DOS_PATHS #define PATH_CHAR '\\' @@ -35,12 +45,13 @@ #else /* not defined (__DJGPP__) || defined (__WIN32__) */ -#include <errno.h> #include <limits.h> +#include <sys/stat.h> #define MAX_PATH PATH_MAX #define POPEN popen #define PCLOSE pclose +#define MKDIR(d) mkdir(d, S_IRWXU|S_IRWXG|S_IROTH|S_IXOTH) #define DEV_NULL "/dev/null" #define UNIX_PATHS #define PATH_CHAR '/' @@ -85,13 +96,13 @@ struct entry_struct *pnext; }; -typedef struct entry_struct CACHE_ENTRY; - -struct cache_struct +typedef struct entry_struct LIST_ENTRY; + +struct list_struct { off_t st_size; - CACHE_ENTRY *phead; - CACHE_ENTRY *ptail; + LIST_ENTRY *phead; + LIST_ENTRY *ptail; }; struct summ_struct @@ -103,6 +114,7 @@ int diff; int majordiff; int revconflicts; + int regfound; int offset_errors; int total; }; @@ -122,15 +134,17 @@ { int rev; int buildrev; + int range; int opt_verbose; }; -typedef struct cache_struct CACHE; +typedef struct list_struct LIST; typedef struct summ_struct SUMM; typedef struct lineinfo_struct LINEINFO; typedef struct revinfo_struct REVINFO; -static CACHE cache; +static LIST cache; +static LIST sources; static SUMM summ; static LINEINFO lastLine; static REVINFO revinfo; @@ -176,6 +190,235 @@ return 1; } +/* Do this in reverse (recursively) + This saves many system calls if the path is likely + to already exist (creating large trees). +*/ +static int +mkPath(char *path, int isDir) +{ + char *s; + int res = 0; + + if (isDir) + { + res = MKDIR(path); + if (!res || (res == -1 && errno == EEXIST)) + return 0; + } + // create parent dir + if ((s = strrchr(path, PATH_CHAR))) + { + *s = '\0'; + res = mkPath(path, 1); + *s = PATH_CHAR; + } + + if (!res && isDir) + res = MKDIR(path); + + return res; +} + +static FILE * +rfopen(char *path, char *mode) +{ + FILE *f = NULL; + char tmppath[MAX_PATH]; // Don't modify const strings + + strcpy(tmppath, path); + f = fopen(tmppath, mode); + if (!f && !mkPath(tmppath, 0)) + f = fopen(tmppath, mode); + return f; +} + +static LIST_ENTRY * +entry_lookup(LIST *list, char *name) +{ + LIST_ENTRY *pprev = NULL; + LIST_ENTRY *pnext; + + if (!name || !name[0]) + return NULL; + + pnext = list->phead; + while (pnext != NULL) + { + if (PATHCMP(name, pnext->name) == 0) + { + if (pprev) + { // move to head for faster lookup next time + pprev->pnext = pnext->pnext; + pnext->pnext = list->phead; + list->phead = pnext; + } + return pnext; + } + pprev = pnext; + pnext = pnext->pnext; + } + return NULL; +} + +static LIST_ENTRY * +entry_delete(LIST_ENTRY *pentry) +{ + if (!pentry) + return NULL; + if (pentry->buf) + free(pentry->buf); + free(pentry); + return NULL; +} + +static LIST_ENTRY * +entry_insert(LIST *list, LIST_ENTRY *pentry) +{ + if (!pentry) + return NULL; + + pentry->pnext = list->phead; + list->phead = pentry; + if (!list->ptail) + list->ptail = pentry; + return pentry; +} + +#if 0 +static LIST_ENTRY * +entry_remove(LIST *list, LIST_ENTRY *pentry) +{ + LIST_ENTRY *pprev = NULL, *p = NULL; + + if (!pentry) + return NULL; + + if (pentry == list->phead) + { + list->phead = pentry->pnext; + p = pentry; + } + else + { + pprev = list->phead; + while (pprev->pnext) + { + if (pprev->pnext == pentry) + { + pprev->pnext = pentry->pnext; + p = pentry; + break; + } + pprev = pprev->pnext; + } + } + if (pentry == list->ptail) + list->ptail = pprev; + + return p; +} +#endif + +static LIST_ENTRY * +cache_entry_create(char *Line) +{ + LIST_ENTRY *pentry; + char *s = NULL; + int l; + + if (!Line) + return NULL; + + pentry = malloc(sizeof(LIST_ENTRY)); + if (!pentry) + return NULL; + + l = strlen(Line); + pentry->buf = s = malloc(l + 1); + if (!s) + { + l2l_dbg(1, "Alloc entry failed\n"); + return entry_delete(pentry); + } + + strcpy(s, Line); + if (s[l] == '\n') + s[l] = '\0'; + + pentry->name = s; + s = strchr(s, '|'); + if (!s) + { + l2l_dbg(1, "Name field missing\n"); + return entry_delete(pentry); + } + *s++ = '\0'; + + pentry->path = s; + s = strchr(s, '|'); + if (!s) + { + l2l_dbg(1, "Path field missing\n"); + return entry_delete(pentry); + } + *s++ = '\0'; + if (1 != sscanf(s, "%x", (unsigned int *)(&pentry->ImageBase))) + { + l2l_dbg(1, "ImageBase field missing\n"); + return entry_delete(pentry); + } + return pentry; +} + + +static LIST_ENTRY * +sources_entry_create(LIST *list, char *path, char *prefix) +{ + LIST_ENTRY *pentry; + char *s = NULL; + int l; + + if (!path) + return NULL; + if (!prefix) + prefix = ""; + + pentry = malloc(sizeof(LIST_ENTRY)); + if (!pentry) + return NULL; + + l = strlen(path) + strlen(prefix); + pentry->buf = s = malloc(l + 1); + if (!s) + { + l2l_dbg(1, "Alloc entry failed\n"); + return entry_delete(pentry); + } + + strcpy(s, prefix); + strcat(s, path); + if (s[l] == '\n') + s[l] = '\0'; + + pentry->name = s; + if (list) + { + if (entry_lookup(list, pentry->name)) + { + l2l_dbg(1, "Entry %s exists\n", pentry->name); + pentry = entry_delete(pentry); + } + else + { + l2l_dbg(1, "Inserting entry %s\n", pentry->name); + entry_insert(list, pentry); + } + } + + return pentry; +} + static void clearLastLine(void) { @@ -198,18 +441,18 @@ { if (lastChanged) { - if(sscanf(s,"Last Changed Rev: %d",&rev)) + if (sscanf(s, "Last Changed Rev: %d", &rev)) break; } else { - if(sscanf(s,"Revision: %d",&rev)) + if (sscanf(s, "Revision: %d", &rev)) break; } } } else - l2l_dbg(1,"Can't popen: \"%s\"\n", s); + l2l_dbg(1, "Can't popen: \"%s\"\n", s); if (psvn) PCLOSE(psvn); @@ -245,7 +488,7 @@ *s = PATH_CHAR; // restore } - l2l_dbg(1,"TBRevision: %d\n", rev); + l2l_dbg(1, "TBRevision: %d\n", rev); return rev; } @@ -270,14 +513,14 @@ { if (i == line) log(outFile, "| ----\n"); - log(outFile, "| %4.4d %s", i+1, s); + log(outFile, "| %4.4d %s", i + 1, s); } i++; } fclose(src); } else - l2l_dbg(1,"Can't open: %s (check " SOURCES_ENV ")\n", s); + l2l_dbg(1, "Can't open: %s (check " SOURCES_ENV ")\n", s); } static void @@ -334,7 +577,7 @@ { int twice = 0; - twice = (lastLine.nr2 && (strcmp(lastLine.file1,lastLine.file2) != 0)); + twice = (lastLine.nr2 && strcmp(lastLine.file1, lastLine.file2) != 0); log_rev_check(outFile, lastLine.file1, twice); if (twice) { @@ -364,6 +607,15 @@ return ++base; return path; } + +static void +report(FILE *outFile) +{ + reportRevision(outFile); + reportSource(outFile); + clearLastLine(); +} + static size_t fixup_offset(size_t ImageBase, size_t offset) @@ -439,21 +691,23 @@ strcpy(lastLine.file1, &Strings[e->FileOffset]); strcpy(lastLine.func1, &Strings[e->FunctionOffset]); lastLine.nr1 = e->SourceLine; + sources_entry_create(&sources, lastLine.file1, SVN_PREFIX); lastLine.valid = 1; if (e2) { strcpy(lastLine.file2, &Strings[e2->FileOffset]); strcpy(lastLine.func2, &Strings[e2->FunctionOffset]); lastLine.nr2 = e2->SourceLine; + sources_entry_create(&sources, lastLine.file2, SVN_PREFIX); bFileOffsetChanged = e->FileOffset != e2->FileOffset; if (e->FileOffset != e2->FileOffset || e->FunctionOffset != e2->FunctionOffset) summ.majordiff++; /* - * - "%.0s" displays nothing, but processes argument - * - bFileOffsetChanged implies always display 2nd SourceLine even if the same - * - also for FunctionOffset - */ + * - "%.0s" displays nothing, but processes argument + * - bFileOffsetChanged implies always display 2nd SourceLine even if the same + * - also for FunctionOffset + */ strcat(fmt, "%s"); if (bFileOffsetChanged) strcat(fmt, "[%s]"); @@ -565,7 +819,7 @@ sprintf(toString, "??:0"); else printf("??:0"); - l2l_dbg(1, "Offset not found: %x\n", offset); + l2l_dbg(1, "Offset not found: %x\n", (unsigned int)offset); summ.offset_errors++; } @@ -627,10 +881,16 @@ l2l_dbg(0, "Cannot remove dst %s before copy\n", dst); return 1; } - system(Line); + if (system(Line) < 0) + { + l2l_dbg(0, "Cannot copy %s to %s\n", src, dst); + l2l_dbg(1, "Failed to execute: '%s'\n", Line); + return 2; + } + if (!file_exists(dst)) { - l2l_dbg(0, "Dst %s does not exist after copy \n", dst); + l2l_dbg(0, "Dst %s does not exist after copy\n", dst); return 2; } return 0; @@ -714,7 +974,7 @@ if (PEOptHeader.Magic != IMAGE_NT_OPTIONAL_HDR32_MAGIC && PEOptHeader.Magic != IMAGE_NT_OPTIONAL_HDR64_MAGIC) { - l2l_dbg(2, "get_ImageBase %s, not an IMAGE_NT_OPTIONAL_HDR<32|64>\n", fname); + l2l_dbg(2, "get_ImageBase %s, not an IMAGE_NT_OPTIONAL_HDR 32/64 bit\n", fname); fclose(fr); return 6; } @@ -724,110 +984,11 @@ return 0; } -static CACHE_ENTRY * -entry_delete(CACHE_ENTRY *pentry) -{ - if (!pentry) - return NULL; - if (pentry->buf) - free(pentry->buf); - free(pentry); - return NULL; -} - -static CACHE_ENTRY * -entry_insert(CACHE_ENTRY *pentry) -{ - if (!pentry) - return NULL; - pentry->pnext = cache.phead; - cache.phead = pentry; - if (!cache.ptail) - cache.ptail = pentry; - return pentry; -} - -static CACHE_ENTRY * -entry_create(char *Line) -{ - CACHE_ENTRY *pentry; - char *s = NULL; - int l; - - if (!Line) - return NULL; - - pentry = malloc(sizeof(CACHE_ENTRY)); - if (!pentry) - return NULL; - - l = strlen(Line); - pentry->buf = s = malloc(l + 1); - if (!s) - { - l2l_dbg(1, "Alloc entry failed\n"); - return entry_delete(pentry); - } - - strcpy(s, Line); - if (s[l] == '\n') - s[l] = '\0'; - - pentry->name = s; - s = strchr(s, '|'); - if (!s) - { - l2l_dbg(1, "Name field missing\n"); - return entry_delete(pentry); - } - *s++ = '\0'; - - pentry->path = s; - s = strchr(s, '|'); - if (!s) - { - l2l_dbg(1, "Path field missing\n"); - return entry_delete(pentry); - } - *s++ = '\0'; - if (1 != sscanf(s, "%x", &pentry->ImageBase)) - { - l2l_dbg(1, "ImageBase field missing\n"); - return entry_delete(pentry); - } - return pentry; -} - -static CACHE_ENTRY * -entry_lookup(char *name) -{ - CACHE_ENTRY *pprev = NULL; - CACHE_ENTRY *pnext; - - pnext = cache.phead; - while (pnext != NULL) - { - if (PATHCMP(name, pnext->name) == 0) - { - if (pprev) - { // move to head for faster lookup next time - pprev->pnext = pnext->pnext; - pnext->pnext = cache.phead; - cache.phead = pnext; - } - return pnext; - } - pprev = pnext; - pnext = pnext->pnext; - } - return NULL; -} - static int read_cache(void) { FILE *fr; - CACHE_ENTRY *pentry; + LIST_ENTRY *pentry; char *Line = NULL; int result = 0; @@ -850,13 +1011,13 @@ while (fgets(Line, LINESIZE, fr) != NULL) { - pentry = entry_create(Line); + pentry = cache_entry_create(Line); if (!pentry) { l2l_dbg(2, "** Create entry failed of: %s\n", Line); } else - entry_insert(pentry); + entry_insert(&cache, pentry); } fclose(fr); @@ -908,7 +1069,12 @@ l2l_dbg(0, "Scanning %s ...\n", opt_dir); snprintf(Line, LINESIZE, DIR_FMT, opt_dir, tmp_name); l2l_dbg(1, "Executing: %s\n", Line); - system(Line); + if (system(Line) < 0) + { + l2l_dbg(0, "Cannot list directory %s\n", opt_dir); + l2l_dbg(1, "Failed to execute: '%s'\n", Line); + return 2; + } l2l_dbg(0, "Creating cache ..."); if ((fr = fopen(tmp_name, "r")) != NULL) @@ -932,9 +1098,9 @@ if (*Fname && !skipImageBase) { if ((err = get_ImageBase(Line, &ImageBase)) == 0) - fprintf(fw, "%s|%s|%0x\n", Fname, Line, ImageBase); + fprintf(fw, "%s|%s|%0x\n", Fname, Line, (unsigned int)ImageBase); else - l2l_dbg(3, "%s|%s|%0x, ERR=%d\n", Fname, Line, ImageBase, err); + l2l_dbg(3, "%s|%s|%0x, ERR=%d\n", Fname, Line, (unsigned int)ImageBase, err); } } fclose(fw); @@ -951,7 +1117,7 @@ translate_file(const char *cpath, size_t offset, char *toString) { size_t base = 0; - CACHE_ENTRY *pentry = NULL; + LIST_ENTRY *pentry = NULL; int res = 0; char *path, *dpath; @@ -962,7 +1128,7 @@ // The path could be absolute: if (get_ImageBase(path, &base)) { - pentry = entry_lookup(path); + pentry = entry_lookup(&cache, path); if (pentry) { path = pentry->path; @@ -1033,7 +1199,7 @@ if (sep) { *sep = ' '; - cnt = sscanf(s, "<%s %x%c", path, &offset, &ch); + cnt = sscanf(s, "<%s %x%c", path, (unsigned int *)(&offset), &ch); if (opt_undo) { if (cnt == 3 && ch == ' ') @@ -1047,12 +1213,12 @@ mark = opt_mark ? "* " : ""; if (opt_redo && !(res = translate_file(path, offset, LineOut))) { - log(outFile, "%s<%s:%x (%s)>%s", mark, path, offset, LineOut, tail); + log(outFile, "%s<%s:%x (%s)>%s", mark, path, (unsigned int)offset, LineOut, tail); summ.redo++; } else { - log(outFile, "%s<%s:%x>%s", mark, path, offset, tail); + log(outFile, "%s<%s:%x>%s", mark, path, (unsigned int)offset, tail); summ.undo++; } } @@ -1073,7 +1239,7 @@ if (!(res = translate_file(path, offset, LineOut))) { mark = opt_mark ? "* " : ""; - log(outFile, "%s<%s:%x (%s)>%s", mark, path, offset, LineOut, tail); + log(outFile, "%s<%s:%x (%s)>%s", mark, path, (unsigned int)offset, LineOut, tail); summ.translated++; } else @@ -1094,6 +1260,123 @@ memset(Line, '\0', LINESIZE); // flushed } +static unsigned long +findRev(FILE *finx, int *rev) +{ + unsigned long pos = 0L; + + while (!fseek(finx, (*rev) * sizeof(unsigned long), SEEK_SET)) + { + fread(&pos, sizeof(long), 1, finx); + (*rev)--; + if (pos) + break; + } + return pos; +} + +static int +regscan(FILE *outFile) +{ + int res = 0; + char logname[MAX_PATH]; + char inxname[MAX_PATH]; + char line[LINESIZE + 1]; + char line2[LINESIZE + 1]; + FILE *flog = NULL; + FILE *finx = NULL; + unsigned long pos = 0L; + int r; + + sprintf(logname, "%s" PATH_STR "%s", sources_path, SVNDB); + sprintf(inxname, "%s" PATH_STR "%s", sources_path, SVNDB_INX); + flog = fopen(logname, "rb"); + finx = fopen(inxname, "rb"); + + if (flog && finx) + { + r = revinfo.buildrev; + if (!fread(&pos, sizeof(long), 1, finx)) + { + res = 2; + l2l_dbg(0, "Cannot read magic number\n"); + } + + if (!res) + { + if (pos != MAGIC_INX) + { + res = 3; + l2l_dbg(0, "Incorrect magic number (%lx)\n", pos); + } + } + + if (!res) + { + char flag[2]; + char path[MAX_PATH]; + char path2[MAX_PATH]; + int wflag = 0; + log(outFile, "\nRegression candidates:\n"); + while (( pos = findRev(finx, &r) )) + { + if (r < (revinfo.buildrev - revinfo.range)) + { + l2l_dbg(1, "r%d is outside range of %d revisions\n", r, revinfo.range); + break; + } + fseek(flog, pos, SEEK_SET); + wflag = 1; + fgets(line, LINESIZE, flog); + fgets(line2, LINESIZE, flog); + while (fgets(line2, LINESIZE, flog)) + { + path2[0] = '\0'; + if (sscanf(line2, "%1s %s %s", flag, path, path2) >= 2) + { + if (entry_lookup(&sources, path) || entry_lookup(&sources, path2)) + { + if (wflag == 1) + { + log(outFile, "%sChanged paths:\n", line); + summ.regfound++; + wflag = 2; + } + log(outFile, "%s", line2); + } + } + else + break; + } + if (wflag == 2) + { + int i = 0; + log(outFile, "\n"); + while (fgets(line2, LINESIZE, flog)) + { + i++; + log(outFile, "%s", line2); + if (strncmp(LOGBOTTOM, line2, sizeof(LOGBOTTOM) - 1) == 0) + break; + } + } + } + } + } + else + { + res = 1; + l2l_dbg(0, "Cannot open %s or %s\n", logname, inxname); + } + + if (flog) + fclose(flog); + if (finx) + fclose(finx); + + return res; +} + static void print_summary(FILE *outFile) { @@ -1107,6 +1390,7 @@ fprintf(outFile, "Differ: %d\n", summ.diff); fprintf(outFile, "Differ (function/source): %d\n", summ.majordiff); fprintf(outFile, "Revision conflicts: %d\n", summ.revconflicts); + fprintf(outFile, "Regression candidates: %d\n", summ.regfound); fprintf(outFile, "Offset error: %d\n", summ.offset_errors); fprintf(outFile, "Total: %d\n", summ.total); fprintf(outFile, "-------------------------------\n"); @@ -1143,9 +1427,7 @@ translate_line(outFile, Line, path, LineOut); i = 0; translate_char(c, outFile); - reportRevision(outFile); - reportSource(outFile); - clearLastLine(); + report(outFile); break; case '<': i = 0; @@ -1198,15 +1480,25 @@ if (!opt_raw) { translate_line(outFile, Line, path, LineOut); - reportRevision(outFile); - reportSource(outFile); - clearLastLine(); + report(outFile); } else log(outFile, "%s", Line); } } } + + if (opt_Revision && (strstr(opt_Revision, "regscan") == opt_Revision)) + { + char *s = strchr(opt_Revision, ','); + if (s) + { + *s++ = '\0'; + revinfo.range = atoi(s); + } + regscan(outFile); + } + if (opt_stats) { print_summary(outFile); @@ -1227,8 +1519,11 @@ " - Also, <offset> can be repeated for each <exefile>\n" " - NOTE: Some of the options below will have no effect in this form.\n" " Otherwise it reads stdin and tries to translate lines of the form:\n" -" <IMAGENAME:ADDRESS>\n\n" -" The result is written to stdout.\n" +" <IMAGENAME:ADDRESS>\n" +" The result is written to stdout.\n\n" +" <offset> or <ADDRESS> can be absolute or relative with the restrictions:\n" +" - An image with base < 0x400000 MUST be relocated to a > 0x400000 address.\n" +" - The offset of a relocated image MUST be relative.\n\n" " log2lines uses a cache in order to avoid a directory scan at each\n" " image lookup, greatly increasing performance. Only image path and its\n" " base address are cached.\n\n" @@ -1266,6 +1561,26 @@ " Also when the revison of the source tree is lower than that of the\n" " tested build (for every source file).\n" " In both cases the source file's -S output would be unreliable.\n" +" - update:\n" +" Updates the SVN log file. Currently only generates the index file\n" +" The SVN log file itself must be generated by hand in the sources\n" +" directory like this (-v is mandatory here):\n" +" svn log -v > svndb.log ('svn log' accepts also a range)\n" +" 'svndb.log' and its index are needed for '-R regscan'\n" +" - regscan[,<range>]:\n" +" Scan for regression candidates. Essentially it tries to find\n" +" matches between the SVN log entries and the sources hit by\n" +" the backtrace.\n" +" <range> is the amount of revisions to look back from the build\n" +" revision (default 500)\n" +" The output of '-R regscan' is printed after EOF. The 'Changed path'\n" +" lists will contain only matched files.\n" +" Limitations:\n" +" - The bug should really be a regression.\n" +" - Expect a number of false positives.\n" +" - The offending change must be in the sources hit by the backtrace.\n" +" This mostly excludes changes in headerfiles for example.\n" +" - Must be combined with -S.\n" " Can be combined with -tTS.\n\n" " -s Statistics. A summary with the following info is printed after EOF:\n" " *** LOG2LINES SUMMARY ***\n" @@ -1276,6 +1591,7 @@ " - Differ: Lines where (addr-1) info differs. See -tT options\n" " - Differ(func/src):Lines where also function or source info differ.\n" " - Rev conflicts: Source files conflicting with build. See '-R check'\n" +" - Reg candidates: Regression candidates. See '-R regscan'\n" " - Offset error: Image exists, but error retrieving offset info.\n" " - Total: Total number of lines attempted to translate.\n" " Also some version info is displayed.\n\n" @@ -1425,7 +1741,10 @@ char *check_dir; if (opt_Revision) + { revinfo.rev = getRevision(NULL, 1); + revinfo.range = DEF_RANGE; + } check_iso = strrchr(opt_dir, '.'); l2l_dbg(1, "Checking directory: %s\n", opt_dir); if (check_iso && PATHCMP(check_iso, ".7z") == 0) @@ -1486,7 +1805,7 @@ if (opt_Revision) { revinfo.buildrev = getTBRevision(opt_dir); - l2l_dbg(1,"Trunk build revision: %d\n", revinfo.buildrev); + l2l_dbg(1, "Trunk build revision: %d\n", revinfo.buildrev); } cache_name = malloc(MAX_PATH); tmp_name = malloc(MAX_PATH); @@ -1497,6 +1816,49 @@ return 0; } +static int +updateSvnlog(void) +{ + int res = 0; + char logname[MAX_PATH]; + char inxname[MAX_PATH]; + char line[LINESIZE + 1]; + FILE *flog = NULL; + FILE *finx = NULL; + unsigned long pos; + int r, y, m, d; + char name[NAMESIZE]; + + sprintf(logname, "%s" PATH_STR "%s", sources_path, SVNDB); + sprintf(inxname, "%s" PATH_STR "%s", sources_path, SVNDB_INX); + flog = fopen(logname, "rb"); + finx = fopen(inxname, "wb"); + + if (flog && finx) + { + pos = MAGIC_INX; + fwrite(&pos, sizeof(long), 1, finx); + pos = ftell(flog); + while (fgets(line, LINESIZE, flog)) + { + if (sscanf(line, "r%d | %s | %d-%d-%d", &r, name, &y, &m, &d) == 5) + { + l2l_dbg(1, "%ld r%d | %s | %d-%d-%d\n", pos, r, name, y, m, d); + fseek(finx, r * sizeof(unsigned long), SEEK_SET); + fwrite(&pos, sizeof(unsigned long), 1, finx); + } + pos = ftell(flog); + } + } + + if (flog) + fclose(flog); + if (finx) + fclose(finx); + + return res; +} + int main(int argc, const char **argv) { @@ -1509,7 +1871,7 @@ strcpy(opt_dir, ""); strcpy(sources_path, ""); if ((s = getenv(SOURCES_ENV))) - strcpy(sources_path,s); + strcpy(sources_path, s); strcpy(opt_scanned, ""); for (i = 1; i < argc; i++) @@ -1520,6 +1882,8 @@ strcpy(opt_logFile, ""); strcpy(opt_7z, CMD_7Z); + memset(&cache, 0, sizeof(LIST)); + memset(&sources, 0, sizeof(LIST)); memset(&summ, 0, sizeof(SUMM)); memset(&revinfo, 0, sizeof(REVINFO)); clearLastLine(); @@ -1566,17 +1930,17 @@ case 'R': optCount++; opt_Revision = malloc(LINESIZE); - i = sscanf(optarg, "%s", opt_Revision); + sscanf(optarg, "%s", opt_Revision); break; case 's': opt_stats++; break; case 'S': optCount++; - i = sscanf(optarg, "%d+%d,%s", &opt_Source,&opt_SrcPlus,sources_path); + i = sscanf(optarg, "%d+%d,%s", &opt_Source, &opt_SrcPlus, sources_path); if (i == 1) sscanf(optarg, "%*d,%s", sources_path); - l2l_dbg(3, "Sources option parse result: %d+%d,\"%s\"\n", opt_Source,opt_SrcPlus,sources_path); + l2l_dbg(3, "Sources option parse result: %d+%d,\"%s\"\n", opt_Source, opt_SrcPlus, sources_path); break; case 't': opt_twice++; @@ -1621,8 +1985,14 @@ strcpy(opt_dir, sources_path); strcat(opt_dir, DEF_OPT_DIR); } - argc -= optCount; + + if (opt_Revision && (strcmp(opt_Revision, "update") == 0)) + { + res = updateSvnlog(); + return res; + } + if (check_directory(opt_force)) return 3; @@ -1658,7 +2028,7 @@ if (argc > 1) { // translate {<exefile> <offset>} int i = 1; - const char *base = NULL; + const char *exefile = NULL; const char *offset = NULL; char Line[LINESIZE + 1]; @@ -1668,14 +2038,12 @@ offset = argv[optCount + i++]; if (isOffset(offset)) { - if (base) + if (exefile) { - l2l_dbg(2, "translating %s %s\n", base, offset); - translate_file(base, my_atoi(offset), Line); - printf("%s\n", Line); - reportRevision(stdout); - reportSource(stdout); - clearLastLine(); + l2l_dbg(2, "translating %s %s\n", exefile, offset); + translate_file(exefile, my_atoi(offset), Line); + printf("%s\n", Line); + report(stdout); } else { @@ -1687,7 +2055,7 @@ else { // Not an offset so must be an exefile: - base = offset; + exefile = offset; } } }
15 years
1
0
0
0
[janderwald] 44667: - Fix broken check for storing the number of transferred bytes. - Fix broken logic in GetOverlappedResult - Patch by Alex
by janderwald@svn.reactos.org
Author: janderwald Date: Sun Dec 20 12:57:21 2009 New Revision: 44667 URL:
http://svn.reactos.org/svn/reactos?rev=44667&view=rev
Log: - Fix broken check for storing the number of transferred bytes. - Fix broken logic in GetOverlappedResult - Patch by Alex Modified: trunk/reactos/dll/win32/kernel32/file/deviceio.c Modified: trunk/reactos/dll/win32/kernel32/file/deviceio.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/file/de…
============================================================================== --- trunk/reactos/dll/win32/kernel32/file/deviceio.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/kernel32/file/deviceio.c [iso-8859-1] Sun Dec 20 12:57:21 2009 @@ -1,18 +1,17 @@ -/* $Id$ - * - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/kernel32/file/deviceio.c - * PURPOSE: Device I/O and Overlapped Result functions - * PROGRAMMER: Ariadne (ariadne(a)xs4all.nl) - * UPDATE HISTORY: - * Created 01/11/98 +/* + * PROJECT: ReactOS Kernel + * LICENSE: GPL - See COPYING in the top level directory + * FILE: kernel32/file/deviceio.c + * PURPOSE: Device I/O Base Client Functionality + * PROGRAMMERS: Alex Ionescu (alex.ionescu(a)reactos.org) */ + +/* INCLUDES *******************************************************************/ #include <k32.h> #include <wine/debug.h> -WINE_DEFAULT_DEBUG_CHANNEL(kernel32file); +/* FUNCTIONS ******************************************************************/ /* * @implemented @@ -21,131 +20,146 @@ WINAPI DeviceIoControl(IN HANDLE hDevice, IN DWORD dwIoControlCode, - IN LPVOID lpInBuffer OPTIONAL, - IN DWORD nInBufferSize OPTIONAL, - OUT LPVOID lpOutBuffer OPTIONAL, - IN DWORD nOutBufferSize OPTIONAL, - OUT LPDWORD lpBytesReturned OPTIONAL, - IN LPOVERLAPPED lpOverlapped OPTIONAL) + IN LPVOID lpInBuffer OPTIONAL, + IN DWORD nInBufferSize OPTIONAL, + OUT LPVOID lpOutBuffer OPTIONAL, + IN DWORD nOutBufferSize OPTIONAL, + OUT LPDWORD lpBytesReturned OPTIONAL, + IN LPOVERLAPPED lpOverlapped OPTIONAL) { - BOOL FsIoCtl; - NTSTATUS Status; - - FsIoCtl = ((dwIoControlCode >> 16) == FILE_DEVICE_FILE_SYSTEM); - - if (lpBytesReturned != NULL) - { - *lpBytesReturned = 0; - } - - if (lpOverlapped != NULL) - { - PVOID ApcContext; - + BOOL FsIoCtl; + NTSTATUS Status; + PVOID ApcContext; + IO_STATUS_BLOCK Iosb; + + /* Check what kind of IOCTL to send */ + FsIoCtl = ((dwIoControlCode >> 16) == FILE_DEVICE_FILE_SYSTEM); + + /* CHeck for async */ + if (lpOverlapped != NULL) + { + /* Set pending status */ lpOverlapped->Internal = STATUS_PENDING; + + + /* Check if there's an APC context */ ApcContext = (((ULONG_PTR)lpOverlapped->hEvent & 0x1) ? NULL : lpOverlapped); + + /* Send file system control? */ if (FsIoCtl) - { - Status = NtFsControlFile(hDevice, - lpOverlapped->hEvent, - NULL, - ApcContext, - (PIO_STATUS_BLOCK)lpOverlapped, - dwIoControlCode, - lpInBuffer, - nInBufferSize, - lpOutBuffer, - nOutBufferSize); - } - else - { - Status = NtDeviceIoControlFile(hDevice, - lpOverlapped->hEvent, - NULL, - ApcContext, - (PIO_STATUS_BLOCK)lpOverlapped, - dwIoControlCode, - lpInBuffer, - nInBufferSize, - lpOutBuffer, - nOutBufferSize); - } - - /* return FALSE in case of failure and pending operations! */ - if (!NT_SUCCESS(Status) || Status == STATUS_PENDING) - { - SetLastErrorByStatus(Status); - return FALSE; - } - - if (lpBytesReturned != NULL) - { - *lpBytesReturned = lpOverlapped->InternalHigh; - } - } - else - { - IO_STATUS_BLOCK Iosb; - + { + /* Send it */ + Status = NtFsControlFile(hDevice, + lpOverlapped->hEvent, + NULL, + ApcContext, + (PIO_STATUS_BLOCK)lpOverlapped, + dwIoControlCode, + lpInBuffer, + nInBufferSize, + lpOutBuffer, + nOutBufferSize); + } + else + { + /* Otherwise send a device control */ + Status = NtDeviceIoControlFile(hDevice, + lpOverlapped->hEvent, + NULL, + ApcContext, + (PIO_STATUS_BLOCK)lpOverlapped, + dwIoControlCode, + lpInBuffer, + nInBufferSize, + lpOutBuffer, + nOutBufferSize); + } + + /* Check for or information instead of failure */ + if (!(NT_ERROR(Status)) && (lpBytesReturned)) + { + /* Protect with SEH */ + _SEH2_TRY + { + /* Return the bytes */ + *lpBytesReturned = lpOverlapped->InternalHigh; + } + _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) + { + /* Return zero bytes */ + *lpBytesReturned = 0; + } + _SEH2_END; + } + + /* Now check for any kind of failure except pending*/ + if (!(NT_SUCCESS(Status)) || (Status == STATUS_PENDING)) + { + /* Fail */ + SetLastErrorByStatus(Status); + return FALSE; + } + } + else + { + /* Sync case -- send file system code? */ if (FsIoCtl) - { - Status = NtFsControlFile(hDevice, - NULL, - NULL, - NULL, - &Iosb, - dwIoControlCode, - lpInBuffer, - nInBufferSize, - lpOutBuffer, - nOutBufferSize); - } - else - { - Status = NtDeviceIoControlFile(hDevice, - NULL, - NULL, - NULL, - &Iosb, - dwIoControlCode, - lpInBuffer, - nInBufferSize, - lpOutBuffer, - nOutBufferSize); - } - - /* wait in case operation is pending */ + { + /* Do it */ + Status = NtFsControlFile(hDevice, + NULL, + NULL, + NULL, + &Iosb, + dwIoControlCode, + lpInBuffer, + nInBufferSize, + lpOutBuffer, + nOutBufferSize); + } + else + { + /* Send device code instead */ + Status = NtDeviceIoControlFile(hDevice, + NULL, + NULL, + NULL, + &Iosb, + dwIoControlCode, + lpInBuffer, + nInBufferSize, + lpOutBuffer, + nOutBufferSize); + } + + /* Now check if the operation isn't done yet */ if (Status == STATUS_PENDING) - { - Status = NtWaitForSingleObject(hDevice, - FALSE, - NULL); - if (NT_SUCCESS(Status)) - { - Status = Iosb.Status; - } - } - + { + /* Wait for it and get the final status */ + Status = NtWaitForSingleObject(hDevice, FALSE, NULL); + if (NT_SUCCESS(Status)) Status = Iosb.Status; + } + + /* Check for success */ if (NT_SUCCESS(Status)) - { - /* lpBytesReturned must not be NULL here, in fact Win doesn't - check that case either and crashes (only after the operation - completed) */ - if (!lpBytesReturned) - { - ERR("Bad caller: lpBytesReturned must not be NULL\n"); - } - *lpBytesReturned = Iosb.Information; - } - else - { - SetLastErrorByStatus(Status); - return FALSE; - } - } - - return TRUE; + { + /* Return the byte count */ + *lpBytesReturned = Iosb.Information; + } + else + { + /* Check for informational or warning failure */ + if (!NT_ERROR(Status)) *lpBytesReturned = Iosb.Information; + + /* Return a failure */ + SetLastErrorByStatus(Status); + return FALSE; + } + } + + /* Return success */ + return TRUE; } @@ -154,55 +168,62 @@ */ BOOL WINAPI -GetOverlappedResult ( - IN HANDLE hFile, - IN LPOVERLAPPED lpOverlapped, - OUT LPDWORD lpNumberOfBytesTransferred, - IN BOOL bWait - ) +GetOverlappedResult(IN HANDLE hFile, + IN LPOVERLAPPED lpOverlapped, + OUT LPDWORD lpNumberOfBytesTransferred, + IN BOOL bWait) { - DWORD WaitStatus; - HANDLE hObject; - - if (lpOverlapped->Internal == STATUS_PENDING) - { - if (!bWait) - { - /* can't use SetLastErrorByStatus(STATUS_PENDING) here, - since STATUS_PENDING translates to ERROR_IO_PENDING */ - SetLastError(ERROR_IO_INCOMPLETE); - return FALSE; - } - - hObject = lpOverlapped->hEvent ? lpOverlapped->hEvent : hFile; - - /* Wine delivers pending APC's while waiting, but Windows does - not, nor do we... */ - WaitStatus = WaitForSingleObject(hObject, INFINITE); - - if (WaitStatus == WAIT_FAILED) - { - WARN("Wait failed!\n"); - /* WaitForSingleObjectEx sets the last error */ - return FALSE; - } - } - - if (!lpNumberOfBytesTransferred) - { - ERR("Bad caller: lpNumberOfBytesTransferred must not be NULL\n"); - } - *lpNumberOfBytesTransferred = lpOverlapped->InternalHigh; - - if (!NT_SUCCESS(lpOverlapped->Internal)) - { - SetLastErrorByStatus(lpOverlapped->Internal); - return FALSE; - } - - return TRUE; + DWORD WaitStatus; + HANDLE hObject; + + + /* Check for pending operation */ + if (lpOverlapped->Internal == STATUS_PENDING) + { + /* Check if the caller is okay with waiting */ + if (!bWait) + { + /* Set timeout */ + WaitStatus = WAIT_TIMEOUT; + } + else + { + /* Wait for the result */ + hObject = lpOverlapped->hEvent ? lpOverlapped->hEvent : hFile; + WaitStatus = WaitForSingleObject(hObject, INFINITE); + } + + + /* Check for timeout */ + if (WaitStatus == WAIT_TIMEOUT) + { + /* We have to override the last error with INCOMPLETE instead */ + SetLastError(ERROR_IO_INCOMPLETE); + return FALSE; + } + + + /* Fail if we had an error -- the last error is already set */ + if (WaitStatus != 0) return FALSE; + } + + + /* Return bytes transferred */ + *lpNumberOfBytesTransferred = lpOverlapped->InternalHigh; + + + /* Check for failure during I/O */ + if (!NT_SUCCESS(lpOverlapped->Internal)) + { + /* Set the error and fail */ + SetLastErrorByStatus(lpOverlapped->Internal); + return FALSE; + } + + + /* All done */ + return TRUE; } /* EOF */ -
15 years
1
0
0
0
[janderwald] 44666: [SETUPAPI] - Add SetupSetNonInteractiveMode stub
by janderwald@svn.reactos.org
Author: janderwald Date: Sun Dec 20 12:43:58 2009 New Revision: 44666 URL:
http://svn.reactos.org/svn/reactos?rev=44666&view=rev
Log: [SETUPAPI] - Add SetupSetNonInteractiveMode stub Modified: trunk/reactos/dll/win32/setupapi/setupapi.spec trunk/reactos/dll/win32/setupapi/stubs.c trunk/reactos/include/psdk/setupapi.h Modified: trunk/reactos/dll/win32/setupapi/setupapi.spec URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/setupapi/setupap…
============================================================================== --- trunk/reactos/dll/win32/setupapi/setupapi.spec [iso-8859-1] (original) +++ trunk/reactos/dll/win32/setupapi/setupapi.spec [iso-8859-1] Sun Dec 20 12:43:58 2009 @@ -520,7 +520,7 @@ @ stdcall SetupSetFileQueueAlternatePlatformA(ptr ptr str) @ stdcall SetupSetFileQueueAlternatePlatformW(ptr ptr wstr) @ stdcall SetupSetFileQueueFlags(long long long) -@ stub SetupSetNonInteractiveMode +@ stdcall SetupSetNonInteractiveMode(long) @ stub SetupSetPlatformPathOverrideA @ stub SetupSetPlatformPathOverrideW @ stdcall SetupSetSourceListA(long ptr long) Modified: trunk/reactos/dll/win32/setupapi/stubs.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/setupapi/stubs.c…
============================================================================== --- trunk/reactos/dll/win32/setupapi/stubs.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/setupapi/stubs.c [iso-8859-1] Sun Dec 20 12:43:58 2009 @@ -241,4 +241,10 @@ return FALSE; } - +WINSETUPAPI BOOL WINAPI SetupSetNonInteractiveMode(BOOL NonInteractiveFlag) +{ + FIXME("(%d) stub\n", NonInteractiveFlag); + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return FALSE; +} + Modified: trunk/reactos/include/psdk/setupapi.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/psdk/setupapi.h?re…
============================================================================== --- trunk/reactos/include/psdk/setupapi.h [iso-8859-1] (original) +++ trunk/reactos/include/psdk/setupapi.h [iso-8859-1] Sun Dec 20 12:43:58 2009 @@ -1420,6 +1420,7 @@ WINSETUPAPI BOOL WINAPI SetupSetDirectoryIdExW(HINF,DWORD,PCWSTR,DWORD,DWORD,PVOID); WINSETUPAPI BOOL WINAPI SetupSetFileQueueAlternatePlatformA(HSPFILEQ,PSP_ALTPLATFORM_INFO,PCSTR); WINSETUPAPI BOOL WINAPI SetupSetFileQueueAlternatePlatformW(HSPFILEQ,PSP_ALTPLATFORM_INFO,PCWSTR); +WINSETUPAPI BOOL WINAPI SetupSetNonInteractiveMode(BOOL); WINSETUPAPI BOOL WINAPI SetupSetPlatformPathOverrideA(PCSTR); WINSETUPAPI BOOL WINAPI SetupSetPlatformPathOverrideW(PCWSTR); WINSETUPAPI BOOL WINAPI SetupSetSourceListA(DWORD,PCSTR*,UINT);
15 years
1
0
0
0
[janderwald] 44665: [KS] - Return correct error code in KsPinPropertyHandler, when buffer is too small - Refactor KsTopologyPropertyHandler to make use of KsHandleSizedListQuery function which makes the function a lot smaller - Fix totally broken KsHandleSizedListQuery
by janderwald@svn.reactos.org
Author: janderwald Date: Sun Dec 20 12:17:02 2009 New Revision: 44665 URL:
http://svn.reactos.org/svn/reactos?rev=44665&view=rev
Log: [KS] - Return correct error code in KsPinPropertyHandler, when buffer is too small - Refactor KsTopologyPropertyHandler to make use of KsHandleSizedListQuery function which makes the function a lot smaller - Fix totally broken KsHandleSizedListQuery Modified: trunk/reactos/drivers/ksfilter/ks/connectivity.c trunk/reactos/drivers/ksfilter/ks/topology.c Modified: trunk/reactos/drivers/ksfilter/ks/connectivity.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/ksfilter/ks/connec…
============================================================================== --- trunk/reactos/drivers/ksfilter/ks/connectivity.c [iso-8859-1] (original) +++ trunk/reactos/drivers/ksfilter/ks/connectivity.c [iso-8859-1] Sun Dec 20 12:17:02 2009 @@ -335,17 +335,44 @@ Size += Descriptor[Pin->PinId].DataRanges[Index]->FormatSize; } - if (IoStack->Parameters.DeviceIoControl.OutputBufferLength < Size) - { + if (IoStack->Parameters.DeviceIoControl.OutputBufferLength == 0) + { + /* buffer too small */ Irp->IoStatus.Information = Size; - Status = STATUS_MORE_ENTRIES; + Status = STATUS_BUFFER_OVERFLOW; break; } Item = (KSMULTIPLE_ITEM*)Buffer; + + if (IoStack->Parameters.DeviceIoControl.OutputBufferLength == sizeof(ULONG)) + { + /* store the result size */ + Item->Size = Size; + Irp->IoStatus.Information = sizeof(ULONG); + Status = STATUS_SUCCESS; + break; + } + + if (IoStack->Parameters.DeviceIoControl.OutputBufferLength < sizeof(KSMULTIPLE_ITEM)) + { + /* buffer too small */ + Status = STATUS_BUFFER_TOO_SMALL; + break; + } + + /* store descriptor size */ Item->Size = Size; Item->Count = Descriptor[Pin->PinId].DataRangesCount; + if (IoStack->Parameters.DeviceIoControl.OutputBufferLength == sizeof(KSMULTIPLE_ITEM)) + { + Irp->IoStatus.Information = sizeof(KSMULTIPLE_ITEM); + Status = STATUS_SUCCESS; + break; + } + + /* now copy all dataranges */ Data = (PUCHAR)(Item +1); for (Index = 0; Index < Descriptor[Pin->PinId].DataRangesCount; Index++) { @@ -402,33 +429,16 @@ break; } - /* calculate size */ - Size = sizeof(KSMULTIPLE_ITEM); - Size += max(1, Descriptor[Pin->PinId].MediumsCount) * sizeof(KSPIN_MEDIUM); - - if (IoStack->Parameters.DeviceIoControl.OutputBufferLength < Size) - { - Irp->IoStatus.Information = Size; - Status = STATUS_MORE_ENTRIES; - break; - } - - Item = (KSMULTIPLE_ITEM*)Buffer; - Item->Size = Size; - if (Descriptor[Pin->PinId].MediumsCount) { - Item->Count = Descriptor[Pin->PinId].MediumsCount; - RtlMoveMemory((PVOID)(Item + 1), Descriptor[Pin->PinId].Mediums, Descriptor[Pin->PinId].MediumsCount * sizeof(KSPIN_MEDIUM)); + /* use mediums provided by driver */ + return KsHandleSizedListQuery(Irp, Descriptor[Pin->PinId].MediumsCount, sizeof(KSPIN_MEDIUM), Descriptor[Pin->PinId].Mediums); } else { - Item->Count = 1; - RtlMoveMemory((PVOID)(Item + 1), &StandardPinMedium, sizeof(KSPIN_MEDIUM)); - } - - Status = STATUS_SUCCESS; - Irp->IoStatus.Information = Size; + /* use standard medium */ + return KsHandleSizedListQuery(Irp, 1, sizeof(KSPIN_MEDIUM), &StandardPinMedium); + } break; case KSPROPERTY_PIN_COMMUNICATION: @@ -695,28 +705,58 @@ /* get current irp stack location */ IoStack = IoGetCurrentIrpStackLocation(Irp); + /* calculate size */ Size = DataItemSize * DataItemsCount + sizeof(KSMULTIPLE_ITEM); - - if (IoStack->Parameters.DeviceIoControl.InputBufferLength < Size) + /* get multiple item */ + Item = (PKSMULTIPLE_ITEM)Irp->UserBuffer; + + if (IoStack->Parameters.DeviceIoControl.OutputBufferLength == 0) { /* buffer too small */ - Irp->IoStatus.Status = STATUS_BUFFER_TOO_SMALL; Irp->IoStatus.Information = Size; + + return STATUS_BUFFER_OVERFLOW; + } + + if (IoStack->Parameters.DeviceIoControl.OutputBufferLength == sizeof(ULONG)) + { + /* store just the size */ + Item->Size = Size; + Irp->IoStatus.Information = sizeof(ULONG); + + return STATUS_SUCCESS; + } + + + if (IoStack->Parameters.DeviceIoControl.OutputBufferLength < sizeof(KSMULTIPLE_ITEM)) + { + /* buffer too small */ return STATUS_BUFFER_TOO_SMALL; } - - /* get multiple item */ - Item = (PKSMULTIPLE_ITEM)IoStack->Parameters.DeviceIoControl.Type3InputBuffer; Item->Count = DataItemsCount; Item->Size = DataItemSize; - /* copy items */ - RtlMoveMemory((PVOID)(Item + 1), DataItems, DataItemSize * DataItemsCount); - /* store result */ - Irp->IoStatus.Status = STATUS_SUCCESS; - Irp->IoStatus.Information = Size; - /* done */ - return STATUS_SUCCESS; + + if (IoStack->Parameters.DeviceIoControl.OutputBufferLength == sizeof(KSMULTIPLE_ITEM)) + { + /* buffer can only hold the length descriptor */ + return STATUS_SUCCESS; + } + + if (IoStack->Parameters.DeviceIoControl.OutputBufferLength >= Size) + { + /* copy items */ + RtlMoveMemory((PVOID)(Item + 1), DataItems, DataItemSize * DataItemsCount); + /* store result */ + Irp->IoStatus.Information = Size; + /* done */ + return STATUS_SUCCESS; + } + else + { + /* buffer too small */ + return STATUS_BUFFER_TOO_SMALL; + } } Modified: trunk/reactos/drivers/ksfilter/ks/topology.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/ksfilter/ks/topolo…
============================================================================== --- trunk/reactos/drivers/ksfilter/ks/topology.c [iso-8859-1] (original) +++ trunk/reactos/drivers/ksfilter/ks/topology.c [iso-8859-1] Sun Dec 20 12:17:02 2009 @@ -152,7 +152,6 @@ UNICODE_STRING GuidString; UNICODE_STRING KeyName; OBJECT_ATTRIBUTES ObjectAttributes; - KSMULTIPLE_ITEM * Item; KSP_NODE * Node; PIO_STACK_LOCATION IoStack; ULONG Size; @@ -174,69 +173,13 @@ switch(Property->Id) { case KSPROPERTY_TOPOLOGY_CATEGORIES: - Size = sizeof(KSMULTIPLE_ITEM) + Topology->CategoriesCount * sizeof(GUID); - if (IoStack->Parameters.DeviceIoControl.OutputBufferLength < Size) - { - Irp->IoStatus.Information = Size; - Status = STATUS_MORE_ENTRIES; - break; - } - - Item = (KSMULTIPLE_ITEM*)Irp->UserBuffer; - Item->Size = Size; - Item->Count = Topology->CategoriesCount; - - if (Topology->CategoriesCount) - { - RtlMoveMemory((PVOID)(Item + 1), (PVOID)Topology->Categories, Topology->CategoriesCount * sizeof(GUID)); - } - Irp->IoStatus.Information = Size; - Status = STATUS_SUCCESS; - break; + return KsHandleSizedListQuery(Irp, Topology->CategoriesCount, sizeof(GUID), Topology->Categories); case KSPROPERTY_TOPOLOGY_NODES: - Size = sizeof(KSMULTIPLE_ITEM) + Topology->TopologyNodesCount * sizeof(GUID); - if (IoStack->Parameters.DeviceIoControl.OutputBufferLength < Size) - { - Irp->IoStatus.Information = Size; - Status = STATUS_MORE_ENTRIES; - break; - } - - Item = (KSMULTIPLE_ITEM*)Irp->UserBuffer; - Item->Size = Size; - Item->Count = Topology->TopologyNodesCount; - - RtlMoveMemory((PVOID)(Item + 1), (PVOID)Topology->TopologyNodes, Topology->TopologyNodesCount * sizeof(GUID)); - if (Topology->TopologyNodesCount) - { - RtlMoveMemory((PVOID)(Item + 1), (PVOID)Topology->TopologyNodes, Topology->TopologyNodesCount * sizeof(GUID)); - } - Irp->IoStatus.Information = Size; - Status = STATUS_SUCCESS; - break; + return KsHandleSizedListQuery(Irp, Topology->TopologyNodesCount, sizeof(GUID), Topology->TopologyNodes); case KSPROPERTY_TOPOLOGY_CONNECTIONS: - Size = sizeof(KSMULTIPLE_ITEM) + Topology->TopologyConnectionsCount * sizeof(KSTOPOLOGY_CONNECTION); - if (IoStack->Parameters.DeviceIoControl.OutputBufferLength < Size) - { - Irp->IoStatus.Information = Size; - Status = STATUS_MORE_ENTRIES; - break; - } - - Item = (KSMULTIPLE_ITEM*)Irp->UserBuffer; - Item->Size = Size; - Item->Count = Topology->TopologyConnectionsCount; - - if (Topology->TopologyConnections) - { - RtlMoveMemory((PVOID)(Item + 1), (PVOID)Topology->TopologyConnections, Topology->TopologyConnectionsCount * sizeof(KSTOPOLOGY_CONNECTION)); - } - - Irp->IoStatus.Information = Size; - Status = STATUS_SUCCESS; - break; + return KsHandleSizedListQuery(Irp, Topology->TopologyConnectionsCount, sizeof(KSTOPOLOGY_CONNECTION), Topology->TopologyConnections); case KSPROPERTY_TOPOLOGY_NAME: Node = (KSP_NODE*)Property;
15 years
1
0
0
0
[janderwald] 44664: [MMIXER] - Add support for enumerating wave in/out devices. Based on the wdmaud driver code
by janderwald@svn.reactos.org
Author: janderwald Date: Sun Dec 20 01:55:55 2009 New Revision: 44664 URL:
http://svn.reactos.org/svn/reactos?rev=44664&view=rev
Log: [MMIXER] - Add support for enumerating wave in/out devices. Based on the wdmaud driver code Added: trunk/reactos/lib/drivers/sound/mmixer/wave.c (with props) Modified: trunk/reactos/lib/drivers/sound/mmixer/controls.c trunk/reactos/lib/drivers/sound/mmixer/filter.c trunk/reactos/lib/drivers/sound/mmixer/mixer.c trunk/reactos/lib/drivers/sound/mmixer/mmixer.h trunk/reactos/lib/drivers/sound/mmixer/mmixer.rbuild trunk/reactos/lib/drivers/sound/mmixer/priv.h Modified: trunk/reactos/lib/drivers/sound/mmixer/controls.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/sound/mmixer/c…
============================================================================== --- trunk/reactos/lib/drivers/sound/mmixer/controls.c [iso-8859-1] (original) +++ trunk/reactos/lib/drivers/sound/mmixer/controls.c [iso-8859-1] Sun Dec 20 01:55:55 2009 @@ -827,6 +827,7 @@ ULONG BytesReturned; KSP_PIN Pin; LPWSTR Buffer = NULL; + ULONG PinId; // allocate a mixer info struct MixerInfo = (LPMIXER_INFO) MixerContext->Alloc(sizeof(MIXER_INFO)); @@ -864,10 +865,15 @@ // now get the target pins of the ADC / DAC node Status = MMixerGetTargetPins(MixerContext, NodeTypes, NodeConnections, NodeIndex, !bInputMixer, Pins, PinCount); + // find a target pin with a name + PinId = PinCount +1; for(Index = 0; Index < PinCount; Index++) { if (Pins[Index]) { + // store index of pin + PinId = Index; + /* retrieve pin name */ Pin.PinId = Index; Pin.Reserved = 0; @@ -900,6 +906,12 @@ } } + if (PinId < PinCount) + { + // create an wave info struct + MMixerInitializeWaveInfo(MixerContext, MixerList, MixerData, MixerInfo->MixCaps.szPname, bInputMixer, PinId); + } + Status = MMixerCreateDestinationLine(MixerContext, MixerInfo, bInputMixer, Buffer); if (Buffer) Modified: trunk/reactos/lib/drivers/sound/mmixer/filter.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/sound/mmixer/f…
============================================================================== --- trunk/reactos/lib/drivers/sound/mmixer/filter.c [iso-8859-1] (original) +++ trunk/reactos/lib/drivers/sound/mmixer/filter.c [iso-8859-1] Sun Dec 20 01:55:55 2009 @@ -251,3 +251,27 @@ DPRINT("Status %x bSet %u NodeId %u Value %d PropertyId %u\n", Status, bSet, NodeId, Value, PropertyId); return Status; } + +ULONG +MMixerGetPinInstanceCount( + PMIXER_CONTEXT MixerContext, + HANDLE hFilter, + ULONG PinId) +{ + KSP_PIN PinRequest; + KSPIN_CINSTANCES PinInstances; + ULONG BytesReturned; + MIXER_STATUS Status; + + /* query the instance count */ + PinRequest.Reserved = 0; + PinRequest.PinId = PinId; + PinRequest.Property.Set = KSPROPSETID_Pin; + PinRequest.Property.Flags = KSPROPERTY_TYPE_GET; + PinRequest.Property.Id = KSPROPERTY_PIN_CINSTANCES; + + Status = MixerContext->Control(hFilter, IOCTL_KS_PROPERTY, (PVOID)&PinRequest, sizeof(KSP_PIN), (PVOID)&PinInstances, sizeof(KSPIN_CINSTANCES), &BytesReturned); + ASSERT(Status == MM_STATUS_SUCCESS); + return PinInstances.CurrentCount; +} + Modified: trunk/reactos/lib/drivers/sound/mmixer/mixer.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/sound/mmixer/m…
============================================================================== --- trunk/reactos/lib/drivers/sound/mmixer/mixer.c [iso-8859-1] (original) +++ trunk/reactos/lib/drivers/sound/mmixer/mixer.c [iso-8859-1] Sun Dec 20 01:55:55 2009 @@ -215,7 +215,7 @@ IN PMIXER_CONTEXT MixerContext, IN HANDLE MixerHandle, IN ULONG Flags, - OUT LPMIXERLINECONTROLS MixerLineControls) + OUT LPMIXERLINECONTROLSW MixerLineControls) { LPMIXER_INFO MixerInfo; LPMIXERLINE_EXT MixerLineSrc; @@ -440,8 +440,13 @@ //initialize mixer list MixerList->MixerListCount = 0; MixerList->MixerDataCount = 0; + MixerList->WaveInListCount = 0; + MixerList->WaveOutListCount = 0; InitializeListHead(&MixerList->MixerList); InitializeListHead(&MixerList->MixerData); + InitializeListHead(&MixerList->WaveInList); + InitializeListHead(&MixerList->WaveOutList); + // store mixer list MixerContext->MixerContext = (PVOID)MixerList; Modified: trunk/reactos/lib/drivers/sound/mmixer/mmixer.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/sound/mmixer/m…
============================================================================== --- trunk/reactos/lib/drivers/sound/mmixer/mmixer.h [iso-8859-1] (original) +++ trunk/reactos/lib/drivers/sound/mmixer/mmixer.h [iso-8859-1] Sun Dec 20 01:55:55 2009 @@ -95,6 +95,15 @@ MMixerGetCount( IN PMIXER_CONTEXT MixerContext); +ULONG +MMixerGetWaveInCount( + IN PMIXER_CONTEXT MixerContext); + +ULONG +MMixerGetWaveOutCount( + IN PMIXER_CONTEXT MixerContext); + + MIXER_STATUS MMixerGetCapabilities( IN PMIXER_CONTEXT MixerContext, @@ -121,7 +130,7 @@ IN PMIXER_CONTEXT MixerContext, IN HANDLE MixerHandle, IN ULONG Flags, - OUT LPMIXERLINECONTROLS MixerLineControls); + OUT LPMIXERLINECONTROLSW MixerLineControls); MIXER_STATUS MMixerSetControlDetails( @@ -137,4 +146,24 @@ IN ULONG Flags, OUT LPMIXERCONTROLDETAILS MixerControlDetails); +MIXER_STATUS +MMixerWaveOutCapabilities( + IN PMIXER_CONTEXT MixerContext, + IN ULONG DeviceIndex, + OUT LPWAVEOUTCAPSW Caps); + +MIXER_STATUS +MMixerWaveInCapabilities( + IN PMIXER_CONTEXT MixerContext, + IN ULONG DeviceIndex, + OUT LPWAVEINCAPSW Caps); + +MIXER_STATUS +MMixerOpenWave( + IN PMIXER_CONTEXT MixerContext, + IN ULONG DeviceIndex, + IN ULONG bWaveIn, + IN LPWAVEFORMATEX WaveFormat, + OUT PHANDLE PinHandle); + #endif Modified: trunk/reactos/lib/drivers/sound/mmixer/mmixer.rbuild URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/sound/mmixer/m…
============================================================================== --- trunk/reactos/lib/drivers/sound/mmixer/mmixer.rbuild [iso-8859-1] (original) +++ trunk/reactos/lib/drivers/sound/mmixer/mmixer.rbuild [iso-8859-1] Sun Dec 20 01:55:55 2009 @@ -7,4 +7,5 @@ <file>filter.c</file> <file>mixer.c</file> <file>sup.c</file> + <file>wave.c</file> </module> Modified: trunk/reactos/lib/drivers/sound/mmixer/priv.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/sound/mmixer/p…
============================================================================== --- trunk/reactos/lib/drivers/sound/mmixer/priv.h [iso-8859-1] (original) +++ trunk/reactos/lib/drivers/sound/mmixer/priv.h [iso-8859-1] Sun Dec 20 01:55:55 2009 @@ -66,10 +66,26 @@ typedef struct { + LIST_ENTRY Entry; + ULONG DeviceId; + ULONG PinId; + union + { + WAVEOUTCAPSW OutCaps; + WAVEINCAPSW InCaps; + }u; +}WAVE_INFO, *LPWAVE_INFO; + +typedef struct +{ ULONG MixerListCount; LIST_ENTRY MixerList; ULONG MixerDataCount; LIST_ENTRY MixerData; + ULONG WaveInListCount; + LIST_ENTRY WaveInList; + ULONG WaveOutListCount; + LIST_ENTRY WaveOutList; }MIXER_LIST, *PMIXER_LIST; #define DESTINATION_LINE 0xFFFF0000 @@ -243,4 +259,13 @@ IN LPMIXER_INFO MixerInfo, IN HANDLE hKey); +MIXER_STATUS +MMixerInitializeWaveInfo( + IN PMIXER_CONTEXT MixerContext, + IN PMIXER_LIST MixerList, + IN LPMIXER_DATA MixerData, + IN LPWSTR DeviceName, + IN ULONG bWaveIn, + IN ULONG PinId); + #endif Added: trunk/reactos/lib/drivers/sound/mmixer/wave.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/sound/mmixer/w…
============================================================================== --- trunk/reactos/lib/drivers/sound/mmixer/wave.c (added) +++ trunk/reactos/lib/drivers/sound/mmixer/wave.c [iso-8859-1] Sun Dec 20 01:55:55 2009 @@ -1,0 +1,578 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS Kernel Streaming + * FILE: lib/drivers/sound/mmixer/mmixer.c + * PURPOSE: Mixer Handling Functions + * PROGRAMMER: Johannes Anderwald + */ + +#include "priv.h" + +const GUID KSDATAFORMAT_SPECIFIER_WAVEFORMATEX = {0x05589f81L, 0xc356, 0x11ce, {0xbf, 0x01, 0x00, 0xaa, 0x00, 0x55, 0x59, 0x5a}}; +const GUID KSDATAFORMAT_SUBTYPE_PCM = {0x00000001L, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}}; +const GUID KSDATAFORMAT_TYPE_AUDIO = {0x73647561L, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}}; +const GUID KSINTERFACESETID_Standard = {0x1A8766A0L, 0x62CE, 0x11CF, {0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00}}; +const GUID KSMEDIUMSETID_Standard = {0x4747B320L, 0x62CE, 0x11CF, {0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00}}; + +typedef struct +{ + ULONG SampleRate; + ULONG Bit8Mono; + ULONG Bit8Stereo; + ULONG Bit16Mono; + ULONG Bit16Stereo; +}AUDIO_RANGE; + +#define AUDIO_TEST_RANGE (5) + +static AUDIO_RANGE TestRange[AUDIO_TEST_RANGE] = +{ + { + 11025, + WAVE_FORMAT_1M08, + WAVE_FORMAT_1S08, + WAVE_FORMAT_1M16, + WAVE_FORMAT_1S16 + }, + { + 22050, + WAVE_FORMAT_2M08, + WAVE_FORMAT_2S08, + WAVE_FORMAT_2M16, + WAVE_FORMAT_2S16 + }, + { + 44100, + WAVE_FORMAT_4M08, + WAVE_FORMAT_4S08, + WAVE_FORMAT_4M16, + WAVE_FORMAT_4S16 + }, + { + 48000, + WAVE_FORMAT_48M08, + WAVE_FORMAT_48S08, + WAVE_FORMAT_48M16, + WAVE_FORMAT_48S16 + }, + { + 96000, + WAVE_FORMAT_96M08, + WAVE_FORMAT_96S08, + WAVE_FORMAT_96M16, + WAVE_FORMAT_96S16 + } +}; + +PKSPIN_CONNECT +MMixerAllocatePinConnect( + IN PMIXER_CONTEXT MixerContext, + ULONG DataFormatSize) +{ + return MixerContext->Alloc(sizeof(KSPIN_CONNECT) + DataFormatSize); +} + +MIXER_STATUS +MMixerGetWaveInfoByIndexAndType( + IN PMIXER_LIST MixerList, + IN ULONG DeviceIndex, + IN ULONG bWaveInType, + OUT LPWAVE_INFO *OutWaveInfo) +{ + ULONG Index = 0; + PLIST_ENTRY Entry, ListHead; + LPWAVE_INFO WaveInfo; + + if (bWaveInType) + ListHead = &MixerList->WaveInList; + else + ListHead = &MixerList->WaveOutList; + + /* get first entry */ + Entry = ListHead->Flink; + + while(Entry != ListHead) + { + WaveInfo = (LPWAVE_INFO)CONTAINING_RECORD(Entry, WAVE_INFO, Entry); + + if (Index == DeviceIndex) + { + *OutWaveInfo = WaveInfo; + return MM_STATUS_SUCCESS; + } + Index++; + Entry = Entry->Flink; + } + + return MM_STATUS_INVALID_PARAMETER; +} + + +VOID +MMixerInitializePinConnect( + IN OUT PKSPIN_CONNECT PinConnect, + IN ULONG PinId) +{ + PinConnect->Interface.Set = KSINTERFACESETID_Standard; + PinConnect->Interface.Id = KSINTERFACE_STANDARD_STREAMING; + PinConnect->Interface.Flags = 0; + PinConnect->Medium.Set = KSMEDIUMSETID_Standard; + PinConnect->Medium.Id = KSMEDIUM_TYPE_ANYINSTANCE; + PinConnect->Medium.Flags = 0; + PinConnect->PinToHandle = NULL; + PinConnect->PinId = PinId; + PinConnect->Priority.PriorityClass = KSPRIORITY_NORMAL; + PinConnect->Priority.PrioritySubClass = 1; +} + +VOID +MMixerInitializeDataFormat( + IN PKSDATAFORMAT_WAVEFORMATEX DataFormat, + LPWAVEFORMATEX WaveFormatEx) +{ + + DataFormat->WaveFormatEx.wFormatTag = WaveFormatEx->wFormatTag; + DataFormat->WaveFormatEx.nChannels = WaveFormatEx->nChannels; + DataFormat->WaveFormatEx.nSamplesPerSec = WaveFormatEx->nSamplesPerSec; + DataFormat->WaveFormatEx.nBlockAlign = WaveFormatEx->nBlockAlign; + DataFormat->WaveFormatEx.nAvgBytesPerSec = WaveFormatEx->nAvgBytesPerSec; + DataFormat->WaveFormatEx.wBitsPerSample = WaveFormatEx->wBitsPerSample; + DataFormat->WaveFormatEx.cbSize = 0; + DataFormat->DataFormat.FormatSize = sizeof(KSDATAFORMAT) + sizeof(WAVEFORMATEX); + DataFormat->DataFormat.Flags = 0; + DataFormat->DataFormat.Reserved = 0; + DataFormat->DataFormat.MajorFormat = KSDATAFORMAT_TYPE_AUDIO; + + DataFormat->DataFormat.SubFormat = KSDATAFORMAT_SUBTYPE_PCM; + DataFormat->DataFormat.Specifier = KSDATAFORMAT_SPECIFIER_WAVEFORMATEX; + DataFormat->DataFormat.SampleSize = 4; +} + + +MIXER_STATUS +MMixerGetAudioPinDataRanges( + IN PMIXER_CONTEXT MixerContext, + IN HANDLE hDevice, + IN ULONG PinId, + IN OUT PKSMULTIPLE_ITEM * OutMultipleItem) +{ + KSP_PIN PinProperty; + ULONG BytesReturned = 0; + MIXER_STATUS Status; + PKSMULTIPLE_ITEM MultipleItem; + + /* retrieve size of data ranges buffer */ + PinProperty.Reserved = 0; + PinProperty.PinId = PinId; + PinProperty.Property.Set = KSPROPSETID_Pin; + PinProperty.Property.Id = KSPROPERTY_PIN_DATARANGES; + PinProperty.Property.Flags = KSPROPERTY_TYPE_GET; + + Status = MixerContext->Control(hDevice, IOCTL_KS_PROPERTY, (PVOID)&PinProperty, sizeof(KSP_PIN), (PVOID)NULL, 0, &BytesReturned); + if (Status != MM_STATUS_MORE_ENTRIES) + { + return Status; + } + + MultipleItem = MixerContext->Alloc(BytesReturned); + if (!MultipleItem) + { + /* not enough memory */ + return MM_STATUS_NO_MEMORY; + } + + Status = MixerContext->Control(hDevice, IOCTL_KS_PROPERTY, (PVOID)&PinProperty, sizeof(KSP_PIN), (PVOID)MultipleItem, BytesReturned, &BytesReturned); + if (Status != MM_STATUS_SUCCESS) + { + /* failed */ + MixerContext->Free(MultipleItem); + return Status; + } + + /* save result */ + *OutMultipleItem = MultipleItem; + return Status; +} + +MIXER_STATUS +MMixerFindAudioDataRange( + PKSMULTIPLE_ITEM MultipleItem, + PKSDATARANGE_AUDIO * OutDataRangeAudio) +{ + ULONG Index; + PKSDATARANGE_AUDIO DataRangeAudio; + PKSDATARANGE DataRange; + + DataRange = (PKSDATARANGE) (MultipleItem + 1); + for(Index = 0; Index < MultipleItem->Count; Index++) + { + if (DataRange->FormatSize == sizeof(KSDATARANGE_AUDIO)) + { + DataRangeAudio = (PKSDATARANGE_AUDIO)DataRange; + if (IsEqualGUIDAligned(&DataRangeAudio->DataRange.MajorFormat, &KSDATAFORMAT_TYPE_AUDIO) && + IsEqualGUIDAligned(&DataRangeAudio->DataRange.SubFormat, &KSDATAFORMAT_SUBTYPE_PCM) && + IsEqualGUIDAligned(&DataRangeAudio->DataRange.Specifier, &KSDATAFORMAT_SPECIFIER_WAVEFORMATEX)) + { + DPRINT("Min Sample %u Max Sample %u Min Bits %u Max Bits %u Max Channel %u\n", DataRangeAudio->MinimumSampleFrequency, DataRangeAudio->MaximumSampleFrequency, + DataRangeAudio->MinimumBitsPerSample, DataRangeAudio->MaximumBitsPerSample, DataRangeAudio->MaximumChannels); + *OutDataRangeAudio = DataRangeAudio; + return MM_STATUS_SUCCESS; + } + } + DataRange = (PKSDATARANGE)((ULONG_PTR)DataRange + DataRange->FormatSize); + } + return MM_STATUS_UNSUCCESSFUL; +} + +MIXER_STATUS +MMixerOpenWavePin( + IN PMIXER_CONTEXT MixerContext, + IN PMIXER_LIST MixerList, + IN ULONG DeviceId, + IN ULONG PinId, + IN LPWAVEFORMATEX WaveFormatEx, + IN ACCESS_MASK DesiredAccess, + OUT PHANDLE PinHandle) +{ + PKSPIN_CONNECT PinConnect; + PKSDATAFORMAT_WAVEFORMATEX DataFormat; + LPMIXER_DATA MixerData; + NTSTATUS Status; + + MixerData = MMixerGetDataByDeviceId(MixerList, DeviceId); + if (!MixerData) + return MM_STATUS_INVALID_PARAMETER; + + /* allocate pin connect */ + PinConnect = MMixerAllocatePinConnect(MixerContext, sizeof(KSDATAFORMAT_WAVEFORMATEX)); + if (!PinConnect) + { + /* no memory */ + return MM_STATUS_NO_MEMORY; + } + + /* initialize pin connect struct */ + MMixerInitializePinConnect(PinConnect, PinId); + + /* get offset to dataformat */ + DataFormat = (PKSDATAFORMAT_WAVEFORMATEX) (PinConnect + 1); + /* initialize with requested wave format */ + MMixerInitializeDataFormat(DataFormat, WaveFormatEx); + + /* now create the pin */ + Status = KsCreatePin(MixerData->hDevice, PinConnect, DesiredAccess, PinHandle); + + /* free create info */ + MixerContext->Free(PinConnect); + + if (Status == STATUS_SUCCESS) + return MM_STATUS_SUCCESS; + else + return MM_STATUS_UNSUCCESSFUL; +} + +VOID +MMixerCheckFormat( + IN PKSDATARANGE_AUDIO DataRangeAudio, + IN LPWAVE_INFO WaveInfo, + IN ULONG bInput) +{ + ULONG Index, SampleFrequency; + ULONG Result = 0; + + for(Index = 0; Index < AUDIO_TEST_RANGE; Index++) + { + SampleFrequency = TestRange[Index].SampleRate; + + if (DataRangeAudio->MinimumSampleFrequency <= SampleFrequency && DataRangeAudio->MaximumSampleFrequency >= SampleFrequency) + { + /* the audio adapter supports the sample frequency */ + if (DataRangeAudio->MinimumBitsPerSample <= 8 && DataRangeAudio->MaximumBitsPerSample >= 8) + { + Result |= TestRange[Index].Bit8Mono; + + if (DataRangeAudio->MaximumChannels > 1) + { + /* check if pin supports the sample rate in 8-Bit Stereo */ + Result |= TestRange[Index].Bit8Stereo; + } + } + + if (DataRangeAudio->MinimumBitsPerSample <= 16 && DataRangeAudio->MaximumBitsPerSample >= 16) + { + /* check if pin supports the sample rate in 16-Bit Mono */ + Result |= TestRange[Index].Bit16Mono; + + + if (DataRangeAudio->MaximumChannels > 1) + { + /* check if pin supports the sample rate in 16-Bit Stereo */ + Result |= TestRange[Index].Bit16Stereo; + } + } + } + } + + + if (bInput) + WaveInfo->u.InCaps.dwFormats = Result; + else + WaveInfo->u.OutCaps.dwFormats = Result; + + DPRINT("Format %lx bInput %u\n", Result, bInput); +} + +MIXER_STATUS +MMixerInitializeWaveInfo( + IN PMIXER_CONTEXT MixerContext, + IN PMIXER_LIST MixerList, + IN LPMIXER_DATA MixerData, + IN LPWSTR DeviceName, + IN ULONG bWaveIn, + IN ULONG PinId) +{ + MIXER_STATUS Status; + PKSMULTIPLE_ITEM MultipleItem; + PKSDATARANGE_AUDIO DataRangeAudio; + LPWAVE_INFO WaveInfo; + + WaveInfo = (LPWAVE_INFO)MixerContext->Alloc(sizeof(WAVE_INFO)); + if (!WaveInfo) + return MM_STATUS_NO_MEMORY; + + /* initialize wave info */ + WaveInfo->DeviceId = MixerData->DeviceId; + WaveInfo->PinId = PinId; + + /* FIXME determine manufacturer / product id */ + if (bWaveIn) + { + WaveInfo->u.InCaps.wMid = MM_MICROSOFT; + WaveInfo->u.InCaps.wPid = MM_PID_UNMAPPED; + WaveInfo->u.InCaps.vDriverVersion = 1; + } + else + { + WaveInfo->u.OutCaps.wMid = MM_MICROSOFT; + WaveInfo->u.OutCaps.wPid = MM_PID_UNMAPPED; + WaveInfo->u.OutCaps.vDriverVersion = 1; + } + + /* get audio pin data ranges */ + Status = MMixerGetAudioPinDataRanges(MixerContext, MixerData->hDevice, PinId, &MultipleItem); + if (Status != MM_STATUS_SUCCESS) + { + /* failed to get audio pin data ranges */ + MixerContext->Free(WaveInfo); + return MM_STATUS_UNSUCCESSFUL; + } + + /* find an KSDATARANGE_AUDIO range */ + Status = MMixerFindAudioDataRange(MultipleItem, &DataRangeAudio); + if (Status != MM_STATUS_SUCCESS) + { + /* failed to find audio pin data range */ + MixerContext->Free(MultipleItem); + MixerContext->Free(WaveInfo); + return MM_STATUS_UNSUCCESSFUL; + } + + /* store channel count */ + if (bWaveIn) + { + WaveInfo->u.InCaps.wChannels = DataRangeAudio->MaximumChannels; + } + else + { + WaveInfo->u.OutCaps.wChannels = DataRangeAudio->MaximumChannels; + } + + /* get all supported formats */ + MMixerCheckFormat(DataRangeAudio, WaveInfo, bWaveIn); + + /* free dataranges buffer */ + MixerContext->Free(MultipleItem); + + + if (bWaveIn) + { + InsertTailList(&MixerList->WaveInList, &WaveInfo->Entry); + MixerList->WaveInListCount++; + } + else + { + InsertTailList(&MixerList->WaveOutList, &WaveInfo->Entry); + MixerList->WaveOutListCount++; + } + + return MM_STATUS_SUCCESS; +} + +MIXER_STATUS +MMixerOpenWave( + IN PMIXER_CONTEXT MixerContext, + IN ULONG DeviceIndex, + IN ULONG bWaveIn, + IN LPWAVEFORMATEX WaveFormat, + OUT PHANDLE PinHandle) +{ + PMIXER_LIST MixerList; + MIXER_STATUS Status; + LPWAVE_INFO WaveInfo; + ACCESS_MASK DesiredAccess = 0; + + // verify mixer context + Status = MMixerVerifyContext(MixerContext); + + if (Status != MM_STATUS_SUCCESS) + { + // invalid context passed + return Status; + } + + // grab mixer list + MixerList = (PMIXER_LIST)MixerContext->MixerContext; + + if (WaveFormat->wFormatTag != WAVE_FORMAT_PCM) + { + // not implemented + return MM_STATUS_NOT_IMPLEMENTED; + } + + /* find destination wave */ + Status = MMixerGetWaveInfoByIndexAndType(MixerList, DeviceIndex, bWaveIn, &WaveInfo); + if (Status != MM_STATUS_SUCCESS) + { + /* failed to find wave info */ + return MM_STATUS_INVALID_PARAMETER; + } + + /* get desired access */ + if (bWaveIn) + { + DesiredAccess |= GENERIC_READ; + } + else + { + DesiredAccess |= GENERIC_WRITE; + } + + /* now try open the pin */ + return MMixerOpenWavePin(MixerContext, MixerList, WaveInfo->DeviceId, WaveInfo->PinId, WaveFormat, DesiredAccess, PinHandle); +} + +MIXER_STATUS +MMixerWaveInCapabilities( + IN PMIXER_CONTEXT MixerContext, + IN ULONG DeviceIndex, + OUT LPWAVEINCAPSW Caps) +{ + PMIXER_LIST MixerList; + MIXER_STATUS Status; + LPWAVE_INFO WaveInfo; + + // verify mixer context + Status = MMixerVerifyContext(MixerContext); + + if (Status != MM_STATUS_SUCCESS) + { + // invalid context passed + return Status; + } + + // grab mixer list + MixerList = (PMIXER_LIST)MixerContext->MixerContext; + + /* find destination wave */ + Status = MMixerGetWaveInfoByIndexAndType(MixerList, DeviceIndex, TRUE, &WaveInfo); + if (Status != MM_STATUS_SUCCESS) + { + /* failed to find wave info */ + return MM_STATUS_UNSUCCESSFUL; + } + + //copy capabilities + MixerContext->Copy(Caps, &WaveInfo->u.InCaps, sizeof(WAVEINCAPSW)); + + return MM_STATUS_SUCCESS; +} + +MIXER_STATUS +MMixerWaveOutCapabilities( + IN PMIXER_CONTEXT MixerContext, + IN ULONG DeviceIndex, + OUT LPWAVEOUTCAPSW Caps) +{ + PMIXER_LIST MixerList; + MIXER_STATUS Status; + LPWAVE_INFO WaveInfo; + + // verify mixer context + Status = MMixerVerifyContext(MixerContext); + + if (Status != MM_STATUS_SUCCESS) + { + // invalid context passed + return Status; + } + + // grab mixer list + MixerList = (PMIXER_LIST)MixerContext->MixerContext; + + /* find destination wave */ + Status = MMixerGetWaveInfoByIndexAndType(MixerList, DeviceIndex, FALSE, &WaveInfo); + if (Status != MM_STATUS_SUCCESS) + { + /* failed to find wave info */ + return MM_STATUS_UNSUCCESSFUL; + } + + //copy capabilities + MixerContext->Copy(Caps, &WaveInfo->u.OutCaps, sizeof(WAVEOUTCAPSW)); + + return MM_STATUS_SUCCESS; +} + +ULONG +MMixerGetWaveInCount( + IN PMIXER_CONTEXT MixerContext) +{ + PMIXER_LIST MixerList; + MIXER_STATUS Status; + + // verify mixer context + Status = MMixerVerifyContext(MixerContext); + + if (Status != MM_STATUS_SUCCESS) + { + // invalid context passed + return 0; + } + + // grab mixer list + MixerList = (PMIXER_LIST)MixerContext->MixerContext; + + return MixerList->WaveInListCount; +} + +ULONG +MMixerGetWaveOutCount( + IN PMIXER_CONTEXT MixerContext) +{ + PMIXER_LIST MixerList; + MIXER_STATUS Status; + + // verify mixer context + Status = MMixerVerifyContext(MixerContext); + + if (Status != MM_STATUS_SUCCESS) + { + // invalid context passed + return 0; + } + + // grab mixer list + MixerList = (PMIXER_LIST)MixerContext->MixerContext; + + return MixerList->WaveOutListCount; +} Propchange: trunk/reactos/lib/drivers/sound/mmixer/wave.c ------------------------------------------------------------------------------ svn:eol-style = native
15 years
1
0
0
0
[janderwald] 44663: [WDMAUD.DRV] - Implement support of using mmixer wave in/out library functions (not yet used) - Not yet used - Remove DIGCF_PRESENT flag from device list as setupapi cannot handle this yet properly
by janderwald@svn.reactos.org
Author: janderwald Date: Sun Dec 20 01:55:52 2009 New Revision: 44663 URL:
http://svn.reactos.org/svn/reactos?rev=44663&view=rev
Log: [WDMAUD.DRV] - Implement support of using mmixer wave in/out library functions (not yet used) - Not yet used - Remove DIGCF_PRESENT flag from device list as setupapi cannot handle this yet properly Modified: trunk/reactos/dll/win32/wdmaud.drv/mmixer.c trunk/reactos/dll/win32/wdmaud.drv/wdmaud.c trunk/reactos/dll/win32/wdmaud.drv/wdmaud.h trunk/reactos/dll/win32/wdmaud.drv/wdmaud.rbuild Modified: trunk/reactos/dll/win32/wdmaud.drv/mmixer.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/wdmaud.drv/mmixe…
============================================================================== --- trunk/reactos/dll/win32/wdmaud.drv/mmixer.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/wdmaud.drv/mmixer.c [iso-8859-1] Sun Dec 20 01:55:52 2009 @@ -295,7 +295,7 @@ DeviceHandle = SetupDiGetClassDevs(&CategoryGuid, NULL, NULL, - DIGCF_DEVICEINTERFACE|DIGCF_PRESENT); + DIGCF_DEVICEINTERFACE/* FIXME |DIGCF_PRESENT*/); if (DeviceHandle == INVALID_HANDLE_VALUE) { @@ -408,3 +408,54 @@ return MMSYSERR_ERROR; } + +ULONG +WdmAudGetWaveOutCount() +{ + return MMixerGetWaveOutCount(&MixerContext); +} + +ULONG +WdmAudGetWaveInCount() +{ + return MMixerGetWaveInCount(&MixerContext); +} + +MMRESULT +WdmAudGetWaveOutCapabilities( + IN ULONG DeviceId, + LPWAVEOUTCAPSW Capabilities) +{ + if (MMixerWaveOutCapabilities(&MixerContext, DeviceId, Capabilities) == MM_STATUS_SUCCESS) + return MMSYSERR_NOERROR; + + return MMSYSERR_ERROR; + +} + +MMRESULT +WdmAudGetWaveInCapabilities( + IN ULONG DeviceId, + LPWAVEINCAPSW Capabilities) +{ + if (MMixerWaveInCapabilities(&MixerContext, DeviceId, Capabilities) == MM_STATUS_SUCCESS) + return MMSYSERR_NOERROR; + + return MMSYSERR_ERROR; +} + +MMRESULT +WdmAudOpenWave( + OUT PHANDLE hPin, + IN DWORD DeviceId, + IN PWAVEFORMATEX WaveFormat, + IN DWORD bWaveIn) +{ + if (MMixerOpenWave(&MixerContext, DeviceId, bWaveIn, WaveFormat, hPin) == MM_STATUS_SUCCESS) + { + //fixme + // start stream if waveout + return MMSYSERR_NOERROR; + } + return MMSYSERR_ERROR; +} Modified: trunk/reactos/dll/win32/wdmaud.drv/wdmaud.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/wdmaud.drv/wdmau…
============================================================================== --- trunk/reactos/dll/win32/wdmaud.drv/wdmaud.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/wdmaud.drv/wdmaud.c [iso-8859-1] Sun Dec 20 01:55:52 2009 @@ -44,7 +44,20 @@ { #ifdef USE_MMIXER_LIB - *DeviceCount = WdmAudGetMixerCount(); + switch(DeviceType) + { + case MIXER_DEVICE_TYPE: + *DeviceCount = WdmAudGetMixerCount(); + break; + case WAVE_OUT_DEVICE_TYPE: + *DeviceCount = WdmAudGetWaveOutCount(); + break; + case WAVE_IN_DEVICE_TYPE: + *DeviceCount = WdmAudGetWaveInCount(); + break; + default: + *DeviceCount = 0; + } return MMSYSERR_NOERROR; #else @@ -106,8 +119,17 @@ #ifdef USE_MMIXER_LIB if (DeviceType == MIXER_DEVICE_TYPE) { - return WdmAudGetMixerCapabilties(DeviceId, (LPMIXERCAPSW)Capabilities); - } + return WdmAudGetMixerCapabilities(DeviceId, (LPMIXERCAPSW)Capabilities); + } + else if (DeviceType == WAVE_OUT_DEVICE_TYPE) + { + return WdmAudGetWaveOutCapabilities(DeviceId, (LPWAVEOUTCAPSW)Capabilities); + } + else if (DeviceType == WAVE_IN_DEVICE_TYPE) + { + return WdmAudGetWaveInCapabilities(DeviceId, (LPWAVEINCAPSW)Capabilities); + } + #endif @@ -459,8 +481,13 @@ return MMSYSERR_NOERROR; } - Result = GetSoundDeviceType(SoundDevice, &DeviceType); + +#ifdef USE_MMIXER_LIB + return WdmAudOpenWavePin(Instance, DeviceId, WaveFormat, DeviceType); +#endif + + SND_ASSERT( Result == MMSYSERR_NOERROR ); ZeroMemory(&DeviceInfo, sizeof(WDMAUD_DEVICE_INFO)); Modified: trunk/reactos/dll/win32/wdmaud.drv/wdmaud.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/wdmaud.drv/wdmau…
============================================================================== --- trunk/reactos/dll/win32/wdmaud.drv/wdmaud.h [iso-8859-1] (original) +++ trunk/reactos/dll/win32/wdmaud.drv/wdmaud.h [iso-8859-1] Sun Dec 20 01:55:52 2009 @@ -18,12 +18,28 @@ WdmAudInitUserModeMixer(); ULONG +WdmAudGetWaveOutCount(); + +ULONG +WdmAudGetWaveInCount(); + +ULONG WdmAudGetMixerCount(); MMRESULT WdmAudGetMixerCapabilties( IN ULONG DeviceId, LPMIXERCAPSW Capabilities); + +MMRESULT +WdmAudGetWaveOutCapabilities( + IN ULONG DeviceId, + LPWAVEOUTCAPSW Capabilities); + +MMRESULT +WdmAudGetWaveInCapabilities( + IN ULONG DeviceId, + LPWAVEINCAPSW Capabilities); MMRESULT WdmAudCloseMixer( @@ -35,6 +51,14 @@ IN PHANDLE hMixer, IN ULONG DeviceId, IN HANDLE hNotifyEvent); + +MMRESULT +WdmAudOpenWave( + OUT PHANDLE hPin, + IN DWORD DeviceId, + IN PWAVEFORMATEX WaveFormat, + IN DWORD bWaveIn); + MMRESULT WdmAudGetLineInfo( Modified: trunk/reactos/dll/win32/wdmaud.drv/wdmaud.rbuild URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/wdmaud.drv/wdmau…
============================================================================== --- trunk/reactos/dll/win32/wdmaud.drv/wdmaud.rbuild [iso-8859-1] (original) +++ trunk/reactos/dll/win32/wdmaud.drv/wdmaud.rbuild [iso-8859-1] Sun Dec 20 01:55:52 2009 @@ -16,6 +16,7 @@ <library>msvcrt</library> <library>mmixer</library> <library>setupapi</library> + <library>ksuser</library> <file>wdmaud.c</file> <file>mixer.c</file> <file>mmixer.c</file>
15 years
1
0
0
0
← Newer
1
...
15
16
17
18
19
20
21
...
51
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
Results per page:
10
25
50
100
200