ReactOS.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
List overview
Download
Ros-diffs
November 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
23 participants
444 discussions
Start a n
N
ew thread
[fireball] 44236: [wininet] - Update wininet to Wine-1.1.33.
by fireball@svn.reactos.org
Author: fireball Date: Fri Nov 20 15:22:05 2009 New Revision: 44236 URL:
http://svn.reactos.org/svn/reactos?rev=44236&view=rev
Log: [wininet] - Update wininet to Wine-1.1.33. Added: trunk/reactos/dll/win32/wininet/wininet_Lt.rc (with props) Modified: trunk/reactos/dll/win32/wininet/cookie.c trunk/reactos/dll/win32/wininet/ftp.c trunk/reactos/dll/win32/wininet/http.c trunk/reactos/dll/win32/wininet/internet.c trunk/reactos/dll/win32/wininet/netconnection.c trunk/reactos/dll/win32/wininet/urlcache.c trunk/reactos/dll/win32/wininet/wininet.spec Modified: trunk/reactos/dll/win32/wininet/cookie.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/wininet/cookie.c…
============================================================================== --- trunk/reactos/dll/win32/wininet/cookie.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/wininet/cookie.c [iso-8859-1] Fri Nov 20 15:22:05 2009 @@ -163,7 +163,6 @@ static BOOL COOKIE_crackUrlSimple(LPCWSTR lpszUrl, LPWSTR hostName, int hostNameLen, LPWSTR path, int pathLen) { URL_COMPONENTSW UrlComponents; - BOOL rc; UrlComponents.lpszExtraInfo = NULL; UrlComponents.lpszPassword = NULL; @@ -178,22 +177,28 @@ UrlComponents.dwHostNameLength = hostNameLen; UrlComponents.dwUrlPathLength = pathLen; - rc = InternetCrackUrlW(lpszUrl, 0, 0, &UrlComponents); + if (!InternetCrackUrlW(lpszUrl, 0, 0, &UrlComponents)) return FALSE; /* discard the webpage off the end of the path */ - if (pathLen > 0 && path[pathLen-1] != '/') - { - LPWSTR ptr; - ptr = strrchrW(path,'/'); - if (ptr) - *(++ptr) = 0; - else - { - path[0] = '/'; - path[1] = 0; - } - } - return rc; + if (UrlComponents.dwUrlPathLength) + { + if (path[UrlComponents.dwUrlPathLength - 1] != '/') + { + WCHAR *ptr; + if ((ptr = strrchrW(path, '/'))) *(++ptr) = 0; + else + { + path[0] = '/'; + path[1] = 0; + } + } + } + else if (pathLen >= 2) + { + path[0] = '/'; + path[1] = 0; + } + return TRUE; } /* match a domain. domain must match if the domain is not NULL. path must match if the path is not NULL */ @@ -569,7 +574,7 @@ return FALSE; } - hostName[0] = path[0] = 0; + hostName[0] = 0; ret = COOKIE_crackUrlSimple(lpszUrl, hostName, sizeof(hostName)/sizeof(hostName[0]), path, sizeof(path)/sizeof(path[0])); if (!ret || !hostName[0]) return FALSE; Modified: trunk/reactos/dll/win32/wininet/ftp.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/wininet/ftp.c?re…
============================================================================== --- trunk/reactos/dll/win32/wininet/ftp.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/wininet/ftp.c [iso-8859-1] Fri Nov 20 15:22:05 2009 @@ -1293,6 +1293,7 @@ lpwh->hdr.vtbl = &FTPFILEVtbl; lpwh->hdr.dwFlags = dwFlags; lpwh->hdr.dwContext = dwContext; + lpwh->hdr.dwInternalFlags = 0; lpwh->hdr.refs = 1; lpwh->hdr.lpfnStatusCB = lpwfs->hdr.lpfnStatusCB; lpwh->nDataSocket = nDataSocket; Modified: trunk/reactos/dll/win32/wininet/http.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/wininet/http.c?r…
============================================================================== --- trunk/reactos/dll/win32/wininet/http.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/wininet/http.c [iso-8859-1] Fri Nov 20 15:22:05 2009 @@ -3340,8 +3340,16 @@ req = &workRequest.u.HttpSendRequestW; if (lpBuffersIn) { - /* FIXME: this should use dwHeadersLength or may not be necessary at all */ - req->lpszHeader = heap_strdupW(lpBuffersIn->lpcszHeader); + DWORD size; + + if (lpBuffersIn->dwHeadersLength == ~0u) + size = (strlenW( lpBuffersIn->lpcszHeader ) + 1) * sizeof(WCHAR); + else + size = lpBuffersIn->dwHeadersLength * sizeof(WCHAR); + + req->lpszHeader = HeapAlloc( GetProcessHeap(), 0, size ); + memcpy( req->lpszHeader, lpBuffersIn->lpcszHeader, size ); + req->dwHeaderLength = lpBuffersIn->dwHeadersLength; req->lpOptional = lpBuffersIn->lpvBuffer; req->dwOptionalLength = lpBuffersIn->dwBufferLength; Modified: trunk/reactos/dll/win32/wininet/internet.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/wininet/internet…
============================================================================== --- trunk/reactos/dll/win32/wininet/internet.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/wininet/internet.c [iso-8859-1] Fri Nov 20 15:22:05 2009 @@ -1133,11 +1133,14 @@ DWORD nASCIILength=WideCharToMultiByte(CP_ACP,0,lpwszComponent,dwwComponentLen,NULL,0,NULL,NULL); if (*lppszComponent == NULL) { - int nASCIIOffset=WideCharToMultiByte(CP_ACP,0,lpwszStart,lpwszComponent-lpwszStart,NULL,0,NULL,NULL); if (lpwszComponent) - *lppszComponent = (LPSTR)lpszStart+nASCIIOffset; + { + int offset = WideCharToMultiByte(CP_ACP, 0, lpwszStart, lpwszComponent-lpwszStart, NULL, 0, NULL, NULL); + *lppszComponent = (LPSTR)lpszStart + offset; + } else *lppszComponent = NULL; + *dwComponentLen = nASCIILength; } else @@ -1184,7 +1187,7 @@ InternetCrackUrlW should not include it */ if (dwUrlLength == -1) nLength--; - lpwszUrl=HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WCHAR)*nLength); + lpwszUrl = HeapAlloc(GetProcessHeap(), 0, nLength * sizeof(WCHAR)); MultiByteToWideChar(CP_ACP,0,lpszUrl,dwUrlLength,lpwszUrl,nLength); memset(&UCW,0,sizeof(UCW)); Modified: trunk/reactos/dll/win32/wininet/netconnection.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/wininet/netconne…
============================================================================== --- trunk/reactos/dll/win32/wininet/netconnection.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/wininet/netconnection.c [iso-8859-1] Fri Nov 20 15:22:05 2009 @@ -289,14 +289,6 @@ #if defined(SONAME_LIBSSL) && defined(SONAME_LIBCRYPTO) if (OpenSSL_crypto_handle) { - if (ssl_locks) - { - int i; - - for (i = 0; i < pCRYPTO_num_locks(); i++) - DeleteCriticalSection(&ssl_locks[i]); - HeapFree(GetProcessHeap(), 0, ssl_locks); - } wine_dlclose(OpenSSL_crypto_handle, NULL, 0); } if (OpenSSL_ssl_handle) @@ -304,6 +296,12 @@ if (ctx) pSSL_CTX_free(ctx); wine_dlclose(OpenSSL_ssl_handle, NULL, 0); + } + if (ssl_locks) + { + int i; + for (i = 0; i < pCRYPTO_num_locks(); i++) DeleteCriticalSection(&ssl_locks[i]); + HeapFree(GetProcessHeap(), 0, ssl_locks); } #endif } Modified: trunk/reactos/dll/win32/wininet/urlcache.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/wininet/urlcache…
============================================================================== --- trunk/reactos/dll/win32/wininet/urlcache.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/wininet/urlcache.c [iso-8859-1] Fri Nov 20 15:22:05 2009 @@ -1449,6 +1449,28 @@ } /*********************************************************************** + * FreeUrlCacheSpaceA (WININET.@) + * + */ +BOOL WINAPI FreeUrlCacheSpaceA(LPCSTR lpszCachePath, DWORD dwSize, DWORD dwFilter) +{ + FIXME("stub!\n"); + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return FALSE; +} + + /*********************************************************************** + * FreeUrlCacheSpaceW (WININET.@) + * + */ +BOOL WINAPI FreeUrlCacheSpaceW(LPCWSTR lpszCachePath, DWORD dwSize, DWORD dwFilter) +{ + FIXME("stub!\n"); + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return FALSE; +} + +/*********************************************************************** * GetUrlCacheEntryInfoExA (WININET.@) * */ Modified: trunk/reactos/dll/win32/wininet/wininet.spec URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/wininet/wininet.…
============================================================================== --- trunk/reactos/dll/win32/wininet/wininet.spec [iso-8859-1] (original) +++ trunk/reactos/dll/win32/wininet/wininet.spec [iso-8859-1] Fri Nov 20 15:22:05 2009 @@ -50,8 +50,8 @@ @ stdcall FindNextUrlCacheGroup(long ptr ptr) @ stub ForceNexusLookup @ stub ForceNexusLookupExW -@ stub FreeUrlCacheSpaceA -@ stub FreeUrlCacheSpaceW +@ stdcall FreeUrlCacheSpaceA(str long long) +@ stdcall FreeUrlCacheSpaceW(wstr long long) @ stdcall FtpCommandA(long long long str ptr ptr) @ stdcall FtpCommandW(long long long wstr ptr ptr) @ stdcall FtpCreateDirectoryA(ptr str) Added: trunk/reactos/dll/win32/wininet/wininet_Lt.rc URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/wininet/wininet_…
============================================================================== --- trunk/reactos/dll/win32/wininet/wininet_Lt.rc (added) +++ trunk/reactos/dll/win32/wininet/wininet_Lt.rc [iso-8859-1] Fri Nov 20 15:22:05 2009 @@ -1,0 +1,69 @@ +/* + * Copyright 2009 Aurimas FiÅ¡eras <aurimas(a)gmail.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "resource.h" + +/* UTF-8 */ +#pragma code_page(65001) + +LANGUAGE LANG_LITHUANIAN, SUBLANG_NEUTRAL + +IDD_PROXYDLG DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 250, 154 +STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Ä®veskite tinklo slaptažodį" +FONT 8, "MS Shell Dlg" +{ + LTEXT "Ä®veskite savo naudotojo vardÄ ir slaptažodį:", -1, 40, 6, 150, 15 + LTEXT "Ä®galiot. serv.", -1, 40, 26, 50, 10 + LTEXT "Sritis", -1, 40, 46, 50, 10 + LTEXT "Naudotojas", -1, 40, 66, 50, 10 + LTEXT "Slaptažodis", -1, 40, 86, 50, 10 + LTEXT "" IDC_PROXY, 80, 26, 150, 14, 0 + LTEXT "" IDC_REALM, 80, 46, 150, 14, 0 + EDITTEXT IDC_USERNAME, 80, 66, 150, 14, ES_AUTOHSCROLL | WS_BORDER | WS_TABSTOP + EDITTEXT IDC_PASSWORD, 80, 86, 150, 14, ES_AUTOHSCROLL | WS_BORDER | WS_TABSTOP | ES_PASSWORD + CHECKBOX "Ä®&raÅ¡yti šį slaptažodį (nesaugu)", IDC_SAVEPASSWORD, + 80, 106, 150, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP + PUSHBUTTON "Gerai", IDOK, 98, 126, 56, 14, WS_GROUP | WS_TABSTOP | BS_DEFPUSHBUTTON + PUSHBUTTON "Atsisakyti", IDCANCEL, 158, 126, 56, 14, WS_GROUP | WS_TABSTOP +} + +IDD_AUTHDLG DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 250, 154 +STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Reikalingas tapatumo nustatymas" +FONT 8, "MS Shell Dlg" +{ + LTEXT "Ä®veskite savo naudotojo vardÄ ir slaptažodį:", -1, 40, 6, 150, 15 + LTEXT "Serveris", -1, 40, 26, 50, 10 + LTEXT "Sritis", -1, 40, 46, 50, 10 + LTEXT "Naudotojas", -1, 40, 66, 50, 10 + LTEXT "Slaptažodis", -1, 40, 86, 50, 10 + LTEXT "" IDC_SERVER, 80, 26, 150, 14, 0 + LTEXT "" IDC_REALM, 80, 46, 150, 14, 0 + EDITTEXT IDC_USERNAME, 80, 66, 150, 14, ES_AUTOHSCROLL | WS_BORDER | WS_TABSTOP + EDITTEXT IDC_PASSWORD, 80, 86, 150, 14, ES_AUTOHSCROLL | WS_BORDER | WS_TABSTOP | ES_PASSWORD + CHECKBOX "Ä®&raÅ¡yti šį slaptažodį (nesaugu)", IDC_SAVEPASSWORD, + 80, 106, 150, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP + PUSHBUTTON "Gerai", IDOK, 98, 126, 56, 14, WS_GROUP | WS_TABSTOP | BS_DEFPUSHBUTTON + PUSHBUTTON "Atsisakyti", IDCANCEL, 158, 126, 56, 14, WS_GROUP | WS_TABSTOP +} + +STRINGTABLE DISCARDABLE +{ + IDS_LANCONNECTION "Vietinio tinklo ryÅ¡ys" +} Propchange: trunk/reactos/dll/win32/wininet/wininet_Lt.rc ------------------------------------------------------------------------------ svn:eol-style = native
15 years, 1 month
1
0
0
0
[arty] 44235: Add read ahead granularity, currently unused.
by arty@svn.reactos.org
Author: arty Date: Fri Nov 20 06:25:35 2009 New Revision: 44235 URL:
http://svn.reactos.org/svn/reactos?rev=44235&view=rev
Log: Add read ahead granularity, currently unused. Modified: branches/arty-newcc/ntoskrnl/cache/fssup.c branches/arty-newcc/ntoskrnl/include/internal/newcc.h Modified: branches/arty-newcc/ntoskrnl/cache/fssup.c URL:
http://svn.reactos.org/svn/reactos/branches/arty-newcc/ntoskrnl/cache/fssup…
============================================================================== --- branches/arty-newcc/ntoskrnl/cache/fssup.c [iso-8859-1] (original) +++ branches/arty-newcc/ntoskrnl/cache/fssup.c [iso-8859-1] Fri Nov 20 06:25:35 2009 @@ -112,6 +112,7 @@ FileObject->SectionObjectPointer->SharedCacheMap = Map; Map->FileSizes = *FileSizes; Map->LazyContext = LazyWriteContext; + Map->ReadAheadGranularity = PAGE_SIZE; RtlCopyMemory(&Map->Callbacks, Callbacks, sizeof(*Callbacks)); // For now ... DPRINT("FileSizes->ValidDataLength %08x%08x\n", FileSizes->ValidDataLength.HighPart, FileSizes->ValidDataLength.LowPart); Modified: branches/arty-newcc/ntoskrnl/include/internal/newcc.h URL:
http://svn.reactos.org/svn/reactos/branches/arty-newcc/ntoskrnl/include/int…
============================================================================== --- branches/arty-newcc/ntoskrnl/include/internal/newcc.h [iso-8859-1] (original) +++ branches/arty-newcc/ntoskrnl/include/internal/newcc.h [iso-8859-1] Fri Nov 20 06:25:35 2009 @@ -136,6 +136,7 @@ PVOID LazyContext; PVOID LogHandle; PFLUSH_TO_LSN FlushToLsn; + ULONG ReadAheadGranularity; } NOCC_CACHE_MAP, *PNOCC_CACHE_MAP; VOID
15 years, 1 month
1
0
0
0
[arty] 44234: We can safely ignore oplock with mostly failures as far as i can tell.
by arty@svn.reactos.org
Author: arty Date: Fri Nov 20 06:24:51 2009 New Revision: 44234 URL:
http://svn.reactos.org/svn/reactos?rev=44234&view=rev
Log: We can safely ignore oplock with mostly failures as far as i can tell. Modified: branches/arty-newcc/ntoskrnl/fsrtl/oplock.c Modified: branches/arty-newcc/ntoskrnl/fsrtl/oplock.c URL:
http://svn.reactos.org/svn/reactos/branches/arty-newcc/ntoskrnl/fsrtl/oploc…
============================================================================== --- branches/arty-newcc/ntoskrnl/fsrtl/oplock.c [iso-8859-1] (original) +++ branches/arty-newcc/ntoskrnl/fsrtl/oplock.c [iso-8859-1] Fri Nov 20 06:24:51 2009 @@ -9,7 +9,7 @@ /* INCLUDES ******************************************************************/ #include <ntoskrnl.h> -#define NDEBUG +//#define NDEBUG #include <debug.h> /* PUBLIC FUNCTIONS **********************************************************/ @@ -49,8 +49,9 @@ IN POPLOCK_FS_PREPOST_IRP PostIrpRoutine OPTIONAL) { /* Unimplemented */ - KeBugCheck(FILE_SYSTEM); - return STATUS_NOT_IMPLEMENTED; + //KeBugCheck(FILE_SYSTEM); + DPRINT("FsRtlCheckOplock\n"); + return STATUS_SUCCESS; // STATUS_NOT_IMPLEMENTED } /*++ @@ -72,7 +73,8 @@ FsRtlCurrentBatchOplock(IN POPLOCK Oplock) { /* Unimplemented */ - KeBugCheck(FILE_SYSTEM); + //KeBugCheck(FILE_SYSTEM); + DPRINT("FsRtlCurrentBatchOplock\n"); return FALSE; } @@ -95,6 +97,7 @@ FsRtlInitializeOplock(IN OUT POPLOCK Oplock) { UNREFERENCED_PARAMETER(Oplock); + DPRINT("FsRtlInitializeOplock\n"); } /*++ @@ -124,7 +127,8 @@ IN ULONG OpenCount) { /* Unimplemented */ - KeBugCheck(FILE_SYSTEM); + //KeBugCheck(FILE_SYSTEM); + DPRINT("FsRtlOplockFsctrl\n"); return STATUS_NOT_IMPLEMENTED; } @@ -147,7 +151,8 @@ FsRtlOplockIsFastIoPossible(IN POPLOCK Oplock) { /* Unimplemented */ - KeBugCheck(FILE_SYSTEM); + //KeBugCheck(FILE_SYSTEM); + DPRINT("FsRtlOplockIsFastIoPossible\n"); return FALSE; } @@ -170,6 +175,7 @@ FsRtlUninitializeOplock(IN POPLOCK Oplock) { /* Unimplemented */ - KeBugCheck(FILE_SYSTEM); + //KeBugCheck(FILE_SYSTEM); + DPRINT("FsRtlUninitializeOplock\n"); }
15 years, 1 month
1
0
0
0
[arty] 44233: Add printing to filelock, although i haven't seen a problem yet.
by arty@svn.reactos.org
Author: arty Date: Fri Nov 20 06:23:42 2009 New Revision: 44233 URL:
http://svn.reactos.org/svn/reactos?rev=44233&view=rev
Log: Add printing to filelock, although i haven't seen a problem yet. Modified: branches/arty-newcc/ntoskrnl/fsrtl/filelock.c Modified: branches/arty-newcc/ntoskrnl/fsrtl/filelock.c URL:
http://svn.reactos.org/svn/reactos/branches/arty-newcc/ntoskrnl/fsrtl/filel…
============================================================================== --- branches/arty-newcc/ntoskrnl/fsrtl/filelock.c [iso-8859-1] (original) +++ branches/arty-newcc/ntoskrnl/fsrtl/filelock.c [iso-8859-1] Fri Nov 20 06:23:42 2009 @@ -218,10 +218,23 @@ IN BOOLEAN Restart) { PCOMBINED_LOCK_ELEMENT Entry; - if (!FileLock->LockInformation) return NULL; + DPRINT("FsRtlGetNextFileLock(%x,%d)\n", FileLock, Restart); + if (!FileLock->LockInformation) + { + DPRINT("No locks at all\n"); + return NULL; + } Entry = RtlEnumerateGenericTable(FileLock->LockInformation, Restart); - if (!Entry) return NULL; - else return &Entry->Exclusive.FileLock; + if (!Entry) + { + DPRINT("No next entry\n"); + return NULL; + } + else + { + DPRINT("Lock info %x\n", &Entry->Exclusive.FileLock); + return &Entry->Exclusive.FileLock; + } } /* @@ -248,7 +261,15 @@ PLOCK_INFORMATION LockInfo; BOOLEAN InsertedNew; - DPRINT1("FsRtlPrivateLock() is stubplemented!\n"); + DPRINT1("FsRtlPrivateLock(FileLock %x,FileObject %x,FileOffset %x,Length %x,Process %x, Key %x, FailImmediately %x, Exclusive %x)\n", + FileLock, + FileObject, + FileOffset->LowPart, + Length->LowPart, + Process, + Key, + FailImmediately, + ExclusiveLock); ASSERT(AlreadySynchronized); /* Initialize the lock, if necessary */ @@ -257,7 +278,10 @@ LockInfo = ExAllocatePool(PagedPool, sizeof(LOCK_INFORMATION)); FileLock->LockInformation = LockInfo; if (!FileLock) + { + DPRINT("out of memory\n"); return FALSE; + } LockInfo->BelongsTo = FileLock; @@ -311,6 +335,10 @@ &Status, FileObject); } + DPRINT("fail immediately and conflicting lock (%x-%x,%x)\n", + Conflict->Exclusive.FileLock.StartingByte.LowPart, + Conflict->Exclusive.FileLock.EndingByte.LowPart, + Conflict->Exclusive.FileLock.Key); return FALSE; } else @@ -325,8 +353,9 @@ NULL, NULL); } + DPRINT("Pending ...\n"); + return TRUE; } - return FALSE; } else { @@ -341,7 +370,8 @@ &Status, FileObject); } - return FALSE; + DPRINT("Yes, completed the lock\n"); + return TRUE; } } else if (!Conflict) @@ -349,6 +379,7 @@ /* Conflict here is (or would be) the newly inserted element, but we ran * out of space probably. */ IoStatus->Status = STATUS_NO_MEMORY; + DPRINT("ran out of memory adding the new lock node\n"); return FALSE; } else @@ -373,9 +404,9 @@ /* Update the status */ IoStatus->Status = Status; } - } - - return TRUE; + DPRINT("Added %x successfully\n", Conflict); + return TRUE; + } } /* @@ -386,20 +417,35 @@ FsRtlCheckLockForReadAccess(IN PFILE_LOCK FileLock, IN PIRP Irp) { + BOOLEAN Result; PIO_STACK_LOCATION IoStack = IoGetCurrentIrpStackLocation(Irp); COMBINED_LOCK_ELEMENT ToFind; PCOMBINED_LOCK_ELEMENT Found; - if (!FileLock->LockInformation) return TRUE; + if (!FileLock->LockInformation) + { + DPRINT("No locks\n"); + return TRUE; + } ToFind.Exclusive.FileLock.StartingByte = IoStack->Parameters.Read.ByteOffset; ToFind.Exclusive.FileLock.EndingByte.QuadPart = ToFind.Exclusive.FileLock.StartingByte.QuadPart + IoStack->Parameters.Read.Length; + DPRINT("FsRtlCheckLockForReadAccess(%x,%x-%x)\n", + FileLock, + ToFind.Exclusive.FileLock.StartingByte.LowPart, + ToFind.Exclusive.FileLock.EndingByte.LowPart); Found = RtlLookupElementGenericTable (FileLock->LockInformation, &ToFind); - if (!Found) return TRUE; - return !Found->Exclusive.FileLock.ExclusiveLock || + if (!Found) + { + DPRINT("Not matched\n"); + return TRUE; + } + Result = !Found->Exclusive.FileLock.ExclusiveLock || IoStack->Parameters.Read.Key == Found->Exclusive.FileLock.Key; + DPRINT("Allowed %d\n", Result); + return Result; } /* @@ -410,20 +456,35 @@ FsRtlCheckLockForWriteAccess(IN PFILE_LOCK FileLock, IN PIRP Irp) { + BOOLEAN Result; PIO_STACK_LOCATION IoStack = IoGetCurrentIrpStackLocation(Irp); COMBINED_LOCK_ELEMENT ToFind; PCOMBINED_LOCK_ELEMENT Found; PEPROCESS Process = Irp->Tail.Overlay.Thread->ThreadsProcess; - if (!FileLock->LockInformation) return TRUE; + if (!FileLock->LockInformation) + { + DPRINT("No locks\n"); + return TRUE; + } ToFind.Exclusive.FileLock.StartingByte = IoStack->Parameters.Write.ByteOffset; ToFind.Exclusive.FileLock.EndingByte.QuadPart = ToFind.Exclusive.FileLock.StartingByte.QuadPart + IoStack->Parameters.Write.Length; + DPRINT("FsRtlCheckLockForReadAccess(%x,%x-%x)\n", + FileLock, + ToFind.Exclusive.FileLock.StartingByte.LowPart, + ToFind.Exclusive.FileLock.EndingByte.LowPart); Found = RtlLookupElementGenericTable (FileLock->LockInformation, &ToFind); - if (!Found) return TRUE; - return Process->UniqueProcessId == Found->Exclusive.FileLock.ProcessId; + if (!Found) + { + DPRINT("Not matched\n"); + return TRUE; + } + Result = Process->UniqueProcessId == Found->Exclusive.FileLock.ProcessId; + DPRINT("Allowed %d\n", Result); + return Result; } /* @@ -441,14 +502,29 @@ PEPROCESS EProcess = Process; COMBINED_LOCK_ELEMENT ToFind; PCOMBINED_LOCK_ELEMENT Found; + DPRINT("FsRtlFastCheckLockForRead(FileLock %x, FileOffset %x, Length %x, Key %x, FileObject %x, Process %x)\n", + FileLock, + FileOffset->LowPart, + Length->LowPart, + Key, + FileObject, + Process); ToFind.Exclusive.FileLock.StartingByte = *FileOffset; ToFind.Exclusive.FileLock.EndingByte.QuadPart = FileOffset->QuadPart + Length->QuadPart; - if (!FileLock->LockInformation) return TRUE; + if (!FileLock->LockInformation) + { + DPRINT("Not found\n"); + return TRUE; + } Found = RtlLookupElementGenericTable (FileLock->LockInformation, &ToFind); - if (!Found || !Found->Exclusive.FileLock.ExclusiveLock) return TRUE; + if (!Found || !Found->Exclusive.FileLock.ExclusiveLock) + { + DPRINT("Not matched\n"); + return TRUE; + } return Found->Exclusive.FileLock.Key == Key && Found->Exclusive.FileLock.ProcessId == EProcess->UniqueProcessId; } @@ -465,19 +541,37 @@ IN PFILE_OBJECT FileObject, IN PVOID Process) { + BOOLEAN Result; PEPROCESS EProcess = Process; COMBINED_LOCK_ELEMENT ToFind; PCOMBINED_LOCK_ELEMENT Found; + DPRINT("FsRtlFastCheckLockForWrite(FileLock %x,FileOffset %x,Length %x,Key %x,FileObject %x, Process %x)\n", + FileLock, + FileOffset->LowPart, + Length->LowPart, + Key, + FileObject, + Process); ToFind.Exclusive.FileLock.StartingByte = *FileOffset; ToFind.Exclusive.FileLock.EndingByte.QuadPart = FileOffset->QuadPart + Length->QuadPart; - if (!FileLock->LockInformation) return TRUE; + if (!FileLock->LockInformation) + { + DPRINT("Not Found\n"); + return TRUE; + } Found = RtlLookupElementGenericTable (FileLock->LockInformation, &ToFind); - if (!Found) return TRUE; - return Found->Exclusive.FileLock.Key == Key && + if (!Found) + { + DPRINT("Not Matched\n"); + return TRUE; + } + Result = Found->Exclusive.FileLock.Key == Key && Found->Exclusive.FileLock.ProcessId == EProcess->UniqueProcessId; + DPRINT("Allowed: %d\n", Result); + return Result; } /* @@ -500,21 +594,39 @@ PLOCK_INFORMATION InternalInfo = FileLock->LockInformation; // The region to unlock must correspond exactly to a previously locked region // -- msdn + DPRINT("FsRtlFastUnlockSingle(FileLock %x, FileObject %x,FileOffset %x,Length %x,Process %x, Key %x)\n", + FileLock, + FileObject, + FileOffset->LowPart, + Length->LowPart, + Process, + Key); ASSERT(AlreadySynchronized); Find.Exclusive.FileLock.StartingByte = *FileOffset; Find.Exclusive.FileLock.EndingByte.QuadPart = FileOffset->QuadPart + Length->QuadPart; Entry = RtlLookupElementGenericTable(&InternalInfo->RangeTable, &Find); - if (!Entry) return STATUS_RANGE_NOT_LOCKED; + if (!Entry) + { + DPRINT("STATUS_RANGE_NOT_LOCKED\n"); + return STATUS_RANGE_NOT_LOCKED; + } if (Entry->Exclusive.FileLock.Key != Key || Entry->Exclusive.FileLock.ProcessId != Process->UniqueProcessId) + { + DPRINT("STATUS_RANGE_NOT_LOCKED\n"); return STATUS_RANGE_NOT_LOCKED; + } if (Entry->Exclusive.FileLock.StartingByte.QuadPart != FileOffset->QuadPart || Entry->Exclusive.FileLock.EndingByte.QuadPart != FileOffset->QuadPart + Length->QuadPart) + { + DPRINT("STATUS_RANGE_NOT_LOCKED\n"); return STATUS_RANGE_NOT_LOCKED; + } // this is definitely the thing we want RtlCopyMemory(&Find, Entry, sizeof(Find)); + DPRINT("Deleting last IRP\n"); RtlDeleteElementGenericTable(&InternalInfo->RangeTable, Entry); NextMatchingLockIrp = IoCsqRemoveNextIrp(&InternalInfo->Csq, &Find); if (NextMatchingLockIrp) @@ -523,8 +635,10 @@ // Note that we pick an operation that would succeed at the time // we looked, but can't guarantee that it won't just be re-queued // because somebody else snatched part of the range in a new thread. + DPRINT("Locking next IRP\n"); FsRtlProcessFileLock(InternalInfo->BelongsTo, NextMatchingLockIrp, NULL); } + DPRINT("Done\n"); return STATUS_SUCCESS; } @@ -541,8 +655,14 @@ PCOMBINED_LOCK_ELEMENT Entry; PRTL_GENERIC_TABLE InternalInfo = FileLock->LockInformation; + DPRINT("FsRtlFastUnlockAll(%x,%x,%x)\n", FileLock, FileObject, Process); + // XXX Synchronize somehow - if (!FileLock->LockInformation) return STATUS_RANGE_NOT_LOCKED; // no locks + if (!FileLock->LockInformation) + { + DPRINT("No locks to unlock!\n"); + return STATUS_SUCCESS; + } for (Entry = RtlEnumerateGenericTable(InternalInfo, TRUE); Entry; Entry = RtlEnumerateGenericTable(InternalInfo, FALSE)) @@ -563,6 +683,7 @@ TRUE); } + DPRINT("Done\n"); return STATUS_SUCCESS; } @@ -580,6 +701,8 @@ PCOMBINED_LOCK_ELEMENT Entry; PRTL_GENERIC_TABLE InternalInfo = FileLock->LockInformation; + DPRINT("FsRtlFastUnlockAllByKey(%x,%x,%x,%x)\n", + FileLock, FileObject, Process, Key); // XXX Synchronize somehow if (!FileLock->LockInformation) return STATUS_RANGE_NOT_LOCKED; // no locks for (Entry = RtlEnumerateGenericTable(InternalInfo, TRUE); @@ -606,6 +729,7 @@ } } + DPRINT("Done\n"); return STATUS_SUCCESS; } @@ -625,6 +749,10 @@ /* Get the I/O Stack location */ IoStackLocation = IoGetCurrentIrpStackLocation(Irp); ASSERT(IoStackLocation->MajorFunction == IRP_MJ_LOCK_CONTROL); + DPRINT("FsRtlProcessFileLock(%x,%x,%x)\n", + FileLock, + IoStackLocation->MajorFunction, + IoStackLocation->MinorFunction); /* Clear the I/O status block and check what function this is */ IoStatusBlock.Information = 0; @@ -632,7 +760,7 @@ { /* A lock */ case IRP_MN_LOCK: - + DPRINT("IRP_MN_LOCK\n"); /* Call the private lock routine */ FsRtlPrivateLock(FileLock, IoStackLocation->FileObject, @@ -651,7 +779,7 @@ /* A single unlock */ case IRP_MN_UNLOCK_SINGLE: - + DPRINT("IRP_MN_UNLOCK_SINGLE\n"); /* Call fast unlock */ IoStatusBlock.Status = FsRtlFastUnlockSingle(FileLock, @@ -677,7 +805,7 @@ /* Total unlock */ case IRP_MN_UNLOCK_ALL: - + DPRINT("IRP_MN_UNLOCK_ALL\n"); /* Do a fast unlock */ IoStatusBlock.Status = FsRtlFastUnlockAll(FileLock, IoStackLocation-> @@ -696,7 +824,7 @@ /* Unlock by key */ case IRP_MN_UNLOCK_ALL_BY_KEY: - + DPRINT("IRP_MN_UNLOCK_ALL_BY_KEY\n"); /* Do it */ IoStatusBlock.Status = FsRtlFastUnlockAllByKey(FileLock, @@ -717,7 +845,7 @@ /* Invalid request */ default: - + DPRINT("Invalid request\n"); /* Complete it */ FsRtlCompleteRequest(Irp, STATUS_INVALID_DEVICE_REQUEST); IoStatusBlock.Status = STATUS_INVALID_DEVICE_REQUEST; @@ -725,6 +853,7 @@ } /* Return the status */ + DPRINT("Status %x\n", Status); return IoStatusBlock.Status; } @@ -738,6 +867,7 @@ IN PUNLOCK_ROUTINE UnlockRoutine OPTIONAL) { /* Setup the lock */ + DPRINT("Initialize %x\n", FileLock); FileLock->FastIoIsQuestionable = FALSE; FileLock->CompleteLockIrpRoutine = CompleteLockIrpRoutine; FileLock->UnlockRoutine = UnlockRoutine; @@ -791,6 +921,7 @@ FsRtlFreeFileLock(IN PFILE_LOCK FileLock) { /* Uninitialize and free the lock */ + DPRINT("FsRtlFreeFileLock(%x)\n", FileLock); FsRtlUninitializeFileLock(FileLock); ExFreeToPagedLookasideList(&FsRtlFileLockLookasideList, FileLock); }
15 years, 1 month
1
0
0
0
[arty] 44232: Support lazy read, needed for matt wu's ext3 driver.
by arty@svn.reactos.org
Author: arty Date: Fri Nov 20 06:23:09 2009 New Revision: 44232 URL:
http://svn.reactos.org/svn/reactos?rev=44232&view=rev
Log: Support lazy read, needed for matt wu's ext3 driver. Modified: branches/arty-newcc/ntoskrnl/cache/cachesub.c Modified: branches/arty-newcc/ntoskrnl/cache/cachesub.c URL:
http://svn.reactos.org/svn/reactos/branches/arty-newcc/ntoskrnl/cache/cache…
============================================================================== --- branches/arty-newcc/ntoskrnl/cache/cachesub.c [iso-8859-1] (original) +++ branches/arty-newcc/ntoskrnl/cache/cachesub.c [iso-8859-1] Fri Nov 20 06:23:09 2009 @@ -13,7 +13,15 @@ #define NDEBUG #include <debug.h> -/* GLOBALS ********************************************************************/ +/* STRUCTURES *****************************************************************/ + +typedef struct _WORK_QUEUE_WITH_READ_AHEAD +{ + WORK_QUEUE_ITEM WorkItem; + PFILE_OBJECT FileObject; + LARGE_INTEGER FileOffset; + ULONG Length; +} WORK_QUEUE_WITH_READ_AHEAD, *PWORK_QUEUE_WITH_READ_AHEAD; /* FUNCTIONS ******************************************************************/ @@ -26,18 +34,76 @@ CcSetReadAheadGranularity(IN PFILE_OBJECT FileObject, IN ULONG Granularity) { - UNIMPLEMENTED; - while (TRUE); + PNOCC_CACHE_MAP Map = (PNOCC_CACHE_MAP)FileObject->SectionObjectPointer->SharedCacheMap; + if (Map) + { + Map->ReadAheadGranularity = Granularity; + } } +VOID +NTAPI +CcpReadAhead(PVOID Context) +{ + LARGE_INTEGER Offset; + PWORK_QUEUE_WITH_READ_AHEAD WorkItem = (PWORK_QUEUE_WITH_READ_AHEAD)Context; + PNOCC_CACHE_MAP Map = (PNOCC_CACHE_MAP)WorkItem->FileObject->SectionObjectPointer->SharedCacheMap; + DPRINT("Reading ahead %08x%08x:%x %wZ\n", + WorkItem->FileOffset.HighPart, + WorkItem->FileOffset.LowPart, + WorkItem->Length, + &WorkItem->FileObject->FileName); + Offset.HighPart = WorkItem->FileOffset.HighPart; + Offset.LowPart = PAGE_ROUND_DOWN(WorkItem->FileOffset.LowPart); + if (Map) + { + PLIST_ENTRY ListEntry; + volatile char *chptr; + PNOCC_BCB Bcb; + for (ListEntry = Map->AssociatedBcb.Flink; + ListEntry != &Map->AssociatedBcb; + ListEntry = ListEntry->Flink) + { + Bcb = CONTAINING_RECORD(ListEntry, NOCC_BCB, ThisFileList); + if ((Offset.QuadPart + WorkItem->Length < Bcb->FileOffset.QuadPart) || + (Bcb->FileOffset.QuadPart + Bcb->Length < Offset.QuadPart)) + continue; + for (chptr = Bcb->BaseAddress, Offset = Bcb->FileOffset; + chptr < ((PCHAR)Bcb->BaseAddress) + Bcb->Length && + Offset.QuadPart < + WorkItem->FileOffset.QuadPart + WorkItem->Length; + chptr += PAGE_SIZE, Offset.QuadPart += PAGE_SIZE) + { + *chptr ^= 0; + } + } + } + ObDereferenceObject(WorkItem->FileObject); + ExFreePool(WorkItem); + DPRINT("Done\n"); +} + VOID NTAPI CcScheduleReadAhead(IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length) { - UNIMPLEMENTED; - while (TRUE); + PWORK_QUEUE_WITH_READ_AHEAD WorkItem; + DPRINT("Schedule read ahead %08x%08x:%x %wZ\n", + FileOffset->HighPart, + FileOffset->LowPart, + Length, + &FileObject->FileName); + WorkItem = ExAllocatePool(NonPagedPool, sizeof(*WorkItem)); + if (!WorkItem) KeBugCheck(0); + ObReferenceObject(FileObject); + WorkItem->FileObject = FileObject; + WorkItem->FileOffset = *FileOffset; + WorkItem->Length = Length; + ExInitializeWorkItem(((PWORK_QUEUE_ITEM)WorkItem), (PWORKER_THREAD_ROUTINE)CcpReadAhead, WorkItem); + ExQueueWorkItem((PWORK_QUEUE_ITEM)WorkItem, DelayedWorkQueue); + DPRINT("Done\n"); } VOID
15 years, 1 month
1
0
0
0
[arty] 44231: We don't use MaximumPairCount to determine where the memory came from.
by arty@svn.reactos.org
Author: arty Date: Fri Nov 20 06:22:32 2009 New Revision: 44231 URL:
http://svn.reactos.org/svn/reactos?rev=44231&view=rev
Log: We don't use MaximumPairCount to determine where the memory came from. Modified: branches/arty-newcc/ntoskrnl/fsrtl/largemcb.c Modified: branches/arty-newcc/ntoskrnl/fsrtl/largemcb.c URL:
http://svn.reactos.org/svn/reactos/branches/arty-newcc/ntoskrnl/fsrtl/large…
============================================================================== --- branches/arty-newcc/ntoskrnl/fsrtl/largemcb.c [iso-8859-1] (original) +++ branches/arty-newcc/ntoskrnl/fsrtl/largemcb.c [iso-8859-1] Fri Nov 20 06:22:32 2009 @@ -266,19 +266,22 @@ if (PoolType == PagedPool) { Mcb->Mapping = ExAllocateFromPagedLookasideList(&FsRtlFirstMappingLookasideList); + DPRINT("Get from lookaside list\n"); } else { Mcb->Mapping = ExAllocatePoolWithTag(PoolType | POOL_RAISE_IF_ALLOCATION_FAILURE, sizeof(RTL_GENERIC_TABLE) + sizeof(LIST_ENTRY), 'FSBC'); + DPRINT("Allocate\n"); } + DPRINT("Mcb->Mapping %x\n", Mcb->Mapping); Mcb->PoolType = PoolType; Mcb->MaximumPairCount = MAXIMUM_PAIR_COUNT; RtlInitializeGenericTable (Mcb->Mapping, - (PRTL_GENERIC_COMPARE_ROUTINE)McbMappingCompare, + McbMappingCompare, McbMappingAllocate, McbMappingFree, Mcb); @@ -683,14 +686,17 @@ { PLARGE_MCB_MAPPING_ENTRY Element; + DPRINT("Reset MCB %x\n", Mcb); while (RtlNumberGenericTableElements(Mcb->Mapping) && (Element = (PLARGE_MCB_MAPPING_ENTRY)RtlGetElementGenericTable(Mcb->Mapping, 0))) { + DPRINT("Deleting %x\n", Element); RtlDeleteElementGenericTable(Mcb->Mapping, Element); } Mcb->PairCount = 0; Mcb->MaximumPairCount = 0; + DPRINT("Done\n"); } /* @@ -860,8 +866,10 @@ FsRtlTruncateBaseMcb(IN PBASE_MCB Mcb, IN LONGLONG Vbn) { + DPRINT("FsRtlTruncateBaseMcb(%x,%x)\n", Mcb, (ULONG)Vbn); if (!Vbn) { + DPRINT("Resetting\n"); FsRtlResetBaseMcb(Mcb); } else @@ -872,11 +880,13 @@ Truncate.SectorCount.QuadPart = (1ull<<62) - Truncate.RunStartVbn.QuadPart; while ((Found = RtlLookupElementGenericTable(Mcb->Mapping, &Truncate))) { + DPRINT("Deleting %x\n", Found); RemoveEntryList(&Found->Sequence); RtlDeleteElementGenericTable(Mcb->Mapping, Found); Mcb->PairCount--; } } + DPRINT("Done\n"); } /* @@ -902,17 +912,23 @@ NTAPI FsRtlUninitializeBaseMcb(IN PBASE_MCB Mcb) { + DPRINT("FsRtlUninitializeBaseMcb(%x)\n", Mcb); FsRtlResetBaseMcb(Mcb); - if ((Mcb->PoolType == PagedPool) && (Mcb->MaximumPairCount == MAXIMUM_PAIR_COUNT)) + DPRINT("Mcb->Mapping %x\n", Mcb->Mapping); + if (Mcb->PoolType == PagedPool) { + DPRINT("Deallocate to lookaside list\n"); ExFreeToPagedLookasideList(&FsRtlFirstMappingLookasideList, Mcb->Mapping); } else { + DPRINT("Deallocate\n"); ExFreePoolWithTag(Mcb->Mapping, 'FSBC'); } + Mcb->Mapping = NULL; + DPRINT("Done\n"); } /* @@ -926,6 +942,7 @@ { ExFreeToNPagedLookasideList(&FsRtlFastMutexLookasideList, Mcb->GuardedMutex); + Mcb->GuardedMutex = NULL; FsRtlUninitializeBaseMcb(&(Mcb->BaseMcb)); } }
15 years, 1 month
1
0
0
0
[arty] 44230: Rough cut at file locks. Not complete yet (probably).
by arty@svn.reactos.org
Author: arty Date: Fri Nov 20 02:56:45 2009 New Revision: 44230 URL:
http://svn.reactos.org/svn/reactos?rev=44230&view=rev
Log: Rough cut at file locks. Not complete yet (probably). Modified: branches/arty-newcc/ntoskrnl/fsrtl/filelock.c Modified: branches/arty-newcc/ntoskrnl/fsrtl/filelock.c URL:
http://svn.reactos.org/svn/reactos/branches/arty-newcc/ntoskrnl/fsrtl/filel…
============================================================================== --- branches/arty-newcc/ntoskrnl/fsrtl/filelock.c [iso-8859-1] (original) +++ branches/arty-newcc/ntoskrnl/fsrtl/filelock.c [iso-8859-1] Fri Nov 20 02:56:45 2009 @@ -9,14 +9,176 @@ /* INCLUDES ******************************************************************/ #include <ntoskrnl.h> -#define NDEBUG +//#define NDEBUG #include <debug.h> /* GLOBALS *******************************************************************/ PAGED_LOOKASIDE_LIST FsRtlFileLockLookasideList; +/* Note: this aligns the two types of lock entry structs so we can access the + FILE_LOCK_INFO part in common. Add elements after Shared if new stuff is needed. +*/ +typedef union _COMBINED_LOCK_ELEMENT +{ + struct + { + LIST_ENTRY dummy; + FILE_SHARED_LOCK_ENTRY Shared; + }; + FILE_EXCLUSIVE_LOCK_ENTRY Exclusive; +} +COMBINED_LOCK_ELEMENT, *PCOMBINED_LOCK_ELEMENT; + +typedef struct _LOCK_INFORMATION +{ + RTL_GENERIC_TABLE RangeTable; + IO_CSQ Csq; + KSPIN_LOCK CsqLock; + PFILE_LOCK BelongsTo; +} +LOCK_INFORMATION, *PLOCK_INFORMATION; + /* PRIVATE FUNCTIONS *********************************************************/ + +VOID +NTAPI +FsRtlCompleteLockIrpReal(IN PCOMPLETE_LOCK_IRP_ROUTINE CompleteRoutine, + IN PVOID Context, + IN PIRP Irp, + IN NTSTATUS Status, + OUT PNTSTATUS NewStatus, + IN PFILE_OBJECT FileObject OPTIONAL); + +/* Generic table methods */ + +static PVOID NTAPI LockAllocate(PRTL_GENERIC_TABLE Table, CLONG Bytes) +{ + PVOID Result; + Result = ExAllocatePoolWithTag(NonPagedPool, Bytes, 'FLCK'); + DPRINT("LockAllocate(%d) => %p\n", Bytes, Result); + return Result; +} + +static VOID NTAPI LockFree(PRTL_GENERIC_TABLE Table, PVOID Buffer) +{ + DPRINT("LockFree(%p)\n", Buffer); + ExFreePoolWithTag(Buffer, 'FLCK'); +} + +static RTL_GENERIC_COMPARE_RESULTS NTAPI LockCompare +(PRTL_GENERIC_TABLE Table, PVOID PtrA, PVOID PtrB) +{ + PCOMBINED_LOCK_ELEMENT A = PtrA, B = PtrB; + RTL_GENERIC_COMPARE_RESULTS Result; + DPRINT("Starting to compare element %x to element %x\n", PtrA, PtrB); + Result = + (A->Exclusive.FileLock.EndingByte.QuadPart < + B->Exclusive.FileLock.StartingByte.QuadPart) ? GenericLessThan : + (A->Exclusive.FileLock.StartingByte.QuadPart > + B->Exclusive.FileLock.EndingByte.QuadPart) ? GenericGreaterThan : + GenericEqual; + DPRINT("Compare(%x:%x) %x-%x to %x-%x => %d\n", + A,B, + A->Exclusive.FileLock.StartingByte.LowPart, + A->Exclusive.FileLock.EndingByte.LowPart, + B->Exclusive.FileLock.StartingByte.LowPart, + B->Exclusive.FileLock.EndingByte.LowPart, + Result); + return Result; +} + +/* CSQ methods */ + +static NTSTATUS NTAPI LockInsertIrpEx +(PIO_CSQ Csq, + PIRP Irp, + PVOID InsertContext) +{ + PCOMBINED_LOCK_ELEMENT LockElement = InsertContext; + InsertTailList(&LockElement->Exclusive.ListEntry, &Irp->Tail.Overlay.ListEntry); + return STATUS_SUCCESS; +} + +static VOID NTAPI LockRemoveIrp(PIO_CSQ Csq, PIRP Irp) +{ + RemoveEntryList(&Irp->Tail.Overlay.ListEntry); +} + +static PIRP NTAPI LockPeekNextIrp(PIO_CSQ Csq, PIRP Irp, PVOID PeekContext) +{ + // Context will be a COMBINED_LOCK_ELEMENT. We're looking for a + // lock that can be acquired, now that the lock matching PeekContext + // has been removed. + COMBINED_LOCK_ELEMENT LockElement; + PCOMBINED_LOCK_ELEMENT WhereUnlocked = PeekContext, Matching; + PLOCK_INFORMATION LockInfo = CONTAINING_RECORD(Csq, LOCK_INFORMATION, Csq); + PFILE_LOCK FileLock = LockInfo->BelongsTo; + if (!PeekContext) + return CONTAINING_RECORD + (Irp->Tail.Overlay.ListEntry.Flink, + IRP, + Tail.Overlay.ListEntry); + else + { + PLIST_ENTRY Following; + if (!FileLock->LockInformation) + { + return CONTAINING_RECORD + (Irp->Tail.Overlay.ListEntry.Flink, + IRP, + Tail.Overlay.ListEntry); + } + for (Following = Irp->Tail.Overlay.ListEntry.Flink; + Following != &WhereUnlocked->Exclusive.ListEntry; + Following = Following->Flink) + { + PIRP Irp = CONTAINING_RECORD(Following, IRP, Tail.Overlay.ListEntry); + PIO_STACK_LOCATION IoStack = IoGetCurrentIrpStackLocation(Irp); + LockElement.Exclusive.FileLock.StartingByte = + IoStack->Parameters.LockControl.ByteOffset; + LockElement.Exclusive.FileLock.EndingByte.QuadPart = + LockElement.Exclusive.FileLock.StartingByte.QuadPart + + IoStack->Parameters.LockControl.Length->QuadPart; + Matching = RtlLookupElementGenericTable + (FileLock->LockInformation, &LockElement); + if (!Matching) + { + // This IRP is fine... + return Irp; + } + } + return NULL; + } +} + +static VOID NTAPI +LockAcquireQueueLock(PIO_CSQ Csq, PKIRQL Irql) +{ + PLOCK_INFORMATION LockInfo = CONTAINING_RECORD(Csq, LOCK_INFORMATION, Csq); + KeAcquireSpinLock(&LockInfo->CsqLock, Irql); +} + +static VOID NTAPI +LockReleaseQueueLock(PIO_CSQ Csq, KIRQL Irql) +{ + PLOCK_INFORMATION LockInfo = CONTAINING_RECORD(Csq, LOCK_INFORMATION, Csq); + KeReleaseSpinLock(&LockInfo->CsqLock, Irql); +} + +static VOID NTAPI +LockCompleteCanceledIrp(PIO_CSQ Csq, PIRP Irp) +{ + NTSTATUS Status; + PLOCK_INFORMATION LockInfo = CONTAINING_RECORD(Csq, LOCK_INFORMATION, Csq); + FsRtlCompleteLockIrpReal + (LockInfo->BelongsTo->CompleteLockIrpRoutine, + NULL, + Irp, + STATUS_CANCELLED, + &Status, + NULL); +} VOID NTAPI @@ -55,8 +217,11 @@ FsRtlGetNextFileLock(IN PFILE_LOCK FileLock, IN BOOLEAN Restart) { - KeBugCheck(FILE_SYSTEM); - return NULL; + PCOMBINED_LOCK_ELEMENT Entry; + if (!FileLock->LockInformation) return NULL; + Entry = RtlEnumerateGenericTable(FileLock->LockInformation, Restart); + if (!Entry) return NULL; + else return &Entry->Exclusive.FileLock; } /* @@ -78,31 +243,137 @@ IN BOOLEAN AlreadySynchronized) { NTSTATUS Status; + COMBINED_LOCK_ELEMENT ToInsert; + PCOMBINED_LOCK_ELEMENT Conflict; + PLOCK_INFORMATION LockInfo; + BOOLEAN InsertedNew; DPRINT1("FsRtlPrivateLock() is stubplemented!\n"); + ASSERT(AlreadySynchronized); /* Initialize the lock, if necessary */ if (!FileLock->LockInformation) { - DPRINT("LockInformation is uninitialized!\n"); + LockInfo = ExAllocatePool(PagedPool, sizeof(LOCK_INFORMATION)); + FileLock->LockInformation = LockInfo; + if (!FileLock) + return FALSE; + + LockInfo->BelongsTo = FileLock; + + RtlInitializeGenericTable + (&LockInfo->RangeTable, + LockCompare, + LockAllocate, + LockFree, + NULL); + + KeInitializeSpinLock(&LockInfo->CsqLock); + + IoCsqInitializeEx + (&LockInfo->Csq, + LockInsertIrpEx, + LockRemoveIrp, + LockPeekNextIrp, + LockAcquireQueueLock, + LockReleaseQueueLock, + LockCompleteCanceledIrp); } - /* Assume all is cool, and lock is set */ - IoStatus->Status = STATUS_SUCCESS; - - if (Irp) - { - /* Complete the request */ - FsRtlCompleteLockIrpReal(FileLock->CompleteLockIrpRoutine, - Context, - Irp, - IoStatus->Status, - &Status, - FileObject); - - /* Update the status */ - IoStatus->Status = Status; - } + LockInfo = FileLock->LockInformation; + ToInsert.Exclusive.FileLock.FileObject = FileObject; + ToInsert.Exclusive.FileLock.StartingByte = *FileOffset; + ToInsert.Exclusive.FileLock.EndingByte.QuadPart = FileOffset->QuadPart + Length->QuadPart; + ToInsert.Exclusive.FileLock.ProcessId = Process->UniqueProcessId; + ToInsert.Exclusive.FileLock.Key = Key; + ToInsert.Exclusive.FileLock.ExclusiveLock = ExclusiveLock; + + Conflict = RtlInsertElementGenericTable + (FileLock->LockInformation, + &ToInsert, + sizeof(ToInsert), + &InsertedNew); + + if (Conflict && !InsertedNew) + { + if (Conflict->Exclusive.FileLock.ExclusiveLock || ExclusiveLock) + { + if (FailImmediately) + { + IoStatus->Status = STATUS_FILE_LOCK_CONFLICT; + if (Irp) + { + FsRtlCompleteLockIrpReal + (FileLock->CompleteLockIrpRoutine, + Context, + Irp, + IoStatus->Status, + &Status, + FileObject); + } + return FALSE; + } + else + { + IoStatus->Status = STATUS_PENDING; + if (Irp) + { + IoMarkIrpPending(Irp); + IoCsqInsertIrpEx + (&LockInfo->Csq, + Irp, + NULL, + NULL); + } + } + return FALSE; + } + else + { + IoStatus->Status = STATUS_SUCCESS; + if (Irp) + { + FsRtlCompleteLockIrpReal + (FileLock->CompleteLockIrpRoutine, + Context, + Irp, + IoStatus->Status, + &Status, + FileObject); + } + return FALSE; + } + } + else if (!Conflict) + { + /* Conflict here is (or would be) the newly inserted element, but we ran + * out of space probably. */ + IoStatus->Status = STATUS_NO_MEMORY; + return FALSE; + } + else + { + /* Assume all is cool, and lock is set */ + IoStatus->Status = STATUS_SUCCESS; + + // Initialize our resource ... We'll use this to mediate access to the + // irp queue. + ExInitializeResourceLite(&Conflict->Exclusive.Resource); + + if (Irp) + { + /* Complete the request */ + FsRtlCompleteLockIrpReal(FileLock->CompleteLockIrpRoutine, + Context, + Irp, + IoStatus->Status, + &Status, + FileObject); + + /* Update the status */ + IoStatus->Status = Status; + } + } return TRUE; } @@ -115,8 +386,20 @@ FsRtlCheckLockForReadAccess(IN PFILE_LOCK FileLock, IN PIRP Irp) { - KeBugCheck(FILE_SYSTEM); - return FALSE; + PIO_STACK_LOCATION IoStack = IoGetCurrentIrpStackLocation(Irp); + COMBINED_LOCK_ELEMENT ToFind; + PCOMBINED_LOCK_ELEMENT Found; + if (!FileLock->LockInformation) return TRUE; + ToFind.Exclusive.FileLock.StartingByte = IoStack->Parameters.Read.ByteOffset; + ToFind.Exclusive.FileLock.EndingByte.QuadPart = + ToFind.Exclusive.FileLock.StartingByte.QuadPart + + IoStack->Parameters.Read.Length; + Found = RtlLookupElementGenericTable + (FileLock->LockInformation, + &ToFind); + if (!Found) return TRUE; + return !Found->Exclusive.FileLock.ExclusiveLock || + IoStack->Parameters.Read.Key == Found->Exclusive.FileLock.Key; } /* @@ -127,8 +410,20 @@ FsRtlCheckLockForWriteAccess(IN PFILE_LOCK FileLock, IN PIRP Irp) { - KeBugCheck(FILE_SYSTEM); - return FALSE; + PIO_STACK_LOCATION IoStack = IoGetCurrentIrpStackLocation(Irp); + COMBINED_LOCK_ELEMENT ToFind; + PCOMBINED_LOCK_ELEMENT Found; + PEPROCESS Process = Irp->Tail.Overlay.Thread->ThreadsProcess; + if (!FileLock->LockInformation) return TRUE; + ToFind.Exclusive.FileLock.StartingByte = IoStack->Parameters.Write.ByteOffset; + ToFind.Exclusive.FileLock.EndingByte.QuadPart = + ToFind.Exclusive.FileLock.StartingByte.QuadPart + + IoStack->Parameters.Write.Length; + Found = RtlLookupElementGenericTable + (FileLock->LockInformation, + &ToFind); + if (!Found) return TRUE; + return Process->UniqueProcessId == Found->Exclusive.FileLock.ProcessId; } /* @@ -143,8 +438,19 @@ IN PFILE_OBJECT FileObject, IN PVOID Process) { - KeBugCheck(FILE_SYSTEM); - return FALSE; + PEPROCESS EProcess = Process; + COMBINED_LOCK_ELEMENT ToFind; + PCOMBINED_LOCK_ELEMENT Found; + ToFind.Exclusive.FileLock.StartingByte = *FileOffset; + ToFind.Exclusive.FileLock.EndingByte.QuadPart = + FileOffset->QuadPart + Length->QuadPart; + if (!FileLock->LockInformation) return TRUE; + Found = RtlLookupElementGenericTable + (FileLock->LockInformation, + &ToFind); + if (!Found || !Found->Exclusive.FileLock.ExclusiveLock) return TRUE; + return Found->Exclusive.FileLock.Key == Key && + Found->Exclusive.FileLock.ProcessId == EProcess->UniqueProcessId; } /* @@ -159,8 +465,19 @@ IN PFILE_OBJECT FileObject, IN PVOID Process) { - KeBugCheck(FILE_SYSTEM); - return FALSE; + PEPROCESS EProcess = Process; + COMBINED_LOCK_ELEMENT ToFind; + PCOMBINED_LOCK_ELEMENT Found; + ToFind.Exclusive.FileLock.StartingByte = *FileOffset; + ToFind.Exclusive.FileLock.EndingByte.QuadPart = + FileOffset->QuadPart + Length->QuadPart; + if (!FileLock->LockInformation) return TRUE; + Found = RtlLookupElementGenericTable + (FileLock->LockInformation, + &ToFind); + if (!Found) return TRUE; + return Found->Exclusive.FileLock.Key == Key && + Found->Exclusive.FileLock.ProcessId == EProcess->UniqueProcessId; } /* @@ -177,9 +494,38 @@ IN PVOID Context OPTIONAL, IN BOOLEAN AlreadySynchronized) { - DPRINT1("FsRtlFastUnlockSingle() is stubplemented!\n"); - - return STATUS_SUCCESS; + COMBINED_LOCK_ELEMENT Find; + PCOMBINED_LOCK_ELEMENT Entry; + PIRP NextMatchingLockIrp; + PLOCK_INFORMATION InternalInfo = FileLock->LockInformation; + // The region to unlock must correspond exactly to a previously locked region + // -- msdn + ASSERT(AlreadySynchronized); + Find.Exclusive.FileLock.StartingByte = *FileOffset; + Find.Exclusive.FileLock.EndingByte.QuadPart = + FileOffset->QuadPart + Length->QuadPart; + Entry = RtlLookupElementGenericTable(&InternalInfo->RangeTable, &Find); + if (!Entry) return STATUS_RANGE_NOT_LOCKED; + if (Entry->Exclusive.FileLock.Key != Key || + Entry->Exclusive.FileLock.ProcessId != Process->UniqueProcessId) + return STATUS_RANGE_NOT_LOCKED; + if (Entry->Exclusive.FileLock.StartingByte.QuadPart != FileOffset->QuadPart || + Entry->Exclusive.FileLock.EndingByte.QuadPart != + FileOffset->QuadPart + Length->QuadPart) + return STATUS_RANGE_NOT_LOCKED; + // this is definitely the thing we want + RtlCopyMemory(&Find, Entry, sizeof(Find)); + RtlDeleteElementGenericTable(&InternalInfo->RangeTable, Entry); + NextMatchingLockIrp = IoCsqRemoveNextIrp(&InternalInfo->Csq, &Find); + if (NextMatchingLockIrp) + { + // Got a new lock irp... try to do the new lock operation + // Note that we pick an operation that would succeed at the time + // we looked, but can't guarantee that it won't just be re-queued + // because somebody else snatched part of the range in a new thread. + FsRtlProcessFileLock(InternalInfo->BelongsTo, NextMatchingLockIrp, NULL); + } + return STATUS_SUCCESS; } /* @@ -192,8 +538,32 @@ IN PEPROCESS Process, IN PVOID Context OPTIONAL) { - KeBugCheck(FILE_SYSTEM); - return STATUS_UNSUCCESSFUL; + PCOMBINED_LOCK_ELEMENT Entry; + PRTL_GENERIC_TABLE InternalInfo = FileLock->LockInformation; + + // XXX Synchronize somehow + if (!FileLock->LockInformation) return STATUS_RANGE_NOT_LOCKED; // no locks + for (Entry = RtlEnumerateGenericTable(InternalInfo, TRUE); + Entry; + Entry = RtlEnumerateGenericTable(InternalInfo, FALSE)) + { + LARGE_INTEGER Length; + // We'll take the first one to be the list head, and free the others first... + Length.QuadPart = + Entry->Exclusive.FileLock.EndingByte.QuadPart - + Entry->Exclusive.FileLock.StartingByte.QuadPart; + FsRtlFastUnlockSingle + (FileLock, + Entry->Exclusive.FileLock.FileObject, + &Entry->Exclusive.FileLock.StartingByte, + &Length, + Entry->Exclusive.FileLock.ProcessId, + Entry->Exclusive.FileLock.Key, + Context, + TRUE); + } + + return STATUS_SUCCESS; } /* @@ -207,8 +577,36 @@ IN ULONG Key, IN PVOID Context OPTIONAL) { - KeBugCheck(FILE_SYSTEM); - return STATUS_UNSUCCESSFUL; + PCOMBINED_LOCK_ELEMENT Entry; + PRTL_GENERIC_TABLE InternalInfo = FileLock->LockInformation; + + // XXX Synchronize somehow + if (!FileLock->LockInformation) return STATUS_RANGE_NOT_LOCKED; // no locks + for (Entry = RtlEnumerateGenericTable(InternalInfo, TRUE); + Entry; + Entry = RtlEnumerateGenericTable(InternalInfo, FALSE)) + { + LARGE_INTEGER Length; + // We'll take the first one to be the list head, and free the others first... + Length.QuadPart = + Entry->Exclusive.FileLock.EndingByte.QuadPart - + Entry->Exclusive.FileLock.StartingByte.QuadPart; + if (Entry->Exclusive.FileLock.Key == Key && + Entry->Exclusive.FileLock.ProcessId == Process->UniqueProcessId) + { + FsRtlFastUnlockSingle + (FileLock, + Entry->Exclusive.FileLock.FileObject, + &Entry->Exclusive.FileLock.StartingByte, + &Length, + Entry->Exclusive.FileLock.ProcessId, + Entry->Exclusive.FileLock.Key, + Context, + TRUE); + } + } + + return STATUS_SUCCESS; } /* @@ -353,7 +751,12 @@ NTAPI FsRtlUninitializeFileLock(IN PFILE_LOCK FileLock) { - return; + if (FileLock->LockInformation) + { + ASSERT(!RtlNumberGenericTableElements(FileLock->LockInformation)); + ExFreePool(FileLock->LockInformation); + FileLock->LockInformation = NULL; + } } /* @@ -391,4 +794,3 @@ FsRtlUninitializeFileLock(FileLock); ExFreeToPagedLookasideList(&FsRtlFileLockLookasideList, FileLock); } -
15 years, 1 month
1
0
0
0
[tkreuzer] 44229: [MM] Implement MiBuildPagedPool. Refactor MmArmInitSystem. Use a hardcoded address for the PFN database, this might not be identical to windows, but it makes things simpler and there's no real point in dynamically putting it below the non paged pool. Use a global MxPhase to decide whether to do early page allocations using MxAllocEarlyPage or use MmAllocPage in phase 1. Paged pool allocations work now, but the page fault isn't handled yet.
by tkreuzer@svn.reactos.org
Author: tkreuzer Date: Wed Nov 18 22:35:14 2009 New Revision: 44229 URL:
http://svn.reactos.org/svn/reactos?rev=44229&view=rev
Log: [MM] Implement MiBuildPagedPool. Refactor MmArmInitSystem. Use a hardcoded address for the PFN database, this might not be identical to windows, but it makes things simpler and there's no real point in dynamically putting it below the non paged pool. Use a global MxPhase to decide whether to do early page allocations using MxAllocEarlyPage or use MmAllocPage in phase 1. Paged pool allocations work now, but the page fault isn't handled yet. Modified: branches/ros-amd64-bringup/reactos/ntoskrnl/mm/amd64/init.c Modified: branches/ros-amd64-bringup/reactos/ntoskrnl/mm/amd64/init.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/ntosk…
============================================================================== --- branches/ros-amd64-bringup/reactos/ntoskrnl/mm/amd64/init.c [iso-8859-1] (original) +++ branches/ros-amd64-bringup/reactos/ntoskrnl/mm/amd64/init.c [iso-8859-1] Wed Nov 18 22:35:14 2009 @@ -77,6 +77,10 @@ PFN_NUMBER MxFreePageBase; ULONG64 MxFreePageCount = 0; +ULONG MxPhase = 0; + +PFN_NUMBER MmSystemPageDirectory; +PFN_NUMBER MmSizeOfPagedPoolInPages = MI_MIN_INIT_PAGED_POOLSIZE / PAGE_SIZE; /* FUNCTIONS *****************************************************************/ @@ -95,6 +99,10 @@ PLIST_ENTRY ListEntry; PFN_NUMBER LastPage; ULONG i; + + /* Get the size of the boot loader's image allocations */ + MmBootImageSize = KeLoaderBlock->Extension->LoaderPagesSpanned * PAGE_SIZE; + MmBootImageSize = ROUND_UP(MmBootImageSize, 4 * 1024 * 1024); /* Instantiate memory that we don't consider RAM/usable */ for (i = 0; i < LoaderMaximum; i++) MiIncludeType[i] = TRUE; @@ -160,47 +168,54 @@ PFN_NUMBER NTAPI -MxGetNextPage(IN PFN_NUMBER PageCount) +MxAllocEarlyPage() { PFN_NUMBER Pfn; /* Make sure we have enough pages */ - if (PageCount > MxFreePageCount) + if (!MxFreePageCount) { /* Crash the system */ KeBugCheckEx(INSTALL_MORE_MEMORY, MmNumberOfPhysicalPages, MxFreeDescriptor->PageCount, MxOldFreeDescriptor.PageCount, - PageCount); + 1); } /* Use our lowest usable free pages */ Pfn = MxFreePageBase; - MxFreePageBase += PageCount; - MxFreePageCount -= PageCount; + MxFreePageBase++; + MxFreePageCount--; return Pfn; } +PFN_NUMBER +NTAPI +MxAllocPage() +{ + return (MxPhase == 0) ? MxAllocEarlyPage() : MmAllocPage(MC_SYSTEM, 0); +} + PMMPTE NTAPI MxGetPte(PVOID Address) { PMMPTE Pte; - MMPTE TmpPte; + MMPTE TmplPte; /* Setup template pte */ - TmpPte.u.Long = 0; - TmpPte.u.Flush.Valid = 1; - TmpPte.u.Flush.Write = 1; + TmplPte.u.Long = 0; + TmplPte.u.Flush.Valid = 1; + TmplPte.u.Flush.Write = 1; /* Get a pointer to the PXE */ Pte = MiAddressToPxe(Address); if (!Pte->u.Hard.Valid) { /* It's not valid, map it! */ - TmpPte.u.Hard.PageFrameNumber = MxGetNextPage(1); - *Pte = TmpPte; + TmplPte.u.Hard.PageFrameNumber = MxAllocPage(); + *Pte = TmplPte; } /* Get a pointer to the PPE */ @@ -208,8 +223,8 @@ if (!Pte->u.Hard.Valid) { /* It's not valid, map it! */ - TmpPte.u.Hard.PageFrameNumber = MxGetNextPage(1); - *Pte = TmpPte; + TmplPte.u.Hard.PageFrameNumber = MxAllocPage(); + *Pte = TmplPte; } /* Get a pointer to the PDE */ @@ -217,8 +232,8 @@ if (!Pte->u.Hard.Valid) { /* It's not valid, map it! */ - TmpPte.u.Hard.PageFrameNumber = MxGetNextPage(1); - *Pte = TmpPte; + TmplPte.u.Hard.PageFrameNumber = MxAllocPage(); + *Pte = TmplPte; } /* Get a pointer to the PTE */ @@ -227,24 +242,31 @@ } VOID +MxMapPage(PVOID Address) +{ + MMPTE TmplPte, *Pte; + + /* Setup template pte */ + TmplPte.u.Long = 0; + TmplPte.u.Flush.Valid = 1; + TmplPte.u.Flush.Write = 1; + TmplPte.u.Hard.PageFrameNumber = MxAllocPage(); + + /* Get the PTE for that page */ + Pte = MxGetPte(Address); + ASSERT(Pte->u.Hard.Valid == 0); + + /* Map a physical page */ + *Pte = TmplPte; +} + +VOID MxMapPageRange(PVOID Address, ULONG64 PageCount) { - MMPTE TmpPte, *Pte; - - /* Setup template pte */ - TmpPte.u.Long = 0; - TmpPte.u.Flush.Valid = 1; - TmpPte.u.Flush.Write = 1; - while (PageCount--) { - /* Get the PTE for that page */ - Pte = MxGetPte(Address); - ASSERT(Pte->u.Hard.Valid == 0); - - /* Map a physical page */ - TmpPte.u.Hard.PageFrameNumber = MxGetNextPage(1); - *Pte = TmpPte; + /* Map the page */ + MxMapPage(Address); /* Goto next page */ Address = (PVOID)((ULONG64)Address + PAGE_SIZE); @@ -253,11 +275,170 @@ VOID NTAPI -MiArmConfigureMemorySizes(IN PLOADER_PARAMETER_BLOCK LoaderBloc) -{ - /* Get the size of the boot loader's image allocations */ - MmBootImageSize = KeLoaderBlock->Extension->LoaderPagesSpanned * PAGE_SIZE; - MmBootImageSize = ROUND_UP(MmBootImageSize, 4 * 1024 * 1024); +MiPreparePfnDatabse(IN PLOADER_PARAMETER_BLOCK LoaderBlock) +{ + PMEMORY_ALLOCATION_DESCRIPTOR MdBlock; + PLIST_ENTRY ListEntry; + PUCHAR Page, FirstPage; + SIZE_T Size; + + /* Calculate the size of the PFN database and convert to pages */ + MxPfnSizeInBytes = ROUND_TO_PAGES((MmHighestPhysicalPage + 1) * sizeof(MMPFN)); + MxPfnAllocation = MxPfnSizeInBytes >> PAGE_SHIFT; + + /* Sinply start at hardcoded address */ + MmPfnDatabase = (PVOID)0xFFFFFAC000000000ULL; + + /* Loop the memory descriptors */ + for (ListEntry = LoaderBlock->MemoryDescriptorListHead.Flink; + ListEntry != &LoaderBlock->MemoryDescriptorListHead; + ListEntry = ListEntry->Flink) + { + /* Get the memory descriptor */ + MdBlock = CONTAINING_RECORD(ListEntry, + MEMORY_ALLOCATION_DESCRIPTOR, + ListEntry); + + /* Skip pages that are not part of the PFN database */ + if (MiIncludeType[MdBlock->MemoryType]) + { + /* Get the base and size of this pfn database entry */ + FirstPage = PAGE_ALIGN(&MmPfnDatabase[MdBlock->BasePage]); + Size = ROUND_TO_PAGES(MdBlock->PageCount * sizeof(MMPFN)); + + /* Loop the pages of this Pfn database entry */ + for (Page = FirstPage; Page < FirstPage + Size; Page += PAGE_SIZE) + { + /* Is the page already mapped? */ + if (!MmIsAddressValid(Page)) + { + /* It's not, map it now */ + MxMapPage(Page); + } + } + + /* Zero out the pages */ + RtlZeroMemory(FirstPage, Size); + } + } +} + + +VOID +NTAPI +MiInitializeSessionSpace(IN PLOADER_PARAMETER_BLOCK LoaderBlock) +{ + /* Set up session space */ + MiSessionSpaceEnd = (PVOID)MI_SESSION_SPACE_END; + + /* This is where we will load Win32k.sys and the video driver */ + MiSessionImageEnd = MiSessionSpaceEnd; + MiSessionImageStart = (PCHAR)MiSessionImageEnd - MmSessionImageSize; + + /* The view starts right below the session working set (itself below + * the image area) */ + MiSessionViewEnd = MI_SESSION_VIEW_END; + MiSessionViewStart = (PCHAR)MiSessionViewEnd - MmSessionViewSize; + ASSERT(IS_PAGE_ALIGNED(MiSessionViewStart)); + + /* Session pool follows */ + MiSessionPoolEnd = MiSessionViewStart; + MiSessionPoolStart = (PCHAR)MiSessionPoolEnd - MmSessionPoolSize; + ASSERT(IS_PAGE_ALIGNED(MiSessionPoolStart)); + + /* And it all begins here */ + MmSessionBase = MiSessionPoolStart; + + /* System view space ends at session space, so now that we know where + * this is, we can compute the base address of system view space itself. */ + MiSystemViewStart = (PCHAR)MmSessionBase - MmSystemViewSize; + ASSERT(IS_PAGE_ALIGNED(MiSystemViewStart)); + + /* Sanity checks */ + ASSERT(MiSessionViewEnd <= MiSessionImageStart); + ASSERT(MmSessionBase <= MiSessionPoolStart); +} + +VOID +MiInitializePageTable() +{ + ULONG64 PageFrameOffset; + PMMPTE Pte, StartPte, EndPte; + MMPTE TmplPte; + PFN_NUMBER PageCount; + + /* HACK: don't use freeldr debug print anymore */ + FrLdrDbgPrint = NoDbgPrint; + + /* Get current directory base */ + MmSystemPageDirectory = ((PMMPTE)PXE_SELFMAP)->u.Hard.PageFrameNumber; + PageFrameOffset = MmSystemPageDirectory << PAGE_SHIFT; + ASSERT(PageFrameOffset == __readcr3()); + + /* Set directory base for the system process */ + PsGetCurrentProcess()->Pcb.DirectoryTableBase[0] = PageFrameOffset; + + /* Enable global pages */ + __writecr4(__readcr4() | CR4_PGE); + ASSERT(__readcr4() & CR4_PGE); + + /* Set user mode address range */ + StartPte = MiAddressToPxe(0); + EndPte = MiAddressToPxe(MmHighestUserAddress); + + /* Loop the user mode PXEs */ + for (Pte = StartPte; Pte <= EndPte; Pte++) + { + /* Zero the PXE, clear all mappings */ + Pte->u.Long = 0; + } + + /* Flush the TLB */ + KeFlushCurrentTb(); + + /* Set up a template PTE */ + TmplPte.u.Long = 0; + TmplPte.u.Flush.Valid = 1; + TmplPte.u.Flush.Write = 1; + HyperTemplatePte = TmplPte; + + /* Create PDPTs (72 KB) for shared system address space, + * skip page tables and hyperspace */ + + /* Set the range */ + StartPte = MiAddressToPxe((PVOID)(HYPER_SPACE_END + 1)); + EndPte = MiAddressToPxe(MI_HIGHEST_SYSTEM_ADDRESS); + + /* Loop the PXEs */ + for (Pte = StartPte; Pte <= EndPte; Pte++) + { + /* Is the PXE already valid? */ + if (!Pte->u.Hard.Valid) + { + /* It's not Initialize it */ + TmplPte.u.Flush.PageFrameNumber = MxAllocPage(); + *Pte = TmplPte; + + /* Zero the page. The PXE is the PTE for the PDPT. */ + RtlZeroMemory(MiPteToAddress(Pte), PAGE_SIZE); + } + } + + /* Setup the mapping PTEs */ + MmFirstReservedMappingPte = MxGetPte((PVOID)MI_MAPPING_RANGE_START); + MmFirstReservedMappingPte->u.Hard.PageFrameNumber = MI_HYPERSPACE_PTES; + MmLastReservedMappingPte = MiAddressToPte((PVOID)MI_MAPPING_RANGE_END); + + /* Setup debug mapping PTE */ + MmDebugPte = MxGetPte(MI_DEBUG_MAPPING); +} + +VOID +NTAPI +MiBuildNonPagedPool(VOID) +{ + PMMPTE Pte; + PFN_COUNT PageCount; /* Check if this is a machine with less than 256MB of RAM, and no overide */ if ((MmNumberOfPhysicalPages <= MI_MIN_PAGES_FOR_NONPAGED_POOL_TUNING) && @@ -317,58 +498,50 @@ MmMaximumNonPagedPoolInBytes = MI_MAX_NONPAGED_POOL_SIZE; } - // MmSessionImageSize -} - -VOID -NTAPI -MiArmInitializeMemoryLayout(IN PLOADER_PARAMETER_BLOCK LoaderBlock) -{ - /* Set up session space */ - MiSessionSpaceEnd = (PVOID)MI_SESSION_SPACE_END; - - /* This is where we will load Win32k.sys and the video driver */ - MiSessionImageEnd = MiSessionSpaceEnd; - MiSessionImageStart = (PCHAR)MiSessionImageEnd - MmSessionImageSize; - - /* The view starts right below the session working set (itself below - * the image area) */ - MiSessionViewEnd = MI_SESSION_VIEW_END; - MiSessionViewStart = (PCHAR)MiSessionViewEnd - MmSessionViewSize; - ASSERT(IS_PAGE_ALIGNED(MiSessionViewStart)); - - /* Session pool follows */ - MiSessionPoolEnd = MiSessionViewStart; - MiSessionPoolStart = (PCHAR)MiSessionPoolEnd - MmSessionPoolSize; - ASSERT(IS_PAGE_ALIGNED(MiSessionPoolStart)); - - /* And it all begins here */ - MmSessionBase = MiSessionPoolStart; - - /* System view space ends at session space, so now that we know where - * this is, we can compute the base address of system view space itself. */ - MiSystemViewStart = (PCHAR)MmSessionBase - MmSystemViewSize; - ASSERT(IS_PAGE_ALIGNED(MiSystemViewStart)); - - /* Calculate the size of the PFN database and convert to pages */ - MxPfnSizeInBytes = ROUND_TO_PAGES((MmHighestPhysicalPage + 1) * sizeof(MMPFN)); - MxPfnAllocation = MxPfnSizeInBytes >> PAGE_SHIFT; - - /* The PFN database is at the start of the non paged region */ - MmPfnDatabase = (PVOID)((PCHAR)MmNonPagedPoolEnd - - MmMaximumNonPagedPoolInBytes); - - /* Reduce maximum non paged pool size */ - MmMaximumNonPagedPoolInBytes -= MxPfnSizeInBytes; - - /* Put non paged pool after the PFN database */ - MmNonPagedPoolStart = (PCHAR)MmPfnDatabase + MxPfnSizeInBytes; + /* Put non paged pool to the end of the region */ + MmNonPagedPoolStart = (PCHAR)MmNonPagedPoolEnd - MmMaximumNonPagedPoolInBytes; + + /* Make sure it doesn't collide with the PFN database */ + if ((PCHAR)MmNonPagedPoolStart < (PCHAR)MmPfnDatabase + MxPfnSizeInBytes) + { + /* Put non paged pool after the PFN database */ + MmNonPagedPoolStart = (PCHAR)MmPfnDatabase + MxPfnSizeInBytes; + MmMaximumNonPagedPoolInBytes = (ULONG64)MmNonPagedPoolEnd - + (ULONG64)MmNonPagedPoolStart; + } + ASSERT(IS_PAGE_ALIGNED(MmNonPagedPoolStart)); /* Calculate the nonpaged pool expansion start region */ MmNonPagedPoolExpansionStart = (PCHAR)MmNonPagedPoolStart + MmSizeOfNonPagedPoolInBytes; ASSERT(IS_PAGE_ALIGNED(MmNonPagedPoolExpansionStart)); + + /* Map the nonpaged pool */ + PageCount = (MmSizeOfNonPagedPoolInBytes + PAGE_SIZE - 1) / PAGE_SIZE; + MxMapPageRange(MmNonPagedPoolStart, PageCount); + + /* Loop the non paged pool extension PTEs */ + for (Pte = MiAddressToPte(MmNonPagedPoolExpansionStart); + Pte <= MiAddressToPte(MmNonPagedPoolEnd); + Pte++) + { + /* Create PXE, PPE, PDE and zero the PTE */ + MxGetPte(MiPteToAddress(Pte))->u.Long = 0; + } + + /* Initialize the ARM3 nonpaged pool */ + MiInitializeArmPool(); + + /* Initialize the nonpaged pool */ + InitializePool(NonPagedPool, 0); +} + +VOID +NTAPI +MiBuildSystemPteSpace() +{ + PMMPTE Pte, StartPte, EndPte; /* Use the default numer of system PTEs */ MmNumberOfSystemPtes = MI_NUMBER_SYSTEM_PTES; @@ -392,122 +565,6 @@ ASSERT(MmNumberOfSystemPtes > 1000); } - /* Sanity checks */ - ASSERT(MiSessionViewEnd <= MiSessionImageStart); - ASSERT(MmSessionBase <= MiSessionPoolStart); -} - -VOID -NTAPI -MiArmPreparePfnDatabse(IN PLOADER_PARAMETER_BLOCK LoaderBlock) -{ - PMEMORY_ALLOCATION_DESCRIPTOR MdBlock; - PLIST_ENTRY ListEntry; - PUCHAR Page, FirstPage; - SIZE_T Size; - - /* Loop the memory descriptors */ - for (ListEntry = LoaderBlock->MemoryDescriptorListHead.Flink; - ListEntry != &LoaderBlock->MemoryDescriptorListHead; - ListEntry = ListEntry->Flink) - { - /* Get the memory descriptor */ - MdBlock = CONTAINING_RECORD(ListEntry, - MEMORY_ALLOCATION_DESCRIPTOR, - ListEntry); - - /* Skip pages that are not part of the PFN database */ - if (!MiIncludeType[MdBlock->MemoryType]) - { - continue; - } - - /* Get the base and size of this pfn database entry */ - FirstPage = PAGE_ALIGN(&MmPfnDatabase[MdBlock->BasePage]); - Size = ROUND_TO_PAGES(MdBlock->PageCount * sizeof(MMPFN)); - - /* Loop the pages of this Pfn database entry */ - for (Page = FirstPage; Page < FirstPage + Size; Page += PAGE_SIZE) - { - /* Is the page already mapped? */ - if (!MmIsAddressValid(Page)) - { - /* It's not, map it now */ - MxMapPageRange(Page, 1); - } - } - - /* Zero out the pages */ - RtlZeroMemory(FirstPage, Size); - } -} - - -VOID -MiArmInitializePageTable() -{ - ULONG64 PageFrameOffset; - PMMPTE Pte, StartPte, EndPte; - MMPTE TmplPte; - PFN_NUMBER PageCount; - PVOID Address; - - /* HACK: don't use freeldr debug print anymore */ - FrLdrDbgPrint = NoDbgPrint; - - /* Get current directory base */ - PageFrameOffset = ((PMMPTE)PXE_SELFMAP)->u.Hard.PageFrameNumber << PAGE_SHIFT; - ASSERT(PageFrameOffset == __readcr3()); - - /* Set directory base for the system process */ - PsGetCurrentProcess()->Pcb.DirectoryTableBase[0] = PageFrameOffset; - - /* Enable global pages */ - __writecr4(__readcr4() | CR4_PGE); - ASSERT(__readcr4() & CR4_PGE); - - /* Set user mode address range */ - StartPte = MiAddressToPxe(0); - EndPte = MiAddressToPxe(MmHighestUserAddress); - - /* Loop the user mode PXEs */ - for (Pte = StartPte; Pte <= EndPte; Pte++) - { - /* Zero the PXE, clear all mappings */ - Pte->u.Long = 0; - } - - /* Flush the TLB */ - KeFlushCurrentTb(); - - /* Set up a template PTE */ - TmplPte.u.Long = 0; - TmplPte.u.Flush.Valid = 1; - TmplPte.u.Flush.Write = 1; - HyperTemplatePte = TmplPte; - - /* Create PDPTs (72 KB) for shared system address space, - * skip page tables and hyperspace */ - - /* Set the range */ - StartPte = MiAddressToPxe((PVOID)(HYPER_SPACE_END + 1)); - EndPte = MiAddressToPxe(MI_HIGHEST_SYSTEM_ADDRESS); - - /* Loop the PXEs */ - for (Pte = StartPte; Pte <= EndPte; Pte++) - { - /* Is the PXE already valid? */ - if (!Pte->u.Hard.Valid) - { - /* It's not Initialize it */ - TmplPte.u.Flush.PageFrameNumber = MxGetNextPage(1); - *Pte = TmplPte; - - /* Zero the page. The PXE is the PTE for the PDPT. */ - RtlZeroMemory(MiPteToAddress(Pte), PAGE_SIZE); - } - } - /* Set the range of system PTEs */ StartPte = MiAddressToPte(MI_SYSTEM_PTE_START); EndPte = StartPte + MmNumberOfSystemPtes - 1; @@ -515,32 +572,21 @@ /* Loop the system PTEs */ for (Pte = StartPte; Pte <= EndPte; Pte++) { - /* Make sure the PTE is valid */ - MxGetPte(MiPteToAddress(Pte)); - } - - /* Map the nonpaged pool */ - PageCount = (MmSizeOfNonPagedPoolInBytes + PAGE_SIZE - 1) / PAGE_SIZE; - MxMapPageRange(MmNonPagedPoolStart, PageCount); - - /* Create PTEs for the paged pool extension */ - for (Address = MmNonPagedPoolExpansionStart; - Address < MmNonPagedPoolEnd; - Address = (PVOID)((ULONG64)Address + PAGE_SIZE)) - { - /* Create PXE, PPE, PDE and set PTE to 0*/ - MxGetPte(Address)->u.Long = 0; - } - - /* Setup the mapping PTEs */ - MmFirstReservedMappingPte = MxGetPte((PVOID)MI_MAPPING_RANGE_START); - MmFirstReservedMappingPte->u.Hard.PageFrameNumber = MI_HYPERSPACE_PTES; - MmLastReservedMappingPte = MiAddressToPte((PVOID)MI_MAPPING_RANGE_END); - - /* Setup debug mapping PTE */ - MmDebugPte = MxGetPte(MI_DEBUG_MAPPING); -} - + /* Create PXE, PPE, PDE and zero the PTE */ + MxGetPte(MiPteToAddress(Pte))->u.Long = 0; + } + + /* Create the system PTE space */ + Pte = MiAddressToPte(MI_SYSTEM_PTE_START); + MiInitializeSystemPtes(Pte, MmNumberOfSystemPtes, SystemPteSpace); + + /* Reserve system PTEs for zeroing PTEs and clear them */ + MiFirstReservedZeroingPte = MiReserveSystemPtes(MI_ZERO_PTES, SystemPteSpace); + RtlZeroMemory(MiFirstReservedZeroingPte, MI_ZERO_PTES * sizeof(MMPTE)); + + /* Set the counter to maximum */ + MiFirstReservedZeroingPte->u.Hard.PageFrameNumber = MI_ZERO_PTES - 1; +} VOID NTAPI @@ -555,7 +601,7 @@ ULONG Size, i; /* Calculate size for the PFN bitmap */ - Size = (MmHighestPhysicalPage + sizeof(ULONG)) / sizeof(ULONG); + Size = ROUND_UP(MmHighestPhysicalPage + 1, sizeof(ULONG)); /* Allocate the PFN bitmap */ Bitmap = ExAllocatePoolWithTag(NonPagedPool, Size, ' mM'); @@ -628,7 +674,129 @@ NTAPI MiBuildPagedPool(VOID) { - UNIMPLEMENTED; + PMMPTE Pte; + MMPTE TmplPte; + PFN_NUMBER PageFrameIndex; + KIRQL OldIrql; + ULONG Size, BitMapSize; + + /* Default size for paged pool is 4 times non paged pool */ + MmSizeOfPagedPoolInBytes = 4 * MmMaximumNonPagedPoolInBytes; + + /* Make sure it doesn't overflow */ + if (MmSizeOfPagedPoolInBytes > ((ULONG64)MmNonPagedSystemStart - + (ULONG64)MmPagedPoolStart)) + { + MmSizeOfPagedPoolInBytes = (ULONG64)MmNonPagedSystemStart - + (ULONG64)MmPagedPoolStart; + } + + /* Make sure paged pool is big enough */ + if (MmSizeOfPagedPoolInBytes < MI_MIN_INIT_PAGED_POOLSIZE) + { + MmSizeOfPagedPoolInBytes = MI_MIN_INIT_PAGED_POOLSIZE; + } + + /* Align down to a PDE boundary */ + MmSizeOfPagedPoolInBytes = ROUND_DOWN(MmSizeOfPagedPoolInBytes, + 512 * PAGE_SIZE); + MmSizeOfPagedPoolInPages = MmSizeOfPagedPoolInBytes >> PAGE_SHIFT; + + /* This is where paged pool ends */ + MmPagedPoolEnd = (PCHAR)MmPagedPoolStart + MmSizeOfPagedPoolInBytes - 1; + + /* Sanity check */ + ASSERT(MmPagedPoolEnd < MmNonPagedSystemStart); + + /* setup a template PTE */ + TmplPte.u.Long = 0; + TmplPte.u.Flush.Valid = 1; + TmplPte.u.Flush.Write = 1; + + /* Make sure the PXE is valid */ + Pte = MiAddressToPxe(MmPagedPoolStart); + if (!Pte->u.Flush.Valid) + { + /* Map it! */ + TmplPte.u.Flush.PageFrameNumber = MmAllocPage(MC_SYSTEM, 0); + *Pte = TmplPte; + } + + /* Map all page directories (max 128) */ + for (Pte = MiAddressToPpe(MmPagedPoolStart); + Pte <= MiAddressToPpe(MmPagedPoolEnd); + Pte++) + { + if (!Pte->u.Flush.Valid) + { + /* Map it! */ + TmplPte.u.Flush.PageFrameNumber = MxAllocPage(); + *Pte = TmplPte; + } + } + + /* Create and map the first PTE for paged pool */ + Pte = MxGetPte(MmPagedPoolStart); + TmplPte.u.Flush.PageFrameNumber = MxAllocPage(); + *Pte = TmplPte; + + /* Save the first and last paged pool PTE */ + MmPagedPoolInfo.FirstPteForPagedPool = MiAddressToPte(MmPagedPoolStart); + MmPagedPoolInfo.LastPteForPagedPool = MiAddressToPte(MmPagedPoolEnd); + + MmPagedPoolInfo.NextPdeForPagedPoolExpansion = + MiAddressToPde(MmPagedPoolStart) + 1; + + // We keep track of each page via a bit, so check how big the bitmap will + // have to be (make sure to align our page count such that it fits nicely + // into a 4-byte aligned bitmap. + + /* The size of the bitmap in bits is the size in pages */ + BitMapSize = MmSizeOfPagedPoolInPages; + + /* Calculate buffer size in bytes, aligned to 32 bits */ + Size = sizeof(RTL_BITMAP) + ROUND_UP(BitMapSize, 32) / 8; + + // Allocate the allocation bitmap, which tells us which regions have not yet + // been mapped into memory + + MmPagedPoolInfo.PagedPoolAllocationMap = + ExAllocatePoolWithTag(NonPagedPool, Size, ' mM'); + ASSERT(MmPagedPoolInfo.PagedPoolAllocationMap); + + DPRINT1("BitMapSize = 0x%lx, Size = 0x%lx\n", BitMapSize, Size); + // Initialize it such that at first, only the first page's worth of PTEs is + // marked as allocated (incidentially, the first PDE we allocated earlier). + RtlInitializeBitMap(MmPagedPoolInfo.PagedPoolAllocationMap, + (PULONG)(MmPagedPoolInfo.PagedPoolAllocationMap + 1), + BitMapSize); + RtlSetAllBits(MmPagedPoolInfo.PagedPoolAllocationMap); + RtlClearBits(MmPagedPoolInfo.PagedPoolAllocationMap, 0, 512); + + // We have a second bitmap, which keeps track of where allocations end. + // Given the allocation bitmap and a base address, we can therefore figure + // out which page is the last page of that allocation, and thus how big the + // entire allocation is. + MmPagedPoolInfo.EndOfPagedPoolBitmap = + ExAllocatePoolWithTag(NonPagedPool, Size, ' mM'); + ASSERT(MmPagedPoolInfo.EndOfPagedPoolBitmap); + + DPRINT1("PagedPoolAllocationMap=%p, EndOfPagedPoolBitmap=%p\n", + MmPagedPoolInfo.PagedPoolAllocationMap, MmPagedPoolInfo.EndOfPagedPoolBitmap); + + /* Initialize the bitmap */ + RtlInitializeBitMap(MmPagedPoolInfo.EndOfPagedPoolBitmap, + (PULONG)(MmPagedPoolInfo.EndOfPagedPoolBitmap + 1), + BitMapSize); + + /* No allocations, no allocation ends; clear all bits. */ + RtlClearAllBits(MmPagedPoolInfo.EndOfPagedPoolBitmap); + + /* Initialize the paged pool mutex */ + KeInitializeGuardedMutex(&MmPagedPoolMutex); + + /* Initialize the paged pool */ + InitializePool(PagedPool, 0); } @@ -642,20 +810,14 @@ /* Parse memory descriptors */ MiEvaluateMemoryDescriptors(LoaderBlock); - /* Configure the memory sizes */ - MiArmConfigureMemorySizes(LoaderBlock); - - /* Initialize the memory layout */ - MiArmInitializeMemoryLayout(LoaderBlock); - /* Prepare PFN database mappings */ - MiArmPreparePfnDatabse(LoaderBlock); + MiPreparePfnDatabse(LoaderBlock); + + /* Initialize the session space */ + MiInitializeSessionSpace(LoaderBlock); /* Initialize some mappings */ - MiArmInitializePageTable(); - - /* Initialize the ARM3 nonpaged pool */ - MiInitializeArmPool(); + MiInitializePageTable(); /* Update the memory descriptor, to make sure the pages we used won't get inserted into the PFN database */ @@ -672,20 +834,14 @@ /* The PFN database was created, restore the free descriptor */ *MxFreeDescriptor = MxOldFreeDescriptor; + /* Switch to phase 1 */ + MxPhase = 1; + /* Initialize the nonpaged pool */ - InitializePool(NonPagedPool, 0); - - /* Create the system PTE space */ - Pte = MiAddressToPte(MI_SYSTEM_PTE_START); - MiInitializeSystemPtes(Pte, MmNumberOfSystemPtes, SystemPteSpace); - - /* Reserve system PTEs for zeroing PTEs and clear them */ - MiFirstReservedZeroingPte = MiReserveSystemPtes(MI_ZERO_PTES, - SystemPteSpace); - RtlZeroMemory(MiFirstReservedZeroingPte, MI_ZERO_PTES * sizeof(MMPTE)); - - /* Set the counter to maximum */ - MiFirstReservedZeroingPte->u.Hard.PageFrameNumber = MI_ZERO_PTES - 1; + MiBuildNonPagedPool(); + + /* Initialize system PTE handling */ + MiBuildSystemPteSpace(); /* Build the physical memory block */ MiBuildPhysicalMemoryBlock(LoaderBlock);
15 years, 1 month
1
0
0
0
[tkreuzer] 44228: [MM] Don't assume 1024 PTEs per page, instead use PTE_PER_PAGE constant.
by tkreuzer@svn.reactos.org
Author: tkreuzer Date: Wed Nov 18 22:20:09 2009 New Revision: 44228 URL:
http://svn.reactos.org/svn/reactos?rev=44228&view=rev
Log: [MM] Don't assume 1024 PTEs per page, instead use PTE_PER_PAGE constant. Modified: branches/ros-amd64-bringup/reactos/ntoskrnl/include/internal/i386/mm.h branches/ros-amd64-bringup/reactos/ntoskrnl/mm/mminit.c Modified: branches/ros-amd64-bringup/reactos/ntoskrnl/include/internal/i386/mm.h URL:
http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/ntosk…
============================================================================== --- branches/ros-amd64-bringup/reactos/ntoskrnl/include/internal/i386/mm.h [iso-8859-1] (original) +++ branches/ros-amd64-bringup/reactos/ntoskrnl/include/internal/i386/mm.h [iso-8859-1] Wed Nov 18 22:20:09 2009 @@ -18,6 +18,7 @@ #define PTE_BASE 0xC0000000 #define PDE_BASE 0xC0300000 #define PTE_TOP 0xC03FFFFF +#define PTE_PER_PAGE 1024 #define HYPER_SPACE 0xC0400000 #define HYPER_SPACE_END 0xC07FFFFF Modified: branches/ros-amd64-bringup/reactos/ntoskrnl/mm/mminit.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/ntosk…
============================================================================== --- branches/ros-amd64-bringup/reactos/ntoskrnl/mm/mminit.c [iso-8859-1] (original) +++ branches/ros-amd64-bringup/reactos/ntoskrnl/mm/mminit.c [iso-8859-1] Wed Nov 18 22:20:09 2009 @@ -433,7 +433,7 @@ Test[i] = MiAllocatePoolPages(PagedPool, PAGE_SIZE); if (!Test[i]) { - ASSERT(i == 1024); + ASSERT(i == PTE_PER_PAGE); break; } }
15 years, 1 month
1
0
0
0
[pschweitzer] 44227: Fixed typo (lost patch found in the dust)
by pschweitzer@svn.reactos.org
Author: pschweitzer Date: Wed Nov 18 19:15:49 2009 New Revision: 44227 URL:
http://svn.reactos.org/svn/reactos?rev=44227&view=rev
Log: Fixed typo (lost patch found in the dust) Modified: trunk/reactos/drivers/filesystems/fastfat_new/fsctl.c Modified: trunk/reactos/drivers/filesystems/fastfat_new/fsctl.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfa…
============================================================================== --- trunk/reactos/drivers/filesystems/fastfat_new/fsctl.c [iso-8859-1] (original) +++ trunk/reactos/drivers/filesystems/fastfat_new/fsctl.c [iso-8859-1] Wed Nov 18 19:15:49 2009 @@ -99,7 +99,7 @@ /* Make sure this IRP is waitable */ ASSERT(IrpContext->Flags & IRPCONTEXT_CANWAIT); - /* Request media changes count, mostly usefull for removable devices */ + /* Request media changes count, mostly useful for removable devices */ Status = FatPerformDevIoCtrl(TargetDeviceObject, IOCTL_STORAGE_CHECK_VERIFY, NULL,
15 years, 1 month
1
0
0
0
← Newer
1
...
8
9
10
11
12
13
14
...
45
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
Results per page:
10
25
50
100
200