From 109fef6e75ced6846a5cda73d61d743ce2bbdf25 Mon Sep 17 00:00:00 2001 From: David Welch Date: Tue, 27 Jun 2000 19:20:45 +0000 Subject: [PATCH] Corrected bug when booting with loadros Began work on fixing up APCs. svn path=/trunk/; revision=1212 --- reactos/include/ddk/zw.h | 4 ++-- reactos/install-system.sh | 8 ++++---- reactos/lib/ntdll/rtl/apc.c | 12 ++++++------ reactos/ntoskrnl/ke/apc.c | 24 ++++++++++++------------ reactos/ntoskrnl/ldr/sysdll.c | 12 +++++++++++- reactos/ntoskrnl/mm/freelist.c | 14 +++++++++++++- reactos/ntoskrnl/ps/create.c | 4 ++-- reactos/ntoskrnl/ps/thread.c | 4 ++-- 8 files changed, 52 insertions(+), 30 deletions(-) diff --git a/reactos/include/ddk/zw.h b/reactos/include/ddk/zw.h index c63e7a03b7e..fcf1bbea6d0 100644 --- a/reactos/include/ddk/zw.h +++ b/reactos/include/ddk/zw.h @@ -1,5 +1,5 @@ -/* $Id: zw.h,v 1.30 2000/05/13 13:50:55 dwelch Exp $ +/* $Id: zw.h,v 1.31 2000/06/27 19:20:42 dwelch Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -479,7 +479,7 @@ NTSTATUS STDCALL NtContinue( IN PCONTEXT Context, - IN CINT IrqLevel + IN BOOLEAN TestAlert ); NTSTATUS STDCALL ZwContinue(IN PCONTEXT Context, IN CINT IrqLevel); diff --git a/reactos/install-system.sh b/reactos/install-system.sh index f73776ffd1d..b4dc8bbfab4 100644 --- a/reactos/install-system.sh +++ b/reactos/install-system.sh @@ -4,10 +4,10 @@ mkdir -p $1/reactos/system32/drivers mkdir -p $1/reactos/bin #cp fdisk.exe $1 #cp format.exe $1 -#cp loaders/dos/loadros.com $1 -#cp ntoskrnl/ntoskrnl.exe $1 -#cp services/fs/vfat/vfatfs.sys $1 -#cp services/dd/ide/ide.sys $1 +cp loaders/dos/loadros.com $1 +cp ntoskrnl/ntoskrnl.exe $1 +cp services/fs/vfat/vfatfs.sys $1 +cp services/dd/ide/ide.sys $1 cp ntoskrnl/ntoskrnl.exe $1/reactos/system32/ cp services/fs/vfat/vfatfs.sys $1/reactos/system32/drivers/ cp services/dd/ide/ide.sys $1/reactos/system32/drivers/ diff --git a/reactos/lib/ntdll/rtl/apc.c b/reactos/lib/ntdll/rtl/apc.c index 94a049ef6c0..a99d7a05ef4 100644 --- a/reactos/lib/ntdll/rtl/apc.c +++ b/reactos/lib/ntdll/rtl/apc.c @@ -1,4 +1,4 @@ -/* $Id: apc.c,v 1.1 2000/05/13 13:50:57 dwelch Exp $ +/* $Id: apc.c,v 1.2 2000/06/27 19:20:43 dwelch Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -16,11 +16,11 @@ /* FUNCTIONS ***************************************************************/ -VOID KiUserApcDispatcher(PIO_APC_ROUTINE ApcRoutine, - PVOID ApcContext, - PIO_STATUS_BLOCK Iosb, - ULONG Reserved, - PCONTEXT Context) +VOID STDCALL KiUserApcDispatcher(PIO_APC_ROUTINE ApcRoutine, + PVOID ApcContext, + PIO_STATUS_BLOCK Iosb, + ULONG Reserved, + PCONTEXT Context) { ApcRoutine(ApcContext, Iosb, diff --git a/reactos/ntoskrnl/ke/apc.c b/reactos/ntoskrnl/ke/apc.c index 5a74acb9ee8..c337c3b835a 100644 --- a/reactos/ntoskrnl/ke/apc.c +++ b/reactos/ntoskrnl/ke/apc.c @@ -81,6 +81,18 @@ BOOLEAN KiTestAlert(PKTHREAD Thread, Esp = (PULONG)UserContext->Esp; memcpy(&SavedContext, UserContext, sizeof(CONTEXT)); + + Esp = Esp - (sizeof(CONTEXT) + (5 * sizeof(ULONG))); + memcpy(Esp, &SavedContext, sizeof(CONTEXT)); + Top = sizeof(CONTEXT) / 4; + Esp[Top] = (ULONG)Apc->NormalRoutine; + Esp[Top + 1] = (ULONG)Apc->NormalContext; + Esp[Top + 2] = (ULONG)Apc->SystemArgument1; + Esp[Top + 3] = (ULONG)Apc->SystemArgument2; + Esp[Top + 4] = (ULONG)Esp - sizeof(CONTEXT); + UserContext->Eip = 0; // KiUserApcDispatcher + + KeReleaseSpinLock(&PiApcLock, oldlvl); /* * Now call for the kernel routine for the APC, which will free @@ -88,18 +100,6 @@ BOOLEAN KiTestAlert(PKTHREAD Thread, */ KeCallKernelRoutineApc(Apc); - Esp = Esp - (sizeof(CONTEXT) + (4 * sizeof(ULONG))); - memcpy(Esp, &SavedContext, sizeof(CONTEXT)); - Top = sizeof(CONTEXT) / 4; - Esp[Top] = (ULONG)Apc->SystemArgument2; - Esp[Top + 1] = (ULONG)Apc->SystemArgument1; - Esp[Top + 2] = (ULONG)Apc->NormalContext; - Esp[Top + 3] = (ULONG)Apc->NormalRoutine; - UserContext->Eip = 0; - - current_entry = current_entry->Flink; - - return(TRUE); } diff --git a/reactos/ntoskrnl/ldr/sysdll.c b/reactos/ntoskrnl/ldr/sysdll.c index be2a428094c..bde5f98f2e7 100644 --- a/reactos/ntoskrnl/ldr/sysdll.c +++ b/reactos/ntoskrnl/ldr/sysdll.c @@ -28,7 +28,7 @@ /* GLOBALS *******************************************************************/ static PVOID SystemDllEntryPoint = NULL; -//static PVOID SystemDllApcDispatcher = NULL; +static PVOID SystemDllApcDispatcher = NULL; //static PVOID SystemDllCallbackDispatcher = NULL; //static PVOID SystemDllExceptionDispatcher = NULL; @@ -39,6 +39,11 @@ PVOID LdrpGetSystemDllEntryPoint(VOID) return(SystemDllEntryPoint); } +PVOID LdrpGetSystemDllApcDispatcher(VOID) +{ + return(SystemDllApcDispatcher); +} + NTSTATUS LdrpMapSystemDll(HANDLE ProcessHandle, PVOID* LdrStartupAddr) /* @@ -133,6 +138,11 @@ NTSTATUS LdrpMapSystemDll(HANDLE ProcessHandle, DPRINT("LdrStartupAddr %x\n", LdrStartupAddr); SystemDllEntryPoint = *LdrStartupAddr; + /* + * FIXME: retrieve the offset of the APC dispatcher from NTDLL + */ + SystemDllApcDispatcher = NULL; + /* * Create a section for NTDLL */ diff --git a/reactos/ntoskrnl/mm/freelist.c b/reactos/ntoskrnl/mm/freelist.c index 5edb54658e1..2c5b9834b9d 100644 --- a/reactos/ntoskrnl/mm/freelist.c +++ b/reactos/ntoskrnl/mm/freelist.c @@ -92,6 +92,18 @@ PVOID MmInitializePageList(PVOID FirstPhysKernelAddress, MiNrFreePages = 0; MiNrUsedPages = 0; + for (i = 0; i < Reserved; i++) + { + if (!MmIsPagePresent(NULL, + (PVOID)((ULONG)MmPageArray + (i * PAGESIZE)))) + { + MmSetPage(NULL, + (PVOID)((ULONG)MmPageArray + (i * PAGESIZE)), + PAGE_READWRITE, + (ULONG)(LastPhysKernelAddress - (i * PAGESIZE))); + } + } + i = 1; if ((ULONG)FirstPhysKernelAddress < 0xa0000) { @@ -109,7 +121,7 @@ PVOID MmInitializePageList(PVOID FirstPhysKernelAddress, } MiNrUsedPages = MiNrUsedPages + ((((ULONG)LastPhysKernelAddress) / PAGESIZE) - i); - for (; i<((ULONG)LastKernelAddress / PAGESIZE); i++) + for (; i<((ULONG)LastPhysKernelAddress / PAGESIZE); i++) { MmPageArray[i].Flags = PHYSICAL_PAGE_INUSE; MmPageArray[i].ReferenceCount = 1; diff --git a/reactos/ntoskrnl/ps/create.c b/reactos/ntoskrnl/ps/create.c index c66dfef1304..03029da91ea 100644 --- a/reactos/ntoskrnl/ps/create.c +++ b/reactos/ntoskrnl/ps/create.c @@ -1,4 +1,4 @@ -/* $Id: create.c,v 1.16 2000/06/03 21:36:32 ekohl Exp $ +/* $Id: create.c,v 1.17 2000/06/27 19:20:45 dwelch Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -268,7 +268,7 @@ static VOID PiTimeoutThread(struct _KDPC *dpc, VOID PiBeforeBeginThread(CONTEXT c) { - DPRINT1("PiBeforeBeginThread(Eip %x)\n", c.Eip); + DPRINT("PiBeforeBeginThread(Eip %x)\n", c.Eip); //KeReleaseSpinLock(&PiThreadListLock, PASSIVE_LEVEL); KeLowerIrql(PASSIVE_LEVEL); } diff --git a/reactos/ntoskrnl/ps/thread.c b/reactos/ntoskrnl/ps/thread.c index b6c21f0807e..0e55596705c 100644 --- a/reactos/ntoskrnl/ps/thread.c +++ b/reactos/ntoskrnl/ps/thread.c @@ -1,4 +1,4 @@ -/* $Id: thread.c,v 1.48 2000/06/04 19:51:05 ekohl Exp $ +/* $Id: thread.c,v 1.49 2000/06/27 19:20:45 dwelch Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -553,7 +553,7 @@ NTSTATUS STDCALL NtSuspendThread (IN HANDLE ThreadHandle, NTSTATUS STDCALL NtContinue(IN PCONTEXT Context, - IN CINT IrqLevel) + IN BOOLEAN TestAlert) { PULONG StackTop;