#include <string.h>
#include <windows.h>
-ULONG x[(4 * 1024 * 1024) / 4096];
+#define SIZE (128*1024*1024)
+
+ULONG x[SIZE / 4096];
int main()
{
PUCHAR BaseAddress;
BaseAddress = VirtualAlloc(NULL,
- 4 * 1024 * 1024,
+ SIZE,
MEM_COMMIT,
PAGE_READONLY);
if (BaseAddress == NULL)
return(1);
}
printf("BaseAddress %p\n", BaseAddress);
- for (i = 0; i < ((4 * 1024 * 1024) / 4096); i++)
+ for (i = 0; i < (SIZE / 4096); i++)
{
- printf("%.6x, ", i*4096);
+ printf("%.8x ", i*4096);
x[i] = BaseAddress[i*4096];
}
-/* $Id: create.c,v 1.34 2001/11/02 22:44:34 hbirr Exp $
+/* $Id: create.c,v 1.35 2002/01/08 00:49:01 dwelch Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
PVFATCCB pCcb;
PVFATFCB pFcb;
PWCHAR c;
+ BOOLEAN PagingFileCreate = FALSE;
Stack = IoGetCurrentIrpStackLocation (Irp);
assert (Stack);
RequestedDisposition = ((Stack->Parameters.Create.Options >> 24) & 0xff);
RequestedOptions =
Stack->Parameters.Create.Options & FILE_VALID_OPTION_FLAGS;
+ PagingFileCreate = (Stack->Flags & SL_OPEN_PAGING_FILE) ? TRUE : FALSE;
if ((RequestedOptions & FILE_DIRECTORY_FILE)
&& RequestedDisposition == FILE_SUPERSEDE)
return STATUS_INVALID_PARAMETER;
}
}
+ /*
+ * If this create was for a paging file then make sure all the
+ * information needed to manipulate it is locked in memory.
+ */
+ if (PagingFileCreate)
+ {
+ ULONG CurrentCluster, NextCluster, i;
+
+ pFcb->Flags |= FCB_IS_PAGE_FILE;
+ pFcb->FatChainSize =
+ ((pFcb->entry.FileSize / DeviceExt->BytesPerCluster) + 2);
+ pFcb->FatChain = ExAllocatePool(NonPagedPool,
+ pFcb->FatChainSize * sizeof(ULONG));
+
+ if (DeviceExt->FatType == FAT32)
+ {
+ CurrentCluster = pFcb->entry.FirstCluster +
+ pFcb->entry.FirstClusterHigh * 65536;
+ }
+ else
+ {
+ CurrentCluster = pFcb->entry.FirstCluster;
+ }
+
+ i = 0;
+ while (CurrentCluster != 0xffffffff)
+ {
+ Status = GetNextCluster (DeviceExt, CurrentCluster, &NextCluster,
+ FALSE);
+ pFcb->FatChain[i] = NextCluster;
+ i++;
+ CurrentCluster = NextCluster;
+ }
+ pFcb->FatChain[i] = 0xFFFFFFFF;
+ }
+
/*
* Check the file has the requested attributes
*/
-/* $Id: dirwr.c,v 1.22 2001/10/10 22:15:51 hbirr Exp $
+/* $Id: dirwr.c,v 1.23 2002/01/08 00:49:01 dwelch Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
if (RequestedOptions & FILE_DIRECTORY_FILE)
{
CurrentCluster = 0xffffffff;
- status = NextCluster (DeviceExt, 0, &CurrentCluster, TRUE);
+ status = NextCluster (DeviceExt, NULL, 0, &CurrentCluster, TRUE);
if (CurrentCluster == 0xffffffff || !NT_SUCCESS(status))
{
vfatReleaseFCB(DeviceExt, pDirFcb);
-/* $Id: fcb.c,v 1.11 2001/11/02 22:40:50 hbirr Exp $
+/* $Id: fcb.c,v 1.12 2002/01/08 00:49:01 dwelch Exp $
*
*
* FILE: fcb.c
while (CurrentCluster != 0xffffffff && NT_SUCCESS(Status))
{
Size += pVCB->BytesPerCluster;
- Status = NextCluster (pVCB, FirstCluster, &CurrentCluster, FALSE);
+ Status = NextCluster (pVCB, NULL, FirstCluster, &CurrentCluster, FALSE);
}
}
else
while (CurrentCluster != 0xffffffff)
{
Size += vcb->BytesPerCluster;
- Status = NextCluster (vcb, FirstCluster, &CurrentCluster, FALSE);
+ Status = NextCluster (vcb, NULL, FirstCluster, &CurrentCluster, FALSE);
}
}
}
-# $Id: makefile,v 1.36 2001/11/02 22:47:36 hbirr Exp $
+# $Id: makefile,v 1.37 2002/01/08 00:49:01 dwelch Exp $
PATH_TO_TOP = ../../..
DEP_OBJECTS = $(TARGET_OBJECTS)
+TARGET_CFLAGS = -g
+
include $(PATH_TO_TOP)/rules.mak
include $(TOOLS_PATH)/helper.mk
-/* $Id: rw.c,v 1.34 2001/11/02 22:47:36 hbirr Exp $
+/* $Id: rw.c,v 1.35 2002/01/08 00:49:01 dwelch Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
NTSTATUS
NextCluster(PDEVICE_EXTENSION DeviceExt,
+ PVFATFCB Fcb,
ULONG FirstCluster,
PULONG CurrentCluster,
BOOLEAN Extend)
* necessary
*/
{
- if (FirstCluster == 1)
- {
- (*CurrentCluster) += DeviceExt->Boot->SectorsPerCluster;
+ if (Fcb != NULL && Fcb->Flags & FCB_IS_PAGE_FILE)
+ {
+ ULONG NextCluster;
+ NextCluster = Fcb->FatChain[(*CurrentCluster)];
+ (*CurrentCluster) = NextCluster;
return(STATUS_SUCCESS);
}
- else
- /* CN: FIXME: Real bug here or in dirwr, where CurrentCluster isn't initialized when 0*/
- if (FirstCluster == 0)
+ if (FirstCluster == 1)
{
- NTSTATUS Status;
-
- Status = GetNextCluster(DeviceExt, 0, CurrentCluster,
- Extend);
- return(Status);
+ (*CurrentCluster) += DeviceExt->Boot->SectorsPerCluster;
+ return(STATUS_SUCCESS);
}
else
{
- NTSTATUS Status;
-
- Status = GetNextCluster(DeviceExt, (*CurrentCluster), CurrentCluster,
- Extend);
- return(Status);
+ /*
+ * CN: FIXME: Real bug here or in dirwr, where CurrentCluster isn't
+ * initialized when 0
+ */
+ if (FirstCluster == 0)
+ {
+ NTSTATUS Status;
+
+ Status = GetNextCluster(DeviceExt, 0, CurrentCluster,
+ Extend);
+ return(Status);
+ }
+ else
+ {
+ NTSTATUS Status;
+
+ Status = GetNextCluster(DeviceExt, (*CurrentCluster), CurrentCluster,
+ Extend);
+ return(Status);
+ }
}
}
NTSTATUS
OffsetToCluster(PDEVICE_EXTENSION DeviceExt,
+ PVFATFCB Fcb,
ULONG FirstCluster,
ULONG FileOffset,
PULONG Cluster,
ULONG i;
NTSTATUS Status;
+ if (Fcb != NULL && Fcb->Flags & FCB_IS_PAGE_FILE)
+ {
+ ULONG NCluster;
+ ULONG Offset = FileOffset / DeviceExt->BytesPerCluster;
+ if (Offset == 0)
+ {
+ (*Cluster) = FirstCluster;
+ }
+ else
+ {
+ (*Cluster) = Fcb->FatChain[Offset - 1];
+ }
+ return(STATUS_SUCCESS);
+ }
if (FirstCluster == 1)
{
/* root of FAT16 or FAT12 */
NTSTATUS
VfatReadCluster(PDEVICE_EXTENSION DeviceExt,
+ PVFATFCB Fcb,
ULONG FirstCluster,
PULONG CurrentCluster,
PVOID Destination,
{
return(Status);
}
- Status = NextCluster(DeviceExt, FirstCluster, CurrentCluster, FALSE);
+ Status = NextCluster(DeviceExt, Fcb, FirstCluster, CurrentCluster, FALSE);
return(Status);
}
CurrentCluster = Ccb->LastCluster;
}
Status = OffsetToCluster(DeviceExt,
+ Fcb,
FirstCluster,
ROUND_DOWN(ReadOffset, DeviceExt->BytesPerCluster),
&CurrentCluster,
TempLength = min (Length, DeviceExt->BytesPerCluster - (ReadOffset % DeviceExt->BytesPerCluster));
Ccb->LastCluster = CurrentCluster;
Ccb->LastOffset = ROUND_DOWN(ReadOffset, DeviceExt->BytesPerCluster);
- Status = VfatReadCluster(DeviceExt, FirstCluster, &CurrentCluster, Buffer,
- ReadOffset % DeviceExt->BytesPerCluster, TempLength);
+ Status = VfatReadCluster(DeviceExt, Fcb, FirstCluster, &CurrentCluster,
+ Buffer, ReadOffset % DeviceExt->BytesPerCluster,
+ TempLength);
if (NT_SUCCESS(Status))
{
(*LengthRead) = (*LengthRead) + TempLength;
do
{
ClusterCount++;
- Status = NextCluster(DeviceExt, FirstCluster, &CurrentCluster, FALSE);
+ Status = NextCluster(DeviceExt, Fcb, FirstCluster, &CurrentCluster, FALSE);
}
while (StartCluster + ClusterCount == CurrentCluster && NT_SUCCESS(Status) &&
Length - ClusterCount * DeviceExt->BytesPerCluster >= DeviceExt->BytesPerCluster);
Ccb->LastCluster = CurrentCluster;
Ccb->LastOffset = ReadOffset + DeviceExt->BytesPerCluster;
- Status = VfatReadCluster(DeviceExt, FirstCluster, &CurrentCluster,
+ Status = VfatReadCluster(DeviceExt, Fcb, FirstCluster, &CurrentCluster,
Buffer, 0, Length);
if (NT_SUCCESS(Status))
{
NTSTATUS
VfatWriteCluster(PDEVICE_EXTENSION DeviceExt,
+ PVFATFCB Fcb,
ULONG StartOffset,
ULONG FirstCluster,
PULONG CurrentCluster,
{
return Status;
}
- Status = NextCluster(DeviceExt, FirstCluster, CurrentCluster, FALSE);
+ Status = NextCluster(DeviceExt, Fcb, FirstCluster, CurrentCluster, FALSE);
return(Status);
}
CurrentCluster = pCcb->LastCluster;
}
Status = OffsetToCluster(DeviceExt,
+ Fcb,
FirstCluster,
ROUND_DOWN(WriteOffset, DeviceExt->BytesPerCluster),
&CurrentCluster,
{
TempLength = min (Length, DeviceExt->BytesPerCluster - (WriteOffset % DeviceExt->BytesPerCluster));
Status = VfatWriteCluster(DeviceExt,
+ Fcb,
ROUND_DOWN(WriteOffset, DeviceExt->BytesPerCluster),
FirstCluster,
&CurrentCluster,
do
{
Count++;
- Status = NextCluster(DeviceExt, FirstCluster, &CurrentCluster, FALSE);
+ Status = NextCluster(DeviceExt, Fcb, FirstCluster, &CurrentCluster, FALSE);
}
while (StartCluster + Count == CurrentCluster && NT_SUCCESS(Status) &&
Length - Count * DeviceExt->BytesPerCluster >= DeviceExt->BytesPerCluster);
if (Length > 0 && CurrentCluster != 0xffffffff && NT_SUCCESS(Status))
{
Status = VfatWriteCluster(DeviceExt,
+ Fcb,
WriteOffset,
FirstCluster,
&CurrentCluster,
if (FirstCluster == 0)
{
// file of size zero
- Status = NextCluster (pDeviceExt, FirstCluster, &CurrentCluster, TRUE);
+ Status = NextCluster (pDeviceExt, pFcb, FirstCluster, &CurrentCluster, TRUE);
if (!NT_SUCCESS(Status))
{
DPRINT1("NextCluster failed, Status %x\n", Status);
}
else
{
- Status = OffsetToCluster(pDeviceExt, FirstCluster,
+ Status = OffsetToCluster(pDeviceExt, pFcb, FirstCluster,
pFcb->RFCB.AllocationSize.QuadPart - pDeviceExt->BytesPerCluster,
&CurrentCluster, FALSE);
if (!NT_SUCCESS(Status))
}
// CurrentCluster zeigt jetzt auf den letzten Cluster in der Kette
NewCluster = CurrentCluster;
- Status = NextCluster(pDeviceExt, FirstCluster, &NewCluster, FALSE);
+ Status = NextCluster(pDeviceExt, pFcb, FirstCluster, &NewCluster, FALSE);
if (NewCluster != 0xffffffff)
{
DPRINT1("Difference between size from direntry and the FAT.\n");
}
}
- Status = OffsetToCluster(pDeviceExt, FirstCluster,
+ Status = OffsetToCluster(pDeviceExt, pFcb, FirstCluster,
ROUND_DOWN(NewSize-1, pDeviceExt->BytesPerCluster),
&NewCluster, TRUE);
if (!NT_SUCCESS(Status) || NewCluster == 0xffffffff)
{
NewCluster = CurrentCluster;
// FIXME: check status
- NextCluster(pDeviceExt, FirstCluster, &NewCluster, FALSE);
+ NextCluster(pDeviceExt, pFcb, FirstCluster, &NewCluster, FALSE);
WriteCluster(pDeviceExt, CurrentCluster, 0xffffffff);
}
// free the allocated space
{
CurrentCluster = NewCluster;
// FIXME: check status
- NextCluster (pDeviceExt, FirstCluster, &NewCluster, FALSE);
+ NextCluster (pDeviceExt, pFcb, FirstCluster, &NewCluster, FALSE);
WriteCluster (pDeviceExt, CurrentCluster, 0);
}
return STATUS_DISK_FULL;
-/* $Id: vfat.h,v 1.37 2001/11/02 22:57:14 hbirr Exp $ */
+/* $Id: vfat.h,v 1.38 2002/01/08 00:49:01 dwelch Exp $ */
#include <ddk/ntifs.h>
ULONG dirIndex;
ERESOURCE PagingIoResource;
ERESOURCE MainResource;
+
+ /* Structure members used only for paging files. */
+ ULONG FatChainSize;
+ PULONG FatChain;
} VFATFCB, *PVFATFCB;
typedef struct _VFATCCB
NTSTATUS
NextCluster(PDEVICE_EXTENSION DeviceExt,
+ PVFATFCB Fcb,
ULONG FirstCluster,
PULONG CurrentCluster,
BOOLEAN Extend);
*/
NTSTATUS
OffsetToCluster(PDEVICE_EXTENSION DeviceExt,
+ PVFATFCB Fcb,
ULONG FirstCluster,
ULONG FileOffset,
PULONG Cluster,
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-/* $Id: view.c,v 1.34 2002/01/01 00:21:55 dwelch Exp $
+/* $Id: view.c,v 1.35 2002/01/08 00:49:00 dwelch Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
{
continue;
}
- if (current->MappedCount > 0 || current->Dirty || current->ReferenceCount > 0)
+ if (current->MappedCount > 0 || current->Dirty ||
+ current->ReferenceCount > 0)
{
ExReleaseFastMutex(¤t->Lock);
continue;
}
ExReleaseFastMutex(¤t->Lock);
- DPRINT("current->Bcb->CacheSegmentSize %d\n", current->Bcb->CacheSegmentSize);
+ DPRINT("current->Bcb->CacheSegmentSize %d\n",
+ current->Bcb->CacheSegmentSize);
PagesPerSegment = current->Bcb->CacheSegmentSize / PAGESIZE;
CcRosInternalFreeCacheSegment(current->Bcb, current);
DPRINT("CcRosTrimCache(): Freed %d\n", PagesPerSegment);
ExReleaseFastMutex(&CacheSeg->Lock);
ExAcquireFastMutex(&ViewLock);
RemoveEntryList(&CacheSeg->CacheSegmentLRUListEntry);
- InsertTailList(&CacheSegmentLRUListHead, &CacheSeg->CacheSegmentLRUListEntry);
+ InsertTailList(&CacheSegmentLRUListHead,
+ &CacheSeg->CacheSegmentLRUListEntry);
ExReleaseFastMutex(&ViewLock);
InterlockedDecrement(&CacheSeg->ReferenceCount);
#define NR_SECTION_PAGE_TABLES (1024)
#define NR_SECTION_PAGE_ENTRIES (1024)
-/*
- * Flags for section objects
- */
-#define SO_PHYSICAL_MEMORY (0x1)
/*
* Additional flags for protection attributes
#define MM_PAGEFILE_SECTION (0x1)
#define MM_IMAGE_SECTION (0x2)
+/*
+ * Flags for section objects
+ */
+#define SO_PHYSICAL_MEMORY (0x4)
#define MM_SECTION_SEGMENT_BSS (0x1)
PVOID Address,
SWAPENTRY SwapEntry);
BOOLEAN MmIsPageSwapEntry(PEPROCESS Process, PVOID Address);
+VOID
+MmTransferOwnershipPage(PVOID PhysicalAddress, ULONG NewConsumer);
+VOID MmSetDirtyPage(PEPROCESS Process, PVOID Address);
#endif
-/* $Id: create.c,v 1.51 2001/12/05 12:11:55 ekohl Exp $
+/* $Id: create.c,v 1.52 2002/01/08 00:49:00 dwelch Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
*
*/
NTSTATUS STDCALL
-IoCreateFile(
- OUT PHANDLE FileHandle,
- IN ACCESS_MASK DesiredAccess,
- IN POBJECT_ATTRIBUTES ObjectAttributes,
- OUT PIO_STATUS_BLOCK IoStatusBlock,
- IN PLARGE_INTEGER AllocationSize OPTIONAL,
- IN ULONG FileAttributes,
- IN ULONG ShareAccess,
- IN ULONG CreateDisposition,
- IN ULONG CreateOptions,
- IN PVOID EaBuffer OPTIONAL,
- IN ULONG EaLength,
- IN CREATE_FILE_TYPE CreateFileType,
- IN PVOID ExtraCreateParameters OPTIONAL,
- IN ULONG Options)
+IoCreateFile(OUT PHANDLE FileHandle,
+ IN ACCESS_MASK DesiredAccess,
+ IN POBJECT_ATTRIBUTES ObjectAttributes,
+ OUT PIO_STATUS_BLOCK IoStatusBlock,
+ IN PLARGE_INTEGER AllocationSize OPTIONAL,
+ IN ULONG FileAttributes,
+ IN ULONG ShareAccess,
+ IN ULONG CreateDisposition,
+ IN ULONG CreateOptions,
+ IN PVOID EaBuffer OPTIONAL,
+ IN ULONG EaLength,
+ IN CREATE_FILE_TYPE CreateFileType,
+ IN PVOID ExtraCreateParameters OPTIONAL,
+ IN ULONG Options)
{
PFILE_OBJECT FileObject;
NTSTATUS Status;
break;
}
StackLoc->MinorFunction = 0;
- StackLoc->Flags = 0;
+ StackLoc->Flags = Options;
StackLoc->Control = 0;
StackLoc->DeviceObject = FileObject->DeviceObject;
StackLoc->FileObject = FileObject;
-/* $Id: page.c,v 1.13 2001/10/10 21:56:59 hbirr Exp $
+/* $Id: page.c,v 1.14 2002/01/08 00:49:00 dwelch Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
IoFileObjectType,
UserMode);
- KeInitializeEvent(&Event,NotificationEvent,FALSE);
+ KeInitializeEvent(&Event, NotificationEvent, FALSE);
Irp = IoBuildSynchronousFsdRequestWithMdl(IRP_MJ_READ,
FileObject->DeviceObject,
Mdl,
StackPtr = IoGetNextIrpStackLocation(Irp);
StackPtr->FileObject = FileObject;
DPRINT("Before IoCallDriver\n");
- Status = IoCallDriver(FileObject->DeviceObject,Irp);
+ Status = IoCallDriver(FileObject->DeviceObject, Irp);
DPRINT("Status %d STATUS_PENDING %d\n",Status,STATUS_PENDING);
if (Status==STATUS_PENDING && (FileObject->Flags & FO_SYNCHRONOUS_IO))
{
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-/* $Id: balance.c,v 1.4 2002/01/01 00:21:55 dwelch Exp $
+/* $Id: balance.c,v 1.5 2002/01/08 00:49:00 dwelch Exp $
*
* COPYRIGHT: See COPYING in the top directory
* PROJECT: ReactOS kernel
{
LONG Target;
- Target = MiMemoryConsumers[Consumer].PagesUsed - MiMemoryConsumers[Consumer].PagesTarget;
+ Target = MiMemoryConsumers[Consumer].PagesUsed -
+ MiMemoryConsumers[Consumer].PagesTarget;
if (Target < 0)
{
Target = 1;
{
KeBugCheck(0);
}
+ MmTransferOwnershipPage(Page, Consumer);
*AllocatedPage = Page;
return(STATUS_SUCCESS);
}
/* FUNCTIONS *************************************************************/
+VOID
+MmTransferOwnershipPage(PVOID PhysicalAddress, ULONG NewConsumer)
+{
+ ULONG Start = (ULONG)PhysicalAddress / PAGESIZE;
+ KIRQL oldIrql;
+
+ KeAcquireSpinLock(&PageListLock, &oldIrql);
+ RemoveEntryList(&MmPageArray[Start].ListEntry);
+ InsertTailList(&UsedPageListHeads[NewConsumer],
+ &MmPageArray[Start].ListEntry);
+ KeReleaseSpinLock(&PageListLock, oldIrql);
+}
+
PVOID
MmGetLRUFirstUserPage(VOID)
{
MmPageArray[i].LockCount = 0;
MmPageArray[i].MapCount = 0;
MmPageArray[i].SavedSwapEntry = 0;
- InsertTailList(&UsedPageListHeads[MC_NPPOOL], &MmPageArray[i].ListEntry);
+ InsertTailList(&UsedPageListHeads[MC_NPPOOL],
+ &MmPageArray[i].ListEntry);
}
KeReleaseSpinLock(&PageListLock, oldIrql);
return((PVOID)(start * 4096));
{
ULONG Start = (ULONG)PhysicalAddress / PAGESIZE;
KIRQL oldIrql;
-
+
KeAcquireSpinLock(&PageListLock, &oldIrql);
MmPageArray[Start].SavedSwapEntry = SavedSwapEntry;
KeReleaseSpinLock(&PageListLock, oldIrql);
KeAcquireSpinLock(&PageListLock, &oldIrql);
SavedSwapEntry = MmPageArray[Start].SavedSwapEntry;
KeReleaseSpinLock(&PageListLock, oldIrql);
-
+
return(SavedSwapEntry);
}
DbgPrint("Freeing locked page\n");
KeBugCheck(0);
}
+ if (MmPageArray[Start].SavedSwapEntry != 0)
+ {
+ DbgPrint("Freeing page with swap entry.\n");
+ KeBugCheck(0);
+ }
if (MmPageArray[Start].Flags != MM_PHYSICAL_PAGE_USED)
{
DbgPrint("Freeing page with flags %x\n",
KeBugCheck(0);
}
MmPageArray[Start].Flags = MM_PHYSICAL_PAGE_FREE;
- InsertTailList(&FreeUnzeroedPageListHead, &MmPageArray[Start].ListEntry);
+ InsertTailList(&FreeUnzeroedPageListHead,
+ &MmPageArray[Start].ListEntry);
}
KeReleaseSpinLock(&PageListLock, oldIrql);
}
KIRQL oldIrql;
BOOLEAN NeedClear = FALSE;
+ if (SavedSwapEntry == 0x17)
+ {
+ KeBugCheck(0);
+ }
+
DPRINT("MmAllocPage()\n");
KeAcquireSpinLock(&PageListLock, &oldIrql);
PageDescriptor->LockCount = 0;
PageDescriptor->MapCount = 0;
PageDescriptor->SavedSwapEntry = SavedSwapEntry;
- ExInterlockedInsertTailList(&UsedPageListHeads[Consumer], ListEntry, &PageListLock);
+ ExInterlockedInsertTailList(&UsedPageListHeads[Consumer], ListEntry,
+ &PageListLock);
MmStats.NrSystemPages++;
MmStats.NrFreePages--;
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-/* $Id: page.c,v 1.33 2002/01/01 03:29:15 dwelch Exp $
+/* $Id: page.c,v 1.34 2002/01/08 00:49:01 dwelch Exp $
*
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/mm/i386/page.c
if (Address >= KERNEL_BASE &&
MmGlobalKernelPageDirectory[ADDR_TO_PDE_OFFSET(Address)] != 0)
{
- (*Pde) = MmGlobalKernelPageDirectory[ADDR_TO_PDE_OFFSET(Address)];
+ (*Pde) = MmGlobalKernelPageDirectory[ADDR_TO_PDE_OFFSET(Address)];
FLUSH_TLB;
}
else
*/
if (WasDirty != NULL)
{
- *WasDirty = Pte & PA_DIRTY;
+ if (Pte & PA_DIRTY)
+ {
+ *WasDirty = TRUE;
+ }
+ else
+ {
+ *WasDirty = FALSE;
+ }
}
if (PhysicalAddr != NULL)
{
}
VOID
-MmDeletePageFileMapping(PEPROCESS Process, PVOID Address, SWAPENTRY* SwapEntry)
+MmDeletePageFileMapping(PEPROCESS Process, PVOID Address,
+ SWAPENTRY* SwapEntry)
/*
* FUNCTION: Delete a virtual mapping
*/
}
}
+VOID MmSetDirtyPage(PEPROCESS Process, PVOID Address)
+{
+ PULONG PageEntry;
+ PEPROCESS CurrentProcess = PsGetCurrentProcess();
+
+ if (Process != CurrentProcess)
+ {
+ KeAttachProcess(Process);
+ }
+ PageEntry = MmGetPageEntry(Address);
+ (*PageEntry) = (*PageEntry) | PA_DIRTY;
+ FLUSH_TLB;
+ if (Process != CurrentProcess)
+ {
+ KeDetachProcess();
+ }
+}
+
VOID MmEnableVirtualMapping(PEPROCESS Process, PVOID Address)
{
PULONG PageEntry;
PVOID Address,
SWAPENTRY SwapEntry)
{
- PEPROCESS CurrentProcess;
- PULONG Pte;
- NTSTATUS Status;
-
+ PEPROCESS CurrentProcess;
+ PULONG Pte;
+ NTSTATUS Status;
+
if (Process != NULL)
{
CurrentProcess = PsGetCurrentProcess();
Attributes = ProtectToPTE(flProtect);
if (!(Attributes & PA_PRESENT) && PhysicalAddress != 0)
{
- DPRINT1("Setting physical address but not allowing access at address 0x%.8X "
- "with attributes %x/%x.\n", Address, Attributes, flProtect);
+ DPRINT1("Setting physical address but not allowing access at address "
+ "0x%.8X with attributes %x/%x.\n",
+ Address, Attributes, flProtect);
KeBugCheck(0);
}
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-/* $Id: pagefile.c,v 1.14 2001/12/31 19:06:47 dwelch Exp $
+/* $Id: pagefile.c,v 1.15 2002/01/08 00:49:00 dwelch Exp $
*
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/mm/pagefile.c
/*
* Number of pages that can be used for potentially swapable memory without
- * pagefile space being reserved. The intention is that is allows smss
+ * pagefile space being reserved. The intention is that this allows smss
* to start up and create page files while ordinarily having a commit
* ratio of one.
*/
i = FILE_FROM_ENTRY(SwapEntry);
offset = OFFSET_FROM_ENTRY(SwapEntry);
+
+ if (i > MAX_PAGING_FILES)
+ {
+ DPRINT1("Bad swap entry 0x%.8X\n", SwapEntry);
+ KeBugCheck(0);
+ }
+ if (PagingFileList[i]->FileObject == NULL ||
+ PagingFileList[i]->FileObject->DeviceObject == NULL)
+ {
+ DPRINT1("Bad paging file 0x%.8X\n", SwapEntry);
+ KeBugCheck(0);
+ }
file_offset.QuadPart = offset * 4096;
i = FILE_FROM_ENTRY(SwapEntry);
offset = OFFSET_FROM_ENTRY(SwapEntry);
+
+ if (i > MAX_PAGING_FILES)
+ {
+ DPRINT1("Bad swap entry 0x%.8X\n", SwapEntry);
+ KeBugCheck(0);
+ }
+ if (PagingFileList[i]->FileObject == NULL ||
+ PagingFileList[i]->FileObject->DeviceObject == NULL)
+ {
+ DPRINT1("Bad paging file 0x%.8X\n", SwapEntry);
+ KeBugCheck(0);
+ }
file_offset.QuadPart = offset * 4096;
{
KIRQL oldIrql;
ULONG i, j;
- static BOOLEAN SwapSpaceMessage = FALSE;
KeAcquireSpinLock(&PagingFile->AllocMapLock, &oldIrql);
}
KeReleaseSpinLock(&PagingFile->AllocMapLock, oldIrql);
- if (!SwapSpaceMessage)
- {
- DPRINT1("MM: Out of swap space.\n");
- SwapSpaceMessage = TRUE;
- }
return(0xFFFFFFFF);
}
ULONG i;
ULONG off;
SWAPENTRY entry;
+ static BOOLEAN SwapSpaceMessage = FALSE;
KeAcquireSpinLock(&PagingFileListLock, &oldIrql);
if (MiFreeSwapPages == 0)
{
KeReleaseSpinLock(&PagingFileListLock, oldIrql);
+ if (!SwapSpaceMessage)
+ {
+ DPRINT1("MM: Out of swap space.\n");
+ SwapSpaceMessage = TRUE;
+ }
return(0);
}
}
}
- KeReleaseSpinLock(&PagingFileListLock, oldIrql);
+ KeReleaseSpinLock(&PagingFileListLock, oldIrql);
+ if (!SwapSpaceMessage)
+ {
+ DPRINT1("MM: Out of swap space.\n");
+ SwapSpaceMessage = TRUE;
+ }
return(0);
}
0,
NULL,
NULL);
- Status = NtCreateFile(&FileHandle,
+
+ Status = IoCreateFile(&FileHandle,
FILE_ALL_ACCESS,
&ObjectAttributes,
&IoStatus,
FILE_OPEN_IF,
FILE_SYNCHRONOUS_IO_NONALERT,
NULL,
- 0);
+ 0,
+ CreateFileTypeNone,
+ NULL,
+ SL_OPEN_PAGING_FILE);
if (!NT_SUCCESS(Status))
{
return(Status);
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-/* $Id: rmap.c,v 1.2 2002/01/01 03:29:15 dwelch Exp $
+/* $Id: rmap.c,v 1.3 2002/01/08 00:49:00 dwelch Exp $
*
* COPYRIGHT: See COPYING in the top directory
* PROJECT: ReactOS kernel
/*
* Get or create a pageop
*/
- PageOp = MmGetPageOp(MemoryArea, 0, 0, MemoryArea->Data.SectionData.Segment,
+ PageOp = MmGetPageOp(MemoryArea, 0, 0,
+ MemoryArea->Data.SectionData.Segment,
Offset.u.LowPart, MM_PAGEOP_PAGEOUT);
if (PageOp == NULL)
{
/*
* Do the actual page out work.
*/
- Status = MmPageOutSectionView(&Process->AddressSpace, MemoryArea, Address, PageOp);
+ Status = MmPageOutSectionView(&Process->AddressSpace, MemoryArea,
+ Address, PageOp);
}
else if (Type == MEMORY_AREA_VIRTUAL_MEMORY)
{
/*
* Do the actual page out work.
*/
- Status = MmPageOutVirtualMemory(&Process->AddressSpace, MemoryArea, Address, PageOp);
+ Status = MmPageOutVirtualMemory(&Process->AddressSpace, MemoryArea,
+ Address, PageOp);
}
else
{
PMM_RMAP_ENTRY current_entry;
PMM_RMAP_ENTRY new_entry;
+ Address = (PVOID)PAGE_ROUND_DOWN(Address);
+
new_entry = ExAllocatePool(NonPagedPool, sizeof(MM_RMAP_ENTRY));
if (new_entry == NULL)
{
new_entry->Address = Address;
new_entry->Process = Process;
- if (MmGetPhysicalAddressForProcess(Process, Address)!= (ULONG)PhysicalAddress)
+ if (MmGetPhysicalAddressForProcess(Process, Address) !=
+ (ULONG)PhysicalAddress)
{
- DPRINT1("Insert rmap (%d, 0x%.8X) 0x%.8X which doesn't match physical address 0x%.8X\n",
- Process->UniqueProcessId, Address,
- MmGetPhysicalAddressForProcess(Process, Address), PhysicalAddress)
+ DPRINT1("Insert rmap (%d, 0x%.8X) 0x%.8X which doesn't match physical "
+ "address 0x%.8X\n", Process->UniqueProcessId, Address,
+ MmGetPhysicalAddressForProcess(Process, Address),
+ PhysicalAddress)
KeBugCheck(0);
}
VOID
MmDeleteAllRmaps(PVOID PhysicalAddress, PVOID Context,
- VOID (*DeleteMapping)(PVOID Context, PEPROCESS Process, PVOID Address))
+ VOID (*DeleteMapping)(PVOID Context, PEPROCESS Process,
+ PVOID Address))
{
PMM_RMAP_ENTRY current_entry;
PMM_RMAP_ENTRY previous_entry;
ExAcquireFastMutex(&RmapListLock);
current_entry = MmGetRmapListHeadPage(PhysicalAddress);
+ if (current_entry == NULL)
+ {
+ DPRINT1("MmDeleteAllRmaps: No rmaps.\n");
+ KeBugCheck(0);
+ }
while (current_entry != NULL)
{
previous_entry = current_entry;
current_entry = current_entry->Next;
if (DeleteMapping)
{
- DeleteMapping(Context, previous_entry->Process, previous_entry->Address);
+ DeleteMapping(Context, previous_entry->Process,
+ previous_entry->Address);
}
ExFreePool(previous_entry);
}
current_entry = MmGetRmapListHeadPage(PhysicalAddress);
while (current_entry != NULL)
{
- if (current_entry->Process == Process && current_entry->Address == Address)
+ if (current_entry->Process == Process &&
+ current_entry->Address == Address)
{
if (previous_entry == NULL)
{
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-/* $Id: section.c,v 1.74 2002/01/01 05:09:50 dwelch Exp $
+/* $Id: section.c,v 1.75 2002/01/08 00:49:00 dwelch Exp $
*
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/mm/section.c
}
Entry = MAKE_SSE(PAGE_FROM_SSE(Entry), SHARE_COUNT_FROM_SSE(Entry) - 1);
/*
- * If we reducing the share count of this entry to zero then set the entry to zero and
- * tell the cache the page is no longer mapped.
+ * If we reducing the share count of this entry to zero then set the entry
+ * to zero and tell the cache the page is no longer mapped.
*/
if (SHARE_COUNT_FROM_SSE(Entry) == 0)
{
TRUE);
if (!NT_SUCCESS(Status) && Status != STATUS_END_OF_FILE)
{
- CcRosReleaseCacheSegment(Fcb->Bcb, CacheSeg, FALSE, FALSE, FALSE);
+ CcRosReleaseCacheSegment(Fcb->Bcb, CacheSeg, FALSE, FALSE,
+ FALSE);
return(Status);
}
}
Mdl,
Offset,
&IoStatus,
- FALSE);
+ TRUE);
return(Status);
}
}
ULONG Entry1;
ULONG Attributes;
PMM_PAGEOP PageOp;
-
+
/*
* There is a window between taking the page fault and locking the
* address space when another thread could load the page so we check
DbgPrint("Unable to create virtual mapping\n");
KeBugCheck(0);
}
- MmInsertRmap(Page, PsGetCurrentProcess(), (PVOID)PAGE_ROUND_DOWN(Address));
+ MmInsertRmap(Page, PsGetCurrentProcess(),
+ (PVOID)PAGE_ROUND_DOWN(Address));
}
if (Locked)
{
MmUnlockSectionSegment(Segment);
MmUnlockSection(Section);
+
+ MmDeletePageFileMapping(NULL, (PVOID)PAddress, &SwapEntry);
- Status = MmRequestPageMemoryConsumer(MC_USER, FALSE, &Page);
+ Status = MmRequestPageMemoryConsumer(MC_USER, TRUE, &Page);
if (!NT_SUCCESS(Status))
{
KeBugCheck(0);
KeBugCheck(0);
return(Status);
}
+
+ /*
+ * Store the swap entry for later use.
+ */
+ MmSetSavedSwapEntryPage(Page, SwapEntry);
/*
* Add the page to the process's working set
*/
- MmInsertRmap(Page, PsGetCurrentProcess(), (PVOID)PAGE_ROUND_DOWN(Address));
+ MmInsertRmap(Page, PsGetCurrentProcess(),
+ (PVOID)PAGE_ROUND_DOWN(Address));
/*
* Finish the operation
MemoryArea->Attributes,
Offset.QuadPart,
FALSE);
- /* Don't add an rmap entry since the page mapped could be for anything. */
+ /*
+ * Don't add an rmap entry since the page mapped could be for
+ * anything.
+ */
if (Locked)
{
MmLockPage((PVOID)MmGetPhysicalAddressForProcess(NULL, Address));
MemoryArea->Attributes,
(ULONG)Page,
FALSE);
- MmInsertRmap(Page, PsGetCurrentProcess(), (PVOID)PAGE_ROUND_DOWN(Address));
+ MmInsertRmap(Page, PsGetCurrentProcess(),
+ (PVOID)PAGE_ROUND_DOWN(Address));
if (Locked)
{
MmLockPage((PVOID)MmGetPhysicalAddressForProcess(NULL, Address));
MmLockSection(Section);
MmLockSectionSegment(Segment);
}
- MmInsertRmap(Page, PsGetCurrentProcess(), (PVOID)PAGE_ROUND_DOWN(Address));
+ MmInsertRmap(Page, PsGetCurrentProcess(),
+ (PVOID)PAGE_ROUND_DOWN(Address));
if (!NT_SUCCESS(Status))
{
DbgPrint("Unable to create virtual mapping\n");
Entry = (ULONG)Page;
MmSetPageEntrySectionSegment(Segment, Offset.QuadPart, Entry);
MmSharePageEntrySectionSegment(Segment, Offset.QuadPart);
+
+ /*
+ * Save the swap entry.
+ */
+ MmSetSavedSwapEntryPage(Page, SwapEntry);
Status = MmCreateVirtualMapping(PsGetCurrentProcess(),
Address,
Attributes,
(ULONG)Page,
FALSE);
- MmInsertRmap(Page, PsGetCurrentProcess(), (PVOID)PAGE_ROUND_DOWN(Address));
+ MmInsertRmap(Page, PsGetCurrentProcess(),
+ (PVOID)PAGE_ROUND_DOWN(Address));
if (!NT_SUCCESS(Status))
{
DbgPrint("Unable to create virtual mapping\n");
Attributes,
(ULONG)Page,
FALSE);
- MmInsertRmap(Page, PsGetCurrentProcess(), (PVOID)PAGE_ROUND_DOWN(Address));
+ MmInsertRmap(Page, PsGetCurrentProcess(),
+ (PVOID)PAGE_ROUND_DOWN(Address));
if (!NT_SUCCESS(Status))
{
DbgPrint("Unable to create virtual mapping\n");
MemoryArea->Attributes,
(ULONG)NewPage,
FALSE);
- MmInsertRmap(NewPage, PsGetCurrentProcess(), (PVOID)PAGE_ROUND_DOWN(Address));
+ MmInsertRmap(NewPage, PsGetCurrentProcess(),
+ (PVOID)PAGE_ROUND_DOWN(Address));
if (!NT_SUCCESS(Status))
{
DbgPrint("Unable to create virtual mapping\n");
* Unshare the old page.
*/
MmUnsharePageEntrySectionSegment(Section, Segment, Offset.QuadPart, FALSE);
- MmDeleteRmap((PVOID)OldPage, PsGetCurrentProcess(), (PVOID)PAGE_ROUND_DOWN(Address));
+ MmDeleteRmap((PVOID)OldPage, PsGetCurrentProcess(),
+ (PVOID)PAGE_ROUND_DOWN(Address));
MmDereferencePage((PVOID)OldPage);
PageOp->Status = STATUS_SUCCESS;
FALSE,
&WasDirty,
(PULONG)&PhysicalAddress);
- PageOutContext->WasDirty = PageOutContext->WasDirty || WasDirty;
+ if (WasDirty)
+ {
+ PageOutContext->WasDirty = TRUE;
+ }
if (!PageOutContext->Private)
{
MmUnsharePageEntrySectionSegment(PageOutContext->Section,
PREACTOS_COMMON_FCB_HEADER Fcb;
BOOLEAN DirectMapped;
- DPRINT("MmPageOutSection(Process %d, Address 0x%.8X)\n",
- AddressSpace->Process->UniqueProcessId,
- Address);
-
Address = (PVOID)PAGE_ROUND_DOWN(Address);
Offset.QuadPart = (ULONG)(Address - (ULONG)MemoryArea->BaseAddress) +
Section = MemoryArea->Data.SectionData.Section;
/*
- * This should never happen even mapping of the physical memory are never
+ * This should never happen since mappings of physical memory are never
* placed in the rmap lists.
*/
- if (Segment->Flags & SO_PHYSICAL_MEMORY)
+ if (Section->Flags & SO_PHYSICAL_MEMORY)
{
+ DPRINT1("Trying to page out from physical memory section address 0x%X "
+ "process %d\n", Address, AddressSpace->Process->UniqueProcessId);
KeBugCheck(0);
}
* Get the section segment entry and the physical address.
*/
Entry = MmGetPageEntrySectionSegment(Segment, Offset.QuadPart);
- PhysicalAddress = (PVOID)MmGetPhysicalAddressForProcess(AddressSpace->Process,
- Address);
+ if (!MmIsPagePresent(AddressSpace->Process, Address))
+ {
+ DPRINT1("Trying to page out not-present page at (%d,0x%.8X).\n",
+ AddressSpace->Process->UniqueProcessId, Address);
+ KeBugCheck(0);
+ }
+ PhysicalAddress =
+ (PVOID)MmGetPhysicalAddressForProcess(AddressSpace->Process,
+ Address);
+ SwapEntry = MmGetSavedSwapEntryPage(PhysicalAddress);
/*
* Prepare the context structure for the rmap delete call.
Context.Segment = Segment;
Context.Offset = Offset;
Context.WasDirty = FALSE;
- Context.Private = Private = ((PVOID)(Entry & 0xFFFFF000) != PhysicalAddress);
+ if (IS_SWAP_FROM_SSE(Entry) ||
+ (PVOID)(PAGE_FROM_SSE(Entry)) != PhysicalAddress)
+ {
+ Context.Private = Private = TRUE;
+ }
+ else
+ {
+ Context.Private = Private = FALSE;
+ }
/*
* Take an additional reference to the page.
MmReferencePage(PhysicalAddress);
/*
- * Paging only data mapped read-only is easy.
+ * Paging out data mapped read-only is easy.
*/
if (MemoryArea->Attributes & PAGE_READONLY ||
MemoryArea->Attributes & PAGE_EXECUTE_READ)
{
+ /*
+ * Read-only data should never be in the swapfile.
+ */
+ if (SwapEntry != 0)
+ {
+ DPRINT1("SwapEntry != 0 was 0x%.8X at address 0x%.8X, "
+ "paddress 0x%.8X\n", SwapEntry, Address,
+ PhysicalAddress);
+ KeBugCheck(0);
+ }
+
+ /*
+ * Read-only data should never be COWed
+ */
+ if (Private)
+ {
+ DPRINT1("Had private copy of read-only page.\n");
+ KeBugCheck(0);
+ }
+
/*
* Delete all mappings of this page.
*/
- MmDeleteAllRmaps(PhysicalAddress, (PVOID)&Context, MmPageOutDeleteMapping);
+ MmDeleteAllRmaps(PhysicalAddress, (PVOID)&Context,
+ MmPageOutDeleteMapping);
if (Context.WasDirty)
{
KeBugCheck(0);
}
/*
- * If this page wasn't direct mapped then we have a private copy so release
- * back to the system; otherwise the cache manager will have handled freeing
- * the cache segment which we mapped from.
+ * If this page wasn't direct mapped then we have a private copy so
+ * release back to the system; otherwise the cache manager will have
+ * handled freeing the cache segment which we mapped from.
*/
if (!DirectMapped)
{
*/
if (!Context.WasDirty)
{
- if (!DirectMapped)
+ if (!DirectMapped || Private)
{
MmReleasePageMemoryConsumer(MC_USER, PhysicalAddress);
}
+ if (Private)
+ {
+ if (SwapEntry == 0)
+ {
+ DPRINT1("Private page, non-dirty but not swapped out "
+ "process %d address 0x%.8X\n",
+ AddressSpace->Process->UniqueProcessId,
+ Address);
+ KeBugCheck(0);
+ }
+ else
+ {
+ Status = MmCreatePageFileMapping(AddressSpace->Process,
+ Address,
+ SwapEntry);
+ if (!NT_SUCCESS(Status))
+ {
+ KeBugCheck(0);
+ }
+ }
+ }
PageOp->Status = STATUS_SUCCESS;
KeSetEvent(&PageOp->CompletionEvent, IO_NO_INCREMENT, FALSE);
* If this page was direct mapped from the cache then the cache manager
* will already have taken care of writing it back.
*/
- if (DirectMapped)
+ if (DirectMapped && !Private)
{
+ assert(SwapEntry == 0);
MmDereferencePage((PVOID)PhysicalAddress);
PageOp->Status = STATUS_SUCCESS;
KeSetEvent(&PageOp->CompletionEvent, IO_NO_INCREMENT, FALSE);
MemoryArea->Attributes,
(ULONG)PhysicalAddress,
FALSE);
+ MmSetDirtyPage(MemoryArea->Process, Address);
MmInsertRmap(PhysicalAddress,
MemoryArea->Process,
Address);
{
/*
* For non-private pages if the page wasn't direct mapped then
- * set it back into section segment entry so we don't loose our
- * copy. Otherwise it will be handled by the cache manager.
+ * set it back into the section segment entry so we don't loose
+ * our copy. Otherwise it will be handled by the cache manager.
*/
Status = MmCreateVirtualMapping(MemoryArea->Process,
Address,
MemoryArea->Attributes,
(ULONG)PhysicalAddress,
FALSE);
- MmSetPageEntrySectionSegment(Segment, Offset.QuadPart, (ULONG)PhysicalAddress);
+ MmSetDirtyPage(MemoryArea->Process, Address);
+ MmSetPageEntrySectionSegment(Segment, Offset.QuadPart,
+ (ULONG)PhysicalAddress);
MmSharePageEntrySectionSegment(Segment, Offset.QuadPart);
}
PageOp->Status = STATUS_UNSUCCESSFUL;
Status = MmWriteToSwapPage(SwapEntry, Mdl);
if (!NT_SUCCESS(Status))
{
- DPRINT1("MM: Failed to write to swap page (Status was 0x%.8X)\n", Status);
+ DPRINT1("MM: Failed to write to swap page (Status was 0x%.8X)\n",
+ Status);
/*
* As above: undo our actions.
* FIXME: Also free the swap page.
MemoryArea->Attributes,
(ULONG)PhysicalAddress,
FALSE);
+ MmSetDirtyPage(MemoryArea->Process, Address);
MmInsertRmap(PhysicalAddress,
MemoryArea->Process,
Address);
MemoryArea->Attributes,
(ULONG)PhysicalAddress,
FALSE);
- MmSetPageEntrySectionSegment(Segment, Offset.QuadPart, (ULONG)PhysicalAddress);
+ MmSetDirtyPage(MemoryArea->Process, Address);
+ MmSetPageEntrySectionSegment(Segment, Offset.QuadPart,
+ (ULONG)PhysicalAddress);
MmSharePageEntrySectionSegment(Segment, Offset.QuadPart);
}
PageOp->Status = STATUS_UNSUCCESSFUL;
* Otherwise we have succeeded.
*/
DPRINT("MM: Wrote section page 0x%.8X to swap!\n", PhysicalAddress);
+ MmSetSavedSwapEntryPage(PhysicalAddress, 0);
MmReleasePageMemoryConsumer(MC_USER, PhysicalAddress);
if (Private)
-/* $Id: virtual.c,v 1.53 2002/01/01 00:21:56 dwelch Exp $
+/* $Id: virtual.c,v 1.54 2002/01/08 00:49:01 dwelch Exp $
*
* COPYRIGHT: See COPYING in the top directory
* PROJECT: ReactOS kernel
Status = MmWriteToSwapPage(SwapEntry, Mdl);
if (!NT_SUCCESS(Status))
{
- DPRINT1("MM: Failed to write to swap page (Status was 0x%.8X)\n", Status);
+ DPRINT1("MM: Failed to write to swap page (Status was 0x%.8X)\n",
+ Status);
MmEnableVirtualMapping(MemoryArea->Process, Address);
PageOp->Status = STATUS_UNSUCCESSFUL;
KeSetEvent(&PageOp->CompletionEvent, IO_NO_INCREMENT, FALSE);
MmDeleteVirtualMapping(MemoryArea->Process, Address, FALSE, NULL, NULL);
MmCreatePageFileMapping(MemoryArea->Process, Address, SwapEntry);
MmDeleteAllRmaps(PhysicalAddress, NULL, NULL);
+ MmSetSavedSwapEntryPage(PhysicalAddress, 0);
MmReleasePageMemoryConsumer(MC_USER, PhysicalAddress);
PageOp->Status = STATUS_SUCCESS;
KeSetEvent(&PageOp->CompletionEvent, IO_NO_INCREMENT, FALSE);
{
KeBugCheck(0);
}
+ MmSetSavedSwapEntryPage(Page, SwapEntry);
}
/*
-/* $Id: thread.c,v 1.82 2002/01/03 14:03:05 ekohl Exp $
+/* $Id: thread.c,v 1.83 2002/01/08 00:49:01 dwelch Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
}
if (IncludeSystem || current->ThreadsProcess->UniqueProcessId >= 6)
{
- DbgPrint("current->Tcb.State %d PID.TID %d.%d Name %.8s\n",
- current->Tcb.State, current->ThreadsProcess->UniqueProcessId,
- current->Cid.UniqueThread, current->ThreadsProcess->ImageFileName);
+ DbgPrint("current->Tcb.State %d PID.TID %d.%d Name %.8s Stack: \n",
+ current->Tcb.State,
+ current->ThreadsProcess->UniqueProcessId,
+ current->Cid.UniqueThread,
+ current->ThreadsProcess->ImageFileName);
if (current->Tcb.State == THREAD_STATE_RUNNABLE ||
current->Tcb.State == THREAD_STATE_SUSPENDED ||
current->Tcb.State == THREAD_STATE_BLOCKED)
i = 0;
while (Ebp != 0 && Ebp >= (PULONG)current->Tcb.StackLimit)
{
- DbgPrint("Frame: 0x%.8X Eip: 0x%.8X%s", Ebp[0], Ebp[1],
- (i % 2) == 1 ? "\n" : "");
+ DbgPrint("%.8X%s", Ebp[0], Ebp[1],
+ (i % 8) == 7 ? "\n" : " ");
Ebp = (PULONG)Ebp[0];
+ i++;
}
- if ((i % 2) == 0)
+ if ((i % 8) != 7)
{
DbgPrint("\n");
}
-# $Id: helper.mk,v 1.9 2001/12/11 06:00:07 phreak Exp $
+# $Id: helper.mk,v 1.10 2002/01/08 00:49:02 dwelch Exp $
#
# Helper makefile for ReactOS modules
# Variables this makefile accepts:
# We don't want to link header files
MK_OBJECTS := $(filter-out %.h,$(TARGET_OBJECTS))
+MK_STRIPPED_OBJECT := $(MK_BASENAME).stripped.o
ifeq ($(MK_IMPLIBONLY),yes)
else # MK_IMPLIBONLY
-all: $(MK_FULLNAME)
+all: $(MK_FULLNAME) $(MK_NOSTRIPNAME)
ifeq ($(MK_IMPLIB),yes)
$(MK_FULLRES) $(MK_OBJECTS) $(MK_LIBS) $(MK_GCCLIBS)
- $(RM) temp.exp
- $(NM) --numeric-sort $(MK_NOSTRIPNAME) > $(MK_BASENAME).sym
+
+$(MK_FULLNAME): $(MK_NOSTRIPNAME)
+ $(CP) $(MK_NOSTRIPNAME) $(MK_FULLNAME)
+# $(STRIP) --strip-debug $(MK_FULLNAME)
+
endif # KM_MODE
# Kernel mode targets
- $(RM) temp.exp
- $(NM) --numeric-sort $(MK_NOSTRIPNAME) > $(MK_BASENAME).sym
-endif # MK_MODE
+$(MK_FULLNAME): $(MK_FULLRES) $(TARGET_OBJECTS) $(MK_LIBS)
+ $(LD) -r -o $(MK_STRIPPED_OBJECT) $(MK_OBJECTS)
+ $(STRIP) --strip-debug $(MK_STRIPPED_OBJECT)
+ $(CC) -Wl,--base-file,base.tmp \
+ -Wl,--entry,$(TARGET_ENTRY) \
+ $(TARGET_LFLAGS) \
+ -nostartfiles -nostdlib \
+ -o junk.tmp \
+ $(MK_FULLRES) $(MK_STRIPPED_OBJECT) $(MK_LIBS) $(MK_GCCLIBS)
+ - $(RM) junk.tmp
+ $(DLLTOOL) --dllname $(MK_FULLNAME) \
+ --base-file base.tmp \
+ --output-exp temp.exp $(MK_EXTRACMD)
+ - $(RM) base.tmp
+ $(CC) $(TARGET_LFLAGS) \
+ -Wl,--subsystem,native \
+ -Wl,--image-base,$(TARGET_BASE) \
+ -Wl,--file-alignment,0x1000 \
+ -Wl,--section-alignment,0x1000 \
+ -Wl,--entry,$(TARGET_ENTRY) \
+ -Wl,temp.exp \
+ -mdll -nostartfiles -nostdlib \
+ -o $(MK_FULLNAME) \
+ $(MK_FULLRES) $(MK_STRIPPED_OBJECT) $(MK_LIBS) $(MK_GCCLIBS)
+ - $(RM) temp.exp
-$(MK_FULLNAME): $(MK_NOSTRIPNAME)
- $(CP) $(MK_NOSTRIPNAME) $(MK_FULLNAME)
-# $(STRIP) --strip-debug $(MK_FULLNAME)
+endif # MK_MODE
endif # MK_IMPLIBONLY
typedef const WCHAR *LPCWSTR;
typedef unsigned int *LPBOOL;
+#ifndef __unix__
#define STDCALL __attribute__((stdcall))
+#else
+#define STDCALL
+#endif
int STDCALL MultiByteToWideChar(
UINT CodePage,