More bug fixes.

svn path=/trunk/; revision=1158
This commit is contained in:
David Welch 2000-05-24 22:29:38 +00:00
parent 1001fb267c
commit 3e519811c4
7 changed files with 118 additions and 16 deletions

View file

@ -26,8 +26,10 @@ enum
MEMORY_AREA_CACHE_SEGMENT,
};
#define PAGE_TO_SECTION_PAGE_DIRECTORY_OFFSET(x) ((x) / (4*1024*1024))
#define PAGE_TO_SECTION_PAGE_TABLE_OFFSET(x) (((x) % 4*1024*1024) / (4*1024))
#define PAGE_TO_SECTION_PAGE_DIRECTORY_OFFSET(x) \
((x) / (4*1024*1024))
#define PAGE_TO_SECTION_PAGE_TABLE_OFFSET(x) \
((((x)) % (4*1024*1024)) / (4*1024))
#define NR_SECTION_PAGE_TABLES (1024)
#define NR_SECTION_PAGE_ENTRIES (1024)

View file

@ -1,4 +1,4 @@
/* $Id: startup.c,v 1.22 2000/03/22 18:35:51 dwelch Exp $
/* $Id: startup.c,v 1.23 2000/05/24 22:29:35 dwelch Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -18,7 +18,7 @@
#include <csrss/csrss.h>
#include <ntdll/csr.h>
#define NDEBUG
//#define NDEBUG
#include <ntdll/ntdll.h>
/* GLOBALS *******************************************************************/
@ -57,7 +57,7 @@ VOID LdrStartup(VOID)
if (ImageBase <= (PVOID)0x1000)
{
DPRINT("ImageBase is null\n");
for(;;);
ZwTerminateProcess(NtCurrentProcess(), STATUS_UNSUCCESSFUL);
}
NtGlobalFlag = Peb->NtGlobalFlag;
@ -70,7 +70,7 @@ VOID LdrStartup(VOID)
*(PULONG)((PUCHAR)ImageBase + PEDosHeader->e_lfanew) != IMAGE_PE_MAGIC)
{
DbgPrint("Image has bad header\n");
ZwTerminateProcess(NULL, STATUS_UNSUCCESSFUL);
ZwTerminateProcess(NtCurrentProcess(), STATUS_UNSUCCESSFUL);
}
/* normalize process parameters */

View file

@ -1,4 +1,4 @@
/* $Id: kdebug.c,v 1.10 2000/04/08 19:09:30 ekohl Exp $
/* $Id: kdebug.c,v 1.11 2000/05/24 22:29:36 dwelch Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -43,7 +43,7 @@ KdDebuggerNotPresent = TRUE; /* EXPORTED */
static BOOLEAN KdpBreakPending = FALSE;
static BOOLEAN KdpBreakRecieved = FALSE;
static ULONG KdpDebugType = 0;
static ULONG KdpDebugType = BochsDebug;
/* PRIVATE FUNCTIONS ********************************************************/
@ -134,7 +134,7 @@ KdInitSystem (
if (Value > 0)
{
KdDebuggerEnabled = TRUE;
KdpDebugType = SerialDebug;
KdpDebugType = KdpDebugType | SerialDebug;
PortInfo.BaudRate = Value;
}
break;
@ -152,7 +152,7 @@ KdInitSystem (
{
p2 += 5;
KdDebuggerEnabled = TRUE;
KdpDebugType = SerialDebug;
KdpDebugType = KdpDebugType | SerialDebug;
break;
}
p1 = p2;

View file

@ -339,6 +339,20 @@ asmlinkage void exception_handler(unsigned int edi,
}
}
}
if (MmIsPagePresent(NULL, (PVOID)eip))
{
char instrs[512];
memcpy(instrs, (PVOID)eip, 512);
DbgPrint("Instrs: ");
for (i=0; i<10; i++)
{
DbgPrint("%x ", instrs[i]);
}
}
#endif
}

View file

@ -1,4 +1,4 @@
/* $Id: usercall.c,v 1.11 2000/05/13 13:51:05 dwelch Exp $
/* $Id: usercall.c,v 1.12 2000/05/24 22:29:36 dwelch Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -57,7 +57,7 @@ void PsBeginThreadWithContextInternal(void);
VOID KiSystemCallHook(ULONG Nr, ...)
{
#if 1
#if 0
va_list ap;
ULONG i;

View file

@ -1,4 +1,4 @@
/* $Id: mm.c,v 1.29 2000/05/13 13:51:05 dwelch Exp $
/* $Id: mm.c,v 1.30 2000/05/24 22:29:36 dwelch Exp $
*
* COPYRIGHT: See COPYING in the top directory
* PROJECT: ReactOS kernel
@ -146,7 +146,7 @@ NTSTATUS MmNotPresentFault(KPROCESSOR_MODE Mode,
MEMORY_AREA* MemoryArea;
NTSTATUS Status;
DPRINT1("MmNotPresentFault(Mode %d, Address %x)\n", Mode, Address);
DPRINT("MmNotPresentFault(Mode %d, Address %x)\n", Mode, Address);
if (KeGetCurrentIrql() >= DISPATCH_LEVEL)
{

View file

@ -1,4 +1,4 @@
/* $Id: section.c,v 1.30 2000/05/13 13:51:05 dwelch Exp $
/* $Id: section.c,v 1.31 2000/05/24 22:29:38 dwelch Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -56,6 +56,8 @@ VOID MmSetPageEntrySection(PSECTION_OBJECT Section,
Table =
Section->PageDirectory.PageTables[DirectoryOffset] =
ExAllocatePool(NonPagedPool, sizeof(SECTION_PAGE_TABLE));
memset(Table, 0, sizeof(SECTION_PAGE_TABLE));
DPRINT("Table %x\n", Table);
}
TableOffset = PAGE_TO_SECTION_PAGE_TABLE_OFFSET(Offset);
Table->Pages[TableOffset] = Entry;
@ -69,8 +71,11 @@ PVOID MmGetPageEntrySection(PSECTION_OBJECT Section,
ULONG DirectoryOffset;
ULONG TableOffset;
DPRINT("MmGetPageEntrySection(Offset %x)\n", Offset);
DirectoryOffset = PAGE_TO_SECTION_PAGE_DIRECTORY_OFFSET(Offset);
Table = Section->PageDirectory.PageTables[DirectoryOffset];
DPRINT("Table %x\n", Table);
if (Table == NULL)
{
return(NULL);
@ -80,6 +85,70 @@ PVOID MmGetPageEntrySection(PSECTION_OBJECT Section,
return(Entry);
}
NTSTATUS MmOldLoadPageForSection(PMADDRESS_SPACE AddressSpace,
MEMORY_AREA* MemoryArea,
PVOID Address)
{
LARGE_INTEGER Offset;
IO_STATUS_BLOCK IoStatus;
PMDL Mdl;
PVOID Page;
NTSTATUS Status;
ULONG PAddress;
PSECTION_OBJECT Section;
DPRINT("MmOldLoadPageForSection(MemoryArea %x, Address %x)\n",
MemoryArea,Address);
if (MmIsPagePresent(NULL, Address))
{
DPRINT("Page is already present\n");
return(STATUS_SUCCESS);
}
PAddress = (ULONG)PAGE_ROUND_DOWN(((ULONG)Address));
Offset.QuadPart = (PAddress - (ULONG)MemoryArea->BaseAddress) +
MemoryArea->Data.SectionData.ViewOffset;
DPRINT("MemoryArea->BaseAddress %x\n", MemoryArea->BaseAddress);
DPRINT("MemoryArea->Data.SectionData.ViewOffset %x\n",
MemoryArea->Data.SectionData.ViewOffset);
DPRINT("Got offset %x\n", Offset.QuadPart);
Section = MemoryArea->Data.SectionData.Section;
DPRINT("Section %x\n", Section);
MmLockSection(Section);
Mdl = MmCreateMdl(NULL, NULL, PAGESIZE);
MmBuildMdlFromPages(Mdl);
Page = MmGetMdlPageAddress(Mdl, 0);
MmUnlockSection(Section);
MmUnlockAddressSpace(AddressSpace);
DPRINT("Reading file offset %x\n", Offset.QuadPart);
Status = IoPageRead(MemoryArea->Data.SectionData.Section->FileObject,
Mdl,
&Offset,
&IoStatus);
if (!NT_SUCCESS(Status))
{
return(Status);
}
MmLockAddressSpace(AddressSpace);
MmLockSection(Section);
MmSetPage(NULL,
Address,
MemoryArea->Attributes,
(ULONG)Page);
MmUnlockSection(Section);
return(STATUS_SUCCESS);
}
NTSTATUS MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace,
MEMORY_AREA* MemoryArea,
PVOID Address)
@ -98,6 +167,7 @@ NTSTATUS MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace,
if (MmIsPagePresent(NULL, Address))
{
DPRINT("Page is already present\n");
return(STATUS_SUCCESS);
}
@ -105,11 +175,25 @@ NTSTATUS MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace,
Offset.QuadPart = (PAddress - (ULONG)MemoryArea->BaseAddress) +
MemoryArea->Data.SectionData.ViewOffset;
if ((MemoryArea->Data.SectionData.ViewOffset % PAGESIZE) != 0)
{
return(MmOldLoadPageForSection(AddressSpace, MemoryArea, Address));
}
DPRINT("MemoryArea->BaseAddress %x\n", MemoryArea->BaseAddress);
DPRINT("MemoryArea->Data.SectionData.ViewOffset %x\n",
MemoryArea->Data.SectionData.ViewOffset);
DPRINT("Got offset %x\n", Offset.QuadPart);
Section = MemoryArea->Data.SectionData.Section;
DPRINT("Section %x\n", Section);
MmLockSection(Section);
Entry = MmGetPageEntrySection(Section, Offset.QuadPart);
Entry = MmGetPageEntrySection(Section, Offset.u.LowPart);
DPRINT("Entry %x\n", Entry);
if (Entry == NULL)
{
@ -118,6 +202,7 @@ NTSTATUS MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace,
Page = MmGetMdlPageAddress(Mdl, 0);
MmUnlockSection(Section);
MmUnlockAddressSpace(AddressSpace);
DPRINT("Reading file offset %x\n", Offset.QuadPart);
Status = IoPageRead(MemoryArea->Data.SectionData.Section->FileObject,
Mdl,
&Offset,
@ -294,6 +379,7 @@ NTSTATUS STDCALL NtCreateSection (OUT PHANDLE SectionHandle,
InitializeListHead(&Section->ViewListHead);
KeInitializeSpinLock(&Section->ViewListLock);
KeInitializeMutex(&Section->Lock, 0);
memset(&Section->PageDirectory, 0, sizeof(Section->PageDirectory));
if (FileHandle != (HANDLE)0xffffffff)
{