sync with trunk (r48253)

svn path=/branches/reactos-yarotows/; revision=48255
This commit is contained in:
Jérôme Gardou 2010-07-25 16:44:57 +00:00
parent fbcac4b275
commit 21a56a9d82
29 changed files with 295 additions and 193 deletions

View file

@ -359,6 +359,7 @@ CLEANUP:
VOID ShowInfo(BOOL bAll) VOID ShowInfo(BOOL bAll)
{ {
MIB_IFROW mibEntry;
PIP_ADAPTER_INFO pAdapterInfo = NULL; PIP_ADAPTER_INFO pAdapterInfo = NULL;
PIP_ADAPTER_INFO pAdapter = NULL; PIP_ADAPTER_INFO pAdapter = NULL;
ULONG adaptOutBufLen = 0; ULONG adaptOutBufLen = 0;
@ -441,6 +442,9 @@ VOID ShowInfo(BOOL bAll)
{ {
LPTSTR IntType, myConType; LPTSTR IntType, myConType;
mibEntry.dwIndex = pAdapter->Index;
GetIfEntry(&mibEntry);
IntType = GetInterfaceTypeName(pAdapter->Type); IntType = GetInterfaceTypeName(pAdapter->Type);
myConType = GetConnectionType(pAdapter->AdapterName); myConType = GetConnectionType(pAdapter->AdapterName);
@ -449,7 +453,7 @@ VOID ShowInfo(BOOL bAll)
if (myConType != NULL) HeapFree(ProcessHeap, 0, myConType); if (myConType != NULL) HeapFree(ProcessHeap, 0, myConType);
/* check if the adapter is connected to the media */ /* check if the adapter is connected to the media */
if (_tcscmp(pAdapter->IpAddressList.IpAddress.String, "0.0.0.0") == 0) if (mibEntry.dwOperStatus != MIB_IF_OPER_STATUS_CONNECTED && mibEntry.dwOperStatus != MIB_IF_OPER_STATUS_OPERATIONAL)
{ {
_tprintf(_T("\tMedia State . . . . . . . . . . . : Media disconnected\n")); _tprintf(_T("\tMedia State . . . . . . . . . . . : Media disconnected\n"));
pAdapter = pAdapter->Next; pAdapter = pAdapter->Next;

View file

@ -65,46 +65,6 @@ InfpFindFirstLineW(
return TRUE; return TRUE;
} }
BOOL WINAPI
InfpFindNextLine(
IN PINFCONTEXT ContextIn,
OUT PINFCONTEXT ContextOut)
{
return InfFindNextLine(ContextIn, ContextOut);
}
BOOL WINAPI
InfpGetBinaryField(
IN PINFCONTEXT Context,
IN ULONG FieldIndex,
IN OUT BYTE* ReturnBuffer,
IN ULONG ReturnBufferSize,
OUT PULONG RequiredSize)
{
return InfGetBinaryField(Context, FieldIndex, ReturnBuffer, ReturnBufferSize, RequiredSize);
}
DWORD WINAPI
InfpGetFieldCount(
IN PINFCONTEXT Context)
{
return (DWORD)InfGetFieldCount(Context);
}
BOOL WINAPI
InfpGetIntField(
IN PINFCONTEXT Context,
IN DWORD FieldIndex,
OUT PINT IntegerValue)
{
LONG IntegerValueL;
BOOL ret;
ret = InfGetIntField(Context, FieldIndex, &IntegerValueL);
*IntegerValue = (INT)IntegerValueL;
return ret;
}
BOOL WINAPI BOOL WINAPI
InfpGetMultiSzFieldW( InfpGetMultiSzFieldW(
IN PINFCONTEXT Context, IN PINFCONTEXT Context,

View file

@ -36,10 +36,10 @@
#define SetupCloseInfFile InfpCloseInfFile #define SetupCloseInfFile InfpCloseInfFile
#define SetupFindFirstLineW InfpFindFirstLineW #define SetupFindFirstLineW InfpFindFirstLineW
#define SetupFindNextLine InfpFindNextLine #define SetupFindNextLine InfFindNextLine
#define SetupGetBinaryField InfpGetBinaryField #define SetupGetBinaryField InfGetBinaryField
#define SetupGetFieldCount InfpGetFieldCount #define SetupGetFieldCount InfGetFieldCount
#define SetupGetIntField InfpGetIntField #define SetupGetIntField InfGetIntField
#define SetupGetMultiSzFieldW InfpGetMultiSzFieldW #define SetupGetMultiSzFieldW InfpGetMultiSzFieldW
#define SetupGetStringFieldW InfpGetStringFieldW #define SetupGetStringFieldW InfpGetStringFieldW
#define SetupOpenInfFileW InfpOpenInfFileW #define SetupOpenInfFileW InfpOpenInfFileW
@ -66,29 +66,6 @@ InfpFindFirstLineW(
IN PCWSTR Key, IN PCWSTR Key,
IN OUT PINFCONTEXT Context); IN OUT PINFCONTEXT Context);
BOOL WINAPI
InfpFindNextLine(
IN PINFCONTEXT ContextIn,
OUT PINFCONTEXT ContextOut);
BOOL WINAPI
InfpGetBinaryField(
IN PINFCONTEXT Context,
IN ULONG FieldIndex,
IN OUT BYTE* ReturnBuffer,
IN ULONG ReturnBufferSize,
OUT PULONG RequiredSize);
DWORD WINAPI
InfpGetFieldCount(
IN PINFCONTEXT Context);
BOOL WINAPI
InfpGetIntField(
IN PINFCONTEXT Context,
IN DWORD FieldIndex,
OUT PINT IntegerValue);
BOOL WINAPI BOOL WINAPI
InfpGetMultiSzFieldW( InfpGetMultiSzFieldW(
IN PINFCONTEXT Context, IN PINFCONTEXT Context,

View file

@ -50,6 +50,7 @@
/* Internal Headers */ /* Internal Headers */
#include "interface/consup.h" #include "interface/consup.h"
#include "partlist.h" #include "partlist.h"
#include "infros.h"
#include "inffile.h" #include "inffile.h"
#include "inicache.h" #include "inicache.h"
#include "progress.h" #include "progress.h"

View file

@ -240,7 +240,7 @@
#elif (_MSC_VER) #elif (_MSC_VER)
#define FORCEINLINE __inline #define FORCEINLINE __inline
#else #else
#define FORCEINLINE static __inline__ __attribute__((always_inline)) #define FORCEINLINE extern __inline__ __attribute__((always_inline))
#endif #endif
#endif #endif

View file

@ -79,7 +79,7 @@ extern "C" {
#elif (_MSC_VER) #elif (_MSC_VER)
#define FORCEINLINE __inline #define FORCEINLINE __inline
#else #else
#define FORCEINLINE static __inline__ __attribute__((always_inline)) #define FORCEINLINE extern __inline__ __attribute__((always_inline))
#endif #endif
#endif #endif
@ -5112,7 +5112,7 @@ static __inline__ PVOID GetCurrentFiber(void)
#endif #endif
#if defined(_M_IX86) #if defined(_M_IX86)
static __inline__ struct _TEB * NtCurrentTeb(void) extern __inline__ struct _TEB * NtCurrentTeb(void)
{ {
struct _TEB *ret; struct _TEB *ret;
@ -5137,12 +5137,12 @@ FORCEINLINE struct _TEB * NtCurrentTeb(VOID)
return (struct _TEB *)__readgsqword(FIELD_OFFSET(NT_TIB, Self)); return (struct _TEB *)__readgsqword(FIELD_OFFSET(NT_TIB, Self));
} }
#elif defined(_M_PPC) #elif defined(_M_PPC)
static __inline__ struct _TEB * NtCurrentTeb(void) extern __inline__ struct _TEB * NtCurrentTeb(void)
{ {
return __readfsdword_winnt(0x18); return __readfsdword_winnt(0x18);
} }
#else #else
static __inline__ struct _TEB * NtCurrentTeb(void) extern __inline__ struct _TEB * NtCurrentTeb(void)
{ {
return __readfsdword_winnt(0x18); return __readfsdword_winnt(0x18);
} }

View file

@ -236,7 +236,7 @@ WspiapiClone(
return 0; return 0;
} }
FORCEINLINE static __inline
void void
WINAPI WINAPI
WspiapiLegacyFreeAddrInfo( WspiapiLegacyFreeAddrInfo(
@ -252,7 +252,7 @@ WspiapiLegacyFreeAddrInfo(
} }
} }
FORCEINLINE static __inline
int int
WINAPI WINAPI
WspiapiLegacyGetAddrInfo( WspiapiLegacyGetAddrInfo(
@ -352,7 +352,7 @@ WspiapiLegacyGetAddrInfo(
return (iError); return (iError);
} }
FORCEINLINE static __inline
int int
WINAPI WINAPI
WspiapiLegacyGetNameInfo( WspiapiLegacyGetNameInfo(

View file

@ -11,3 +11,34 @@
we do tls cleanup in runtime and _CRT_MT has value 2. */ we do tls cleanup in runtime and _CRT_MT has value 2. */
int _CRT_MT = 2; int _CRT_MT = 2;
// HACK around broken imports from libmingwex, until RosBE64 is updated
#ifdef _M_AMD64
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
#include <stdlib.h>
int __mingwthr_key_dtor (DWORD key, void (*dtor)(void *));
int __mingwthr_remove_key_dtor (DWORD key);
extern int ___w64_mingwthr_remove_key_dtor (DWORD key);
extern int ___w64_mingwthr_add_key_dtor (DWORD key, void (*dtor)(void *));
int
__mingwthr_remove_key_dtor (DWORD key)
{
return ___w64_mingwthr_remove_key_dtor (key);
}
int
__mingwthr_key_dtor (DWORD key, void (*dtor)(void *))
{
if (dtor)
return ___w64_mingwthr_add_key_dtor (key, dtor);
return 0;
}
#endif

View file

@ -83,9 +83,14 @@ extern long timedelta;
#ifdef _MSC_VER #ifdef _MSC_VER
#define MAKE_SET(set, sym, type) #define MAKE_SET(set, sym, type)
#else #else
#if defined(_M_AMD64)
#define MAKE_SET(set, sym, type) \
asm(".stabs \"" #set "\", " #type ", 0, 0, " #sym)
#else
#define MAKE_SET(set, sym, type) \ #define MAKE_SET(set, sym, type) \
asm(".stabs \"_" #set "\", " #type ", 0, 0, _" #sym) asm(".stabs \"_" #set "\", " #type ", 0, 0, _" #sym)
#endif #endif
#endif
#define TEXT_SET(set, sym) MAKE_SET(set, sym, 23) #define TEXT_SET(set, sym) MAKE_SET(set, sym, 23)
#define DATA_SET(set, sym) MAKE_SET(set, sym, 25) #define DATA_SET(set, sym) MAKE_SET(set, sym, 25)
#define BSS_SET(set, sym) MAKE_SET(set, sym, 27) #define BSS_SET(set, sym) MAKE_SET(set, sym, 27)

View file

@ -271,7 +271,7 @@ InfpGetBinaryField(PINFCONTEXT Context,
INFSTATUS INFSTATUS
InfpGetIntField(PINFCONTEXT Context, InfpGetIntField(PINFCONTEXT Context,
ULONG FieldIndex, ULONG FieldIndex,
PLONG IntegerValue) INT* IntegerValue)
{ {
PINFCACHELINE CacheLine; PINFCACHELINE CacheLine;
PINFCACHEFIELD CacheField; PINFCACHEFIELD CacheField;

View file

@ -115,7 +115,7 @@ extern INFSTATUS InfpGetBinaryField(PINFCONTEXT Context,
PULONG RequiredSize); PULONG RequiredSize);
extern INFSTATUS InfpGetIntField(PINFCONTEXT Context, extern INFSTATUS InfpGetIntField(PINFCONTEXT Context,
ULONG FieldIndex, ULONG FieldIndex,
PLONG IntegerValue); INT* IntegerValue);
extern INFSTATUS InfpGetMultiSzField(PINFCONTEXT Context, extern INFSTATUS InfpGetMultiSzField(PINFCONTEXT Context,
ULONG FieldIndex, ULONG FieldIndex,
PTSTR ReturnBuffer, PTSTR ReturnBuffer,

View file

@ -48,7 +48,7 @@ extern BOOLEAN InfGetBinaryField(PINFCONTEXT Context,
PULONG RequiredSize); PULONG RequiredSize);
extern BOOLEAN InfGetIntField(PINFCONTEXT Context, extern BOOLEAN InfGetIntField(PINFCONTEXT Context,
ULONG FieldIndex, ULONG FieldIndex,
PLONG IntegerValue); PINT IntegerValue);
extern BOOLEAN InfGetMultiSzField(PINFCONTEXT Context, extern BOOLEAN InfGetMultiSzField(PINFCONTEXT Context,
ULONG FieldIndex, ULONG FieldIndex,
PWSTR ReturnBuffer, PWSTR ReturnBuffer,

View file

@ -84,7 +84,7 @@ InfGetBinaryField(PINFCONTEXT Context,
BOOLEAN BOOLEAN
InfGetIntField(PINFCONTEXT Context, InfGetIntField(PINFCONTEXT Context,
ULONG FieldIndex, ULONG FieldIndex,
PLONG IntegerValue) PINT IntegerValue)
{ {
return INF_SUCCESS(InfpGetIntField(Context, FieldIndex, IntegerValue)); return INF_SUCCESS(InfpGetIntField(Context, FieldIndex, IntegerValue));
} }

View file

@ -416,7 +416,7 @@ InfpGetBinaryField(PINFCONTEXT Context,
INFSTATUS INFSTATUS
InfpGetIntField(PINFCONTEXT Context, InfpGetIntField(PINFCONTEXT Context,
ULONG FieldIndex, ULONG FieldIndex,
PLONG IntegerValue) INT *IntegerValue)
{ {
PINFCACHELINE CacheLine; PINFCACHELINE CacheLine;
PINFCACHEFIELD CacheField; PINFCACHEFIELD CacheField;

View file

@ -49,7 +49,7 @@ extern int InfHostGetBinaryField(PINFCONTEXT Context,
ULONG *RequiredSize); ULONG *RequiredSize);
extern int InfHostGetIntField(PINFCONTEXT Context, extern int InfHostGetIntField(PINFCONTEXT Context,
ULONG FieldIndex, ULONG FieldIndex,
ULONG *IntegerValue); INT *IntegerValue);
extern int InfHostGetMultiSzField(PINFCONTEXT Context, extern int InfHostGetMultiSzField(PINFCONTEXT Context,
ULONG FieldIndex, ULONG FieldIndex,
WCHAR *ReturnBuffer, WCHAR *ReturnBuffer,

View file

@ -138,11 +138,11 @@ InfHostGetBinaryField(PINFCONTEXT Context,
int int
InfHostGetIntField(PINFCONTEXT Context, InfHostGetIntField(PINFCONTEXT Context,
ULONG FieldIndex, ULONG FieldIndex,
ULONG *IntegerValue) INT *IntegerValue)
{ {
INFSTATUS Status; INFSTATUS Status;
Status = InfpGetIntField(Context, FieldIndex, (PLONG)IntegerValue); Status = InfpGetIntField(Context, FieldIndex, IntegerValue);
if (INF_SUCCESS(Status)) if (INF_SUCCESS(Status))
{ {
return 0; return 0;

View file

@ -116,7 +116,7 @@ extern INFSTATUS InfpGetBinaryField(PINFCONTEXT Context,
PULONG RequiredSize); PULONG RequiredSize);
extern INFSTATUS InfpGetIntField(PINFCONTEXT Context, extern INFSTATUS InfpGetIntField(PINFCONTEXT Context,
ULONG FieldIndex, ULONG FieldIndex,
PLONG IntegerValue); INT *IntegerValue);
extern INFSTATUS InfpGetMultiSzField(PINFCONTEXT Context, extern INFSTATUS InfpGetMultiSzField(PINFCONTEXT Context,
ULONG FieldIndex, ULONG FieldIndex,
PWSTR ReturnBuffer, PWSTR ReturnBuffer,

View file

@ -50,7 +50,7 @@ extern BOOLEAN InfGetBinaryField(PINFCONTEXT Context,
PULONG RequiredSize); PULONG RequiredSize);
extern BOOLEAN InfGetIntField(PINFCONTEXT Context, extern BOOLEAN InfGetIntField(PINFCONTEXT Context,
ULONG FieldIndex, ULONG FieldIndex,
PLONG IntegerValue); INT *IntegerValue);
extern BOOLEAN InfGetMultiSzField(PINFCONTEXT Context, extern BOOLEAN InfGetMultiSzField(PINFCONTEXT Context,
ULONG FieldIndex, ULONG FieldIndex,
PWSTR ReturnBuffer, PWSTR ReturnBuffer,

View file

@ -84,7 +84,7 @@ InfGetBinaryField(PINFCONTEXT Context,
BOOLEAN BOOLEAN
InfGetIntField(PINFCONTEXT Context, InfGetIntField(PINFCONTEXT Context,
ULONG FieldIndex, ULONG FieldIndex,
PLONG IntegerValue) INT *IntegerValue)
{ {
return INF_SUCCESS(InfpGetIntField(Context, FieldIndex, IntegerValue)); return INF_SUCCESS(InfpGetIntField(Context, FieldIndex, IntegerValue));
} }

View file

@ -73,7 +73,7 @@ IntToChar2(int x)
return u.char2; return u.char2;
} }
FORCEINLINE static __inline
void void
FillBuf(timebuf_t *buf, const struct tm *ptm) FillBuf(timebuf_t *buf, const struct tm *ptm)
{ {

View file

@ -4,6 +4,8 @@
#pragma once #pragma once
#define _MI_PAGING_LEVELS 4
/* Helper macros */ /* Helper macros */
#define PAGE_MASK(x) ((x)&(~0xfff)) #define PAGE_MASK(x) ((x)&(~0xfff))
#define PAE_PAGE_MASK(x) ((x)&(~0xfffLL)) #define PAE_PAGE_MASK(x) ((x)&(~0xfffLL))
@ -106,12 +108,17 @@ ULONG
FORCEINLINE FORCEINLINE
MiAddressToPti(PVOID Address) MiAddressToPti(PVOID Address)
{ {
ULONG64 Pti = (ULONG64)Address >> PTI_SHIFT; return ((((ULONG64)Address) >> PTI_SHIFT) & 0x1FF);
Pti &= PTI_MASK_AMD64; }
return Pti; #define MiAddressToPteOffset(x) MiAddressToPti(x) // FIXME: bad name
ULONG
FORCEINLINE
MiAddressToPxi(PVOID Address)
{
return ((((ULONG64)Address) >> PXI_SHIFT) & 0x1FF);
} }
#define MiAddressToPteOffset(x) MiAddressToPti(x)
/* Convert a PTE into a corresponding address */ /* Convert a PTE into a corresponding address */
PVOID PVOID

View file

@ -7,6 +7,12 @@
struct _EPROCESS; struct _EPROCESS;
PULONG MmGetPageDirectory(VOID); PULONG MmGetPageDirectory(VOID);
#ifdef _PAE_
#define _MI_PAGING_LEVELS 3
#else
#define _MI_PAGING_LEVELS 2
#endif
#define PAGE_MASK(x) ((x)&(~0xfff)) #define PAGE_MASK(x) ((x)&(~0xfff))
#define PAE_PAGE_MASK(x) ((x)&(~0xfffLL)) #define PAE_PAGE_MASK(x) ((x)&(~0xfffLL))

View file

@ -95,7 +95,7 @@
// //
// Allocates a new message // Allocates a new message
// //
FORCEINLINE static __inline
PLPCP_MESSAGE PLPCP_MESSAGE
LpcpAllocateFromPortZone(VOID) LpcpAllocateFromPortZone(VOID)
{ {

View file

@ -34,7 +34,8 @@ NTAPI
MiInitializeLargePageSupport(VOID) MiInitializeLargePageSupport(VOID)
{ {
#if _MI_PAGING_LEVELS > 2 #if _MI_PAGING_LEVELS > 2
#error "PAE/x64 Not Implemented" DPRINT1("PAE/x64 Not Implemented\n");
ASSERT(FALSE);
#else #else
/* Initialize the large-page hyperspace PTE used for initial mapping */ /* Initialize the large-page hyperspace PTE used for initial mapping */
MiLargePageHyperPte = MiReserveSystemPtes(1, SystemPteSpace); MiLargePageHyperPte = MiReserveSystemPtes(1, SystemPteSpace);

View file

@ -139,56 +139,9 @@
#else #else
#error Define these please! #error Define these please!
#endif #endif
static const
ULONG extern const ULONG MmProtectToPteMask[32];
MmProtectToPteMask[32] =
{
//
// These are the base MM_ protection flags
//
0,
PTE_READONLY | PTE_ENABLE_CACHE,
PTE_EXECUTE | PTE_ENABLE_CACHE,
PTE_EXECUTE_READ | PTE_ENABLE_CACHE,
PTE_READWRITE | PTE_ENABLE_CACHE,
PTE_WRITECOPY | PTE_ENABLE_CACHE,
PTE_EXECUTE_READWRITE | PTE_ENABLE_CACHE,
PTE_EXECUTE_WRITECOPY | PTE_ENABLE_CACHE,
//
// These OR in the MM_NOCACHE flag
//
0,
PTE_READONLY | PTE_DISABLE_CACHE,
PTE_EXECUTE | PTE_DISABLE_CACHE,
PTE_EXECUTE_READ | PTE_DISABLE_CACHE,
PTE_READWRITE | PTE_DISABLE_CACHE,
PTE_WRITECOPY | PTE_DISABLE_CACHE,
PTE_EXECUTE_READWRITE | PTE_DISABLE_CACHE,
PTE_EXECUTE_WRITECOPY | PTE_DISABLE_CACHE,
//
// These OR in the MM_DECOMMIT flag, which doesn't seem supported on x86/64/ARM
//
0,
PTE_READONLY | PTE_ENABLE_CACHE,
PTE_EXECUTE | PTE_ENABLE_CACHE,
PTE_EXECUTE_READ | PTE_ENABLE_CACHE,
PTE_READWRITE | PTE_ENABLE_CACHE,
PTE_WRITECOPY | PTE_ENABLE_CACHE,
PTE_EXECUTE_READWRITE | PTE_ENABLE_CACHE,
PTE_EXECUTE_WRITECOPY | PTE_ENABLE_CACHE,
//
// These OR in the MM_NOACCESS flag, which seems to enable WriteCombining?
//
0,
PTE_READONLY | PTE_WRITECOMBINED_CACHE,
PTE_EXECUTE | PTE_WRITECOMBINED_CACHE,
PTE_EXECUTE_READ | PTE_WRITECOMBINED_CACHE,
PTE_READWRITE | PTE_WRITECOMBINED_CACHE,
PTE_WRITECOPY | PTE_WRITECOMBINED_CACHE,
PTE_EXECUTE_READWRITE | PTE_WRITECOMBINED_CACHE,
PTE_EXECUTE_WRITECOPY | PTE_WRITECOMBINED_CACHE,
};
// //
// Assertions for session images, addresses, and PTEs // Assertions for session images, addresses, and PTEs
// //

View file

@ -64,22 +64,26 @@ BOOLEAN
NTAPI NTAPI
MmIsAddressValid(IN PVOID VirtualAddress) MmIsAddressValid(IN PVOID VirtualAddress)
{ {
// #if _MI_PAGING_LEVELS >= 4
// Just check the Valid bit in the Address' PDE and PTE /* Check if the PXE is valid */
// if (MiAddressToPxe(VirtualAddress)->u.Hard.Valid == 0) return FALSE;
if ((MiAddressToPde(VirtualAddress)->u.Hard.Valid == 0) || #endif
(MiAddressToPte(VirtualAddress)->u.Hard.Valid == 0))
{
//
// Attempting to access this page is guranteed to result in a page fault
//
return FALSE;
}
// #if _MI_PAGING_LEVELS >= 3
// This address is valid now, but it will only stay so if the caller holds /* Check if the PPE is valid */
// the PFN lock if (MiAddressToPpe(VirtualAddress)->u.Hard.Valid == 0) return FALSE;
// #endif
#if _MI_PAGING_LEVELS >= 2
/* Check if the PDE is valid */
if (MiAddressToPde(VirtualAddress)->u.Hard.Valid == 0) return FALSE;
#endif
/* Check if the PTE is valid */
if (MiAddressToPte(VirtualAddress)->u.Hard.Valid == 0) return FALSE;
/* This address is valid now, but it will only stay so if the caller holds
* the PFN lock */
return TRUE; return TRUE;
} }

View file

@ -1040,6 +1040,7 @@ MmInitializeHandBuiltProcess2(IN PEPROCESS Process)
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
#ifdef _M_IX86
/* FIXME: Evaluate ways to make this portable yet arch-specific */ /* FIXME: Evaluate ways to make this portable yet arch-specific */
BOOLEAN BOOLEAN
NTAPI NTAPI
@ -1131,6 +1132,7 @@ MmCreateProcessAddressSpace(IN ULONG MinWs,
MiReleaseSystemPtes(PointerPte, 1, SystemPteSpace); MiReleaseSystemPtes(PointerPte, 1, SystemPteSpace);
return TRUE; return TRUE;
} }
#endif
VOID VOID
NTAPI NTAPI

View file

@ -5,6 +5,7 @@
* PURPOSE: Low level memory managment manipulation * PURPOSE: Low level memory managment manipulation
* *
* PROGRAMMER: Timo Kreuzer (timo.kreuzer@reactos.org) * PROGRAMMER: Timo Kreuzer (timo.kreuzer@reactos.org)
* ReactOS Portable Systems Group
*/ */
/* INCLUDES ***************************************************************/ /* INCLUDES ***************************************************************/
@ -12,6 +13,7 @@
#include <ntoskrnl.h> #include <ntoskrnl.h>
#define NDEBUG #define NDEBUG
#include <debug.h> #include <debug.h>
#include "../ARM3/miarm.h"
#undef InterlockedExchangePte #undef InterlockedExchangePte
#define InterlockedExchangePte(pte1, pte2) \ #define InterlockedExchangePte(pte1, pte2) \
@ -25,6 +27,55 @@ extern MMPTE HyperTemplatePte;
/* GLOBALS *****************************************************************/ /* GLOBALS *****************************************************************/
const
ULONG
MmProtectToPteMask[32] =
{
//
// These are the base MM_ protection flags
//
0,
PTE_READONLY | PTE_ENABLE_CACHE,
PTE_EXECUTE | PTE_ENABLE_CACHE,
PTE_EXECUTE_READ | PTE_ENABLE_CACHE,
PTE_READWRITE | PTE_ENABLE_CACHE,
PTE_WRITECOPY | PTE_ENABLE_CACHE,
PTE_EXECUTE_READWRITE | PTE_ENABLE_CACHE,
PTE_EXECUTE_WRITECOPY | PTE_ENABLE_CACHE,
//
// These OR in the MM_NOCACHE flag
//
0,
PTE_READONLY | PTE_DISABLE_CACHE,
PTE_EXECUTE | PTE_DISABLE_CACHE,
PTE_EXECUTE_READ | PTE_DISABLE_CACHE,
PTE_READWRITE | PTE_DISABLE_CACHE,
PTE_WRITECOPY | PTE_DISABLE_CACHE,
PTE_EXECUTE_READWRITE | PTE_DISABLE_CACHE,
PTE_EXECUTE_WRITECOPY | PTE_DISABLE_CACHE,
//
// These OR in the MM_DECOMMIT flag, which doesn't seem supported on x86/64/ARM
//
0,
PTE_READONLY | PTE_ENABLE_CACHE,
PTE_EXECUTE | PTE_ENABLE_CACHE,
PTE_EXECUTE_READ | PTE_ENABLE_CACHE,
PTE_READWRITE | PTE_ENABLE_CACHE,
PTE_WRITECOPY | PTE_ENABLE_CACHE,
PTE_EXECUTE_READWRITE | PTE_ENABLE_CACHE,
PTE_EXECUTE_WRITECOPY | PTE_ENABLE_CACHE,
//
// These OR in the MM_NOACCESS flag, which seems to enable WriteCombining?
//
0,
PTE_READONLY | PTE_WRITECOMBINED_CACHE,
PTE_EXECUTE | PTE_WRITECOMBINED_CACHE,
PTE_EXECUTE_READ | PTE_WRITECOMBINED_CACHE,
PTE_READWRITE | PTE_WRITECOMBINED_CACHE,
PTE_WRITECOPY | PTE_WRITECOMBINED_CACHE,
PTE_EXECUTE_READWRITE | PTE_WRITECOMBINED_CACHE,
PTE_EXECUTE_WRITECOPY | PTE_WRITECOMBINED_CACHE,
};
/* PRIVATE FUNCTIONS *******************************************************/ /* PRIVATE FUNCTIONS *******************************************************/
@ -489,46 +540,95 @@ MmCreateVirtualMapping(PEPROCESS Process,
return MmCreateVirtualMappingUnsafe(Process, Address, Protect, Pages, PageCount); return MmCreateVirtualMappingUnsafe(Process, Address, Protect, Pages, PageCount);
} }
NTSTATUS
NTAPI
MmInitializeHandBuiltProcess(IN PEPROCESS Process,
IN PULONG_PTR DirectoryTableBase)
{
/* Share the directory base with the idle process */
DirectoryTableBase[0] = PsGetCurrentProcess()->Pcb.DirectoryTableBase[0];
DirectoryTableBase[1] = PsGetCurrentProcess()->Pcb.DirectoryTableBase[1];
/* Initialize the Addresss Space */
KeInitializeGuardedMutex(&Process->AddressCreationLock);
Process->Vm.WorkingSetExpansionLinks.Flink = NULL;
ASSERT(Process->VadRoot.NumberGenericTableElements == 0);
Process->VadRoot.BalancedRoot.u1.Parent = &Process->VadRoot.BalancedRoot;
/* The process now has an address space */
Process->HasAddressSpace = TRUE;
return STATUS_SUCCESS;
}
BOOLEAN BOOLEAN
NTAPI NTAPI
MmCreateProcessAddressSpace(IN ULONG MinWs, MmCreateProcessAddressSpace(IN ULONG MinWs,
IN PEPROCESS Process, IN PEPROCESS Process,
IN PULONG_PTR DirectoryTableBase) OUT PULONG_PTR DirectoryTableBase)
{ {
UNIMPLEMENTED; KIRQL OldIrql;
return 0; PFN_NUMBER TableBasePfn, HyperPfn;
} PMMPTE PointerPte;
MMPTE TempPte, PdePte;
ULONG TableIndex;
PMMPTE SystemTable;
BOOLEAN /* No page colors yet */
NTAPI Process->NextPageColor = 0;
_MmIsAddressValid(IN PVOID VirtualAddress)
{ /* Setup the hyperspace lock */
/* Check all four page table levels */ KeInitializeSpinLock(&Process->HyperSpaceLock);
return (MiAddressToPxe(VirtualAddress)->u.Hard.Valid != 0 &&
MiAddressToPpe(VirtualAddress)->u.Hard.Valid != 0 &&
MiAddressToPde(VirtualAddress)->u.Hard.Valid != 0 &&
MiAddressToPte(VirtualAddress)->u.Hard.Valid != 0);
}
/* Lock PFN database */
OldIrql = KeAcquireQueuedSpinLock(LockQueuePfnLock);
/* Get a page for the table base and for hyperspace */
TableBasePfn = MiRemoveAnyPage(0);
HyperPfn = MiRemoveAnyPage(0);
/* Release PFN lock */
KeReleaseQueuedSpinLock(LockQueuePfnLock, OldIrql);
/* Zero both pages */
MiZeroPhysicalPage(TableBasePfn);
MiZeroPhysicalPage(HyperPfn);
/* Set the base directory pointers */
DirectoryTableBase[0] = TableBasePfn << PAGE_SHIFT;
DirectoryTableBase[1] = HyperPfn << PAGE_SHIFT;
/* Make sure we don't already have a page directory setup */
ASSERT(Process->Pcb.DirectoryTableBase[0] == 0);
/* Insert us into the Mm process list */
InsertTailList(&MmProcessList, &Process->MmProcessLinks);
/* Get a PTE to map the page directory */
PointerPte = MiReserveSystemPtes(1, SystemPteSpace);
ASSERT(PointerPte != NULL);
/* Build it */
MI_MAKE_HARDWARE_PTE_KERNEL(&PdePte,
PointerPte,
MM_READWRITE,
TableBasePfn);
/* Set it dirty and map it */
PdePte.u.Hard.Dirty = TRUE;
MI_WRITE_VALID_PTE(PointerPte, PdePte);
/* Now get the page directory (which we'll double map, so call it a page table */
SystemTable = MiPteToAddress(PointerPte);
/* Copy all the kernel mappings */
TableIndex = MiAddressToPxi(MmSystemRangeStart);
RtlCopyMemory(&SystemTable[TableIndex],
MiAddressToPxe(MmSystemRangeStart),
PAGE_SIZE - TableIndex * sizeof(MMPTE));
/* Now write the PTE/PDE entry for hyperspace itself */
TempPte = ValidKernelPte;
TempPte.u.Hard.PageFrameNumber = HyperPfn;
TableIndex = MiAddressToPxi(HYPER_SPACE);
SystemTable[TableIndex] = TempPte;
/* Sanity check */
ASSERT(MiAddressToPxi(MmHyperSpaceEnd) > TableIndex);
/* Now do the x86 trick of making the PDE a page table itself */
TableIndex = MiAddressToPxi(PTE_BASE);
TempPte.u.Hard.PageFrameNumber = TableBasePfn;
SystemTable[TableIndex] = TempPte;
/* Let go of the system PTE */
MiReleaseSystemPtes(PointerPte, 1, SystemPteSpace);
/* Switch to phase 1 initialization */
ASSERT(Process->AddressSpaceInitialized == 0);
Process->AddressSpaceInitialized = 1;
return TRUE;
}
/* EOF */ /* EOF */

View file

@ -12,6 +12,7 @@
#include <ntoskrnl.h> #include <ntoskrnl.h>
#define NDEBUG #define NDEBUG
#include <debug.h> #include <debug.h>
#include "../ARM3/miarm.h"
#if defined (ALLOC_PRAGMA) #if defined (ALLOC_PRAGMA)
#pragma alloc_text(INIT, MmInitGlobalKernelPageDirectory) #pragma alloc_text(INIT, MmInitGlobalKernelPageDirectory)
@ -58,6 +59,56 @@ __inline LARGE_INTEGER PTE_TO_PAGE(ULONG npage)
} }
#endif #endif
const
ULONG
MmProtectToPteMask[32] =
{
//
// These are the base MM_ protection flags
//
0,
PTE_READONLY | PTE_ENABLE_CACHE,
PTE_EXECUTE | PTE_ENABLE_CACHE,
PTE_EXECUTE_READ | PTE_ENABLE_CACHE,
PTE_READWRITE | PTE_ENABLE_CACHE,
PTE_WRITECOPY | PTE_ENABLE_CACHE,
PTE_EXECUTE_READWRITE | PTE_ENABLE_CACHE,
PTE_EXECUTE_WRITECOPY | PTE_ENABLE_CACHE,
//
// These OR in the MM_NOCACHE flag
//
0,
PTE_READONLY | PTE_DISABLE_CACHE,
PTE_EXECUTE | PTE_DISABLE_CACHE,
PTE_EXECUTE_READ | PTE_DISABLE_CACHE,
PTE_READWRITE | PTE_DISABLE_CACHE,
PTE_WRITECOPY | PTE_DISABLE_CACHE,
PTE_EXECUTE_READWRITE | PTE_DISABLE_CACHE,
PTE_EXECUTE_WRITECOPY | PTE_DISABLE_CACHE,
//
// These OR in the MM_DECOMMIT flag, which doesn't seem supported on x86/64/ARM
//
0,
PTE_READONLY | PTE_ENABLE_CACHE,
PTE_EXECUTE | PTE_ENABLE_CACHE,
PTE_EXECUTE_READ | PTE_ENABLE_CACHE,
PTE_READWRITE | PTE_ENABLE_CACHE,
PTE_WRITECOPY | PTE_ENABLE_CACHE,
PTE_EXECUTE_READWRITE | PTE_ENABLE_CACHE,
PTE_EXECUTE_WRITECOPY | PTE_ENABLE_CACHE,
//
// These OR in the MM_NOACCESS flag, which seems to enable WriteCombining?
//
0,
PTE_READONLY | PTE_WRITECOMBINED_CACHE,
PTE_EXECUTE | PTE_WRITECOMBINED_CACHE,
PTE_EXECUTE_READ | PTE_WRITECOMBINED_CACHE,
PTE_READWRITE | PTE_WRITECOMBINED_CACHE,
PTE_WRITECOPY | PTE_WRITECOMBINED_CACHE,
PTE_EXECUTE_READWRITE | PTE_WRITECOMBINED_CACHE,
PTE_EXECUTE_WRITECOPY | PTE_WRITECOMBINED_CACHE,
};
/* FUNCTIONS ***************************************************************/ /* FUNCTIONS ***************************************************************/
BOOLEAN MmUnmapPageTable(PULONG Pt); BOOLEAN MmUnmapPageTable(PULONG Pt);