2000-10-07 13:41:58 +00:00
|
|
|
/*
|
|
|
|
* ReactOS kernel
|
2001-03-16 18:11:24 +00:00
|
|
|
* Copyright (C) 2000 ReactOS Team
|
2000-10-07 13:41:58 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program 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 General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
*/
|
2003-12-31 05:33:04 +00:00
|
|
|
/* $Id: kthread.c,v 1.46 2003/12/31 05:33:03 jfilby Exp $
|
2002-05-07 22:34:17 +00:00
|
|
|
*
|
2000-10-07 13:41:58 +00:00
|
|
|
* FILE: ntoskrnl/ke/kthread.c
|
|
|
|
* PURPOSE: Microkernel thread support
|
|
|
|
* PROGRAMMER: David Welch (welch@cwcom.net)
|
|
|
|
* UPDATE HISTORY:
|
|
|
|
* Created 22/05/98
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* INCLUDES *****************************************************************/
|
|
|
|
|
2002-09-08 10:23:54 +00:00
|
|
|
#include <ddk/ntddk.h>
|
|
|
|
#include <internal/ke.h>
|
|
|
|
#include <internal/ps.h>
|
|
|
|
#include <internal/id.h>
|
|
|
|
#include <internal/pool.h>
|
2000-10-07 13:41:58 +00:00
|
|
|
|
|
|
|
#define NDEBUG
|
|
|
|
#include <internal/debug.h>
|
|
|
|
|
|
|
|
/* FUNCTIONS *****************************************************************/
|
|
|
|
|
2001-03-29 01:14:00 +00:00
|
|
|
VOID
|
2002-06-04 David Welch <welch@whitehall1-5.seh.ox.ac.uk>
* ntoskrnl/ke/i386/exp.c (KiDoubleFaultHandler): Print CR3
correctly.
2002-06-04 David Welch <welch@whitehall1-5.seh.ox.ac.uk>
* ntoskrnl/include/internal/ps.h: Added KTHREAD_STACK_LIMIT definition.
* ntoskrnl/ke/i386/tskswitch.S (Ki386ContextSwitch): Force all the
pages of the kernel stack to be accessible from this process.
2002-06-04 David Welch <welch@cwcom.net>
* ntoskrnl/cc/view.c (ReadCacheSegmentChain): Changes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/cc/copy.c (CcRosCreateCacheSegment): Changes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/cc/copy.c (CcFreeCachePage): Changes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/include/internal/mm.h: Changed prototypes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/include/internal/ps.h (KPROCESS): Changed type of
page directory base to PHYSICAL_ADDRESS.
* ntoskrnl/include/internal/i386/mm.h: Changed prototypes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/ke/kthread.c (KeFreeStackPage): Changes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/ke/kthread.c (KeInitializeThread): Changes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/ke/process.c (KeAttachProcess, KeDetachProcess): Changes
to use PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/ke/kernel.c (PcrPages, KeApplicationProcessorInit): Changes
to use PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/mm/balance.c (MM_ALLOCATION_REQUEST): Changes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/mm/balance.c (MmReleasePageMemoryConsumer): Changes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/mm/balance.c (MmRequestPageMemoryConsumer): Changes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/mm/cont.c (MmFreeContinuousPage): Changes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/mm/cont.c (MmAllocateContinuousAlignedMemory): Changes to
use PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/mm/freelist.c (MmTransferOwnershipPage,
MmGetLRUFirstUserPage, MmGetLRUNextUserPage, MmGetContinuousPages,
MmInitializePageList, MmSetFlagsPage, MmSetRmapListHeadPage,
MmGetRmapListHeadPage, MmMarkPageMapped, MmMarkPageUnmapped,
MmGetFlagsPage, MmSetSavedSwapEntryPage, MmGetSavedSwapEntryPage,
MmReferencePage, MmGetReferenceCountPage, MmIsUsablePage,
MmDereferencePage, MmGetLockCountPage, MmLockPage, MmUnlockPage,
MmAllocPage): Changes to use PHYSICAL_ADDRESS type for physical
addresses.
* ntoskrnl/mm/iospace.c (MmMapIoSpace): Changes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/mm/kmap.c (ExAllocatePage, MiZeroPage, MiCopyFromUserPage,
ExAllocatePageWithPhysPage): Changes to use PHYSICAL_ADDRESS type for
physical addresses.
* ntoskrnl/mm/marea.c (MmFreeMemoryArea): Changes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/mm/mdl.c (MmUnlockPages, MmMapLockedPages,
MmProbeAndLockPages): Changes to use PHYSICAL_ADDRESS type for
physical addresses.
* ntoskrnl/mm/mm.c (MmSharedDataPagePhysicalAddress,
MmCommitPagedPoolAddress, MmNotPresentFault): Changes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/mm/mminit.c (MmInitVirtualMemory): Changes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/mm/ncache.c (MmAllocateNonCachedMemory,
MmFreeNonCachedPage): Changes to use PHYSICAL_ADDRESS type for
physical addresses.
* ntoskrnl/mm/npool.c (grow_kernel_pool): Changes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/mm/rmap.c (MmPageOutPhysicalAddress, MmInsertRmap,
MmDeleteAllRmaps, MmDeleteRmap): Changes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/mm/section.c (MiReadPage, MmNotPresentFaultSectionView,
MmAccessFaultSectionView, MmPageOutDeleteMapping,
MmPageOutSectionView, MmFreeSectionPage): Changes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/mm/slab.c (ExGrowSlabCache): Changes to use
PHYSICAL_ADDRESS type for physical address.
* ntoskrnl/mm/virtual.c (MmPageOutVirtualMemory,
MmNotPresentFaultVirtualMemory, MmFreeVirtualMemoryPage): Changes to
use PHYSICAL_ADDRESS type for physical address.
* ntoskrnl/mm/wset.c (MmTrimUserMemory): Changes to use
PHYSICAL_ADDRESS type for physical address.
* ntoskrnl/mm/page.c (Mmi386ReleaseMmInfo, MmCopyMmInfo,
MmGetPhysicalAddressForProcess, MmCreateVirtualMapping,
MmCreateVirtualMappingUnsafe, MmCreateVirtualMappingForProcess,
MmDeleteVirtualMapping): Changes to use PHYSICAL_ADDRESS type for
physical address.
* ntoskrnl/ps/process (PsInitProcessManagment): Changes to use
PHYSICAL_ADDRESS type for physical address.
* ntoskrnl/ps/thread.c (PsAllocateCallbackStack): Changes to use
PHYSICAL_ADDRESS type for physical address.
2002-06-04 David Welch <welch@cwcom.net>
* Lots of change since the ChangeLog was last updated.
svn path=/trunk/; revision=3000
2002-06-04 15:26:58 +00:00
|
|
|
KeFreeStackPage(PVOID Context, MEMORY_AREA* MemoryArea, PVOID Address,
|
|
|
|
PHYSICAL_ADDRESS PhysAddr, SWAPENTRY SwapEntry, BOOLEAN Dirty)
|
2001-03-29 01:14:00 +00:00
|
|
|
{
|
2002-05-14 21:19:21 +00:00
|
|
|
assert(SwapEntry == 0);
|
2002-06-04 David Welch <welch@whitehall1-5.seh.ox.ac.uk>
* ntoskrnl/ke/i386/exp.c (KiDoubleFaultHandler): Print CR3
correctly.
2002-06-04 David Welch <welch@whitehall1-5.seh.ox.ac.uk>
* ntoskrnl/include/internal/ps.h: Added KTHREAD_STACK_LIMIT definition.
* ntoskrnl/ke/i386/tskswitch.S (Ki386ContextSwitch): Force all the
pages of the kernel stack to be accessible from this process.
2002-06-04 David Welch <welch@cwcom.net>
* ntoskrnl/cc/view.c (ReadCacheSegmentChain): Changes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/cc/copy.c (CcRosCreateCacheSegment): Changes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/cc/copy.c (CcFreeCachePage): Changes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/include/internal/mm.h: Changed prototypes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/include/internal/ps.h (KPROCESS): Changed type of
page directory base to PHYSICAL_ADDRESS.
* ntoskrnl/include/internal/i386/mm.h: Changed prototypes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/ke/kthread.c (KeFreeStackPage): Changes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/ke/kthread.c (KeInitializeThread): Changes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/ke/process.c (KeAttachProcess, KeDetachProcess): Changes
to use PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/ke/kernel.c (PcrPages, KeApplicationProcessorInit): Changes
to use PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/mm/balance.c (MM_ALLOCATION_REQUEST): Changes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/mm/balance.c (MmReleasePageMemoryConsumer): Changes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/mm/balance.c (MmRequestPageMemoryConsumer): Changes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/mm/cont.c (MmFreeContinuousPage): Changes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/mm/cont.c (MmAllocateContinuousAlignedMemory): Changes to
use PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/mm/freelist.c (MmTransferOwnershipPage,
MmGetLRUFirstUserPage, MmGetLRUNextUserPage, MmGetContinuousPages,
MmInitializePageList, MmSetFlagsPage, MmSetRmapListHeadPage,
MmGetRmapListHeadPage, MmMarkPageMapped, MmMarkPageUnmapped,
MmGetFlagsPage, MmSetSavedSwapEntryPage, MmGetSavedSwapEntryPage,
MmReferencePage, MmGetReferenceCountPage, MmIsUsablePage,
MmDereferencePage, MmGetLockCountPage, MmLockPage, MmUnlockPage,
MmAllocPage): Changes to use PHYSICAL_ADDRESS type for physical
addresses.
* ntoskrnl/mm/iospace.c (MmMapIoSpace): Changes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/mm/kmap.c (ExAllocatePage, MiZeroPage, MiCopyFromUserPage,
ExAllocatePageWithPhysPage): Changes to use PHYSICAL_ADDRESS type for
physical addresses.
* ntoskrnl/mm/marea.c (MmFreeMemoryArea): Changes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/mm/mdl.c (MmUnlockPages, MmMapLockedPages,
MmProbeAndLockPages): Changes to use PHYSICAL_ADDRESS type for
physical addresses.
* ntoskrnl/mm/mm.c (MmSharedDataPagePhysicalAddress,
MmCommitPagedPoolAddress, MmNotPresentFault): Changes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/mm/mminit.c (MmInitVirtualMemory): Changes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/mm/ncache.c (MmAllocateNonCachedMemory,
MmFreeNonCachedPage): Changes to use PHYSICAL_ADDRESS type for
physical addresses.
* ntoskrnl/mm/npool.c (grow_kernel_pool): Changes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/mm/rmap.c (MmPageOutPhysicalAddress, MmInsertRmap,
MmDeleteAllRmaps, MmDeleteRmap): Changes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/mm/section.c (MiReadPage, MmNotPresentFaultSectionView,
MmAccessFaultSectionView, MmPageOutDeleteMapping,
MmPageOutSectionView, MmFreeSectionPage): Changes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/mm/slab.c (ExGrowSlabCache): Changes to use
PHYSICAL_ADDRESS type for physical address.
* ntoskrnl/mm/virtual.c (MmPageOutVirtualMemory,
MmNotPresentFaultVirtualMemory, MmFreeVirtualMemoryPage): Changes to
use PHYSICAL_ADDRESS type for physical address.
* ntoskrnl/mm/wset.c (MmTrimUserMemory): Changes to use
PHYSICAL_ADDRESS type for physical address.
* ntoskrnl/mm/page.c (Mmi386ReleaseMmInfo, MmCopyMmInfo,
MmGetPhysicalAddressForProcess, MmCreateVirtualMapping,
MmCreateVirtualMappingUnsafe, MmCreateVirtualMappingForProcess,
MmDeleteVirtualMapping): Changes to use PHYSICAL_ADDRESS type for
physical address.
* ntoskrnl/ps/process (PsInitProcessManagment): Changes to use
PHYSICAL_ADDRESS type for physical address.
* ntoskrnl/ps/thread.c (PsAllocateCallbackStack): Changes to use
PHYSICAL_ADDRESS type for physical address.
2002-06-04 David Welch <welch@cwcom.net>
* Lots of change since the ChangeLog was last updated.
svn path=/trunk/; revision=3000
2002-06-04 15:26:58 +00:00
|
|
|
if (PhysAddr.QuadPart != 0)
|
2001-03-29 01:14:00 +00:00
|
|
|
{
|
2002-06-10 21:34:38 +00:00
|
|
|
MmReleasePageMemoryConsumer(MC_NPPOOL, PhysAddr);
|
2001-03-29 01:14:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-03-08 22:06:02 +00:00
|
|
|
NTSTATUS
|
2002-02-15 14:47:55 +00:00
|
|
|
KeReleaseThread(PETHREAD Thread)
|
2001-03-08 22:06:02 +00:00
|
|
|
/*
|
|
|
|
* FUNCTION: Releases the resource allocated for a thread by
|
2002-02-15 14:47:55 +00:00
|
|
|
* KeInitializeThread
|
2001-03-08 22:06:02 +00:00
|
|
|
* NOTE: The thread had better not be running when this is called
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
extern unsigned int init_stack;
|
2001-03-29 01:14:00 +00:00
|
|
|
|
2001-03-08 22:06:02 +00:00
|
|
|
if (Thread->Tcb.StackLimit != (ULONG)&init_stack)
|
|
|
|
{
|
2002-05-07 22:34:17 +00:00
|
|
|
MmLockAddressSpace(MmGetKernelAddressSpace());
|
2001-03-29 01:14:00 +00:00
|
|
|
MmFreeMemoryArea(MmGetKernelAddressSpace(),
|
|
|
|
(PVOID)Thread->Tcb.StackLimit,
|
|
|
|
MM_STACK_SIZE,
|
|
|
|
KeFreeStackPage,
|
|
|
|
NULL);
|
2002-05-07 22:34:17 +00:00
|
|
|
MmUnlockAddressSpace(MmGetKernelAddressSpace());
|
2001-03-08 22:06:02 +00:00
|
|
|
}
|
|
|
|
Thread->Tcb.StackLimit = 0;
|
|
|
|
Thread->Tcb.InitialStack = NULL;
|
|
|
|
Thread->Tcb.StackBase = NULL;
|
|
|
|
Thread->Tcb.KernelStack = NULL;
|
|
|
|
return(STATUS_SUCCESS);
|
|
|
|
}
|
|
|
|
|
2003-06-16 16:45:52 +00:00
|
|
|
VOID
|
2000-12-23 02:37:41 +00:00
|
|
|
KeInitializeThread(PKPROCESS Process, PKTHREAD Thread, BOOLEAN First)
|
2000-10-07 13:41:58 +00:00
|
|
|
/*
|
|
|
|
* FUNCTION: Initialize the microkernel state of the thread
|
|
|
|
*/
|
|
|
|
{
|
2001-11-25 15:21:11 +00:00
|
|
|
PVOID KernelStack;
|
|
|
|
NTSTATUS Status;
|
|
|
|
extern unsigned int init_stack_top;
|
|
|
|
extern unsigned int init_stack;
|
|
|
|
PMEMORY_AREA StackArea;
|
|
|
|
ULONG i;
|
2003-12-31 05:33:04 +00:00
|
|
|
PHYSICAL_ADDRESS BoundaryAddressMultiple;
|
|
|
|
|
|
|
|
BoundaryAddressMultiple.QuadPart = 0;
|
2001-11-25 15:21:11 +00:00
|
|
|
|
|
|
|
KeInitializeDispatcherHeader(&Thread->DispatcherHeader,
|
|
|
|
InternalThreadType,
|
|
|
|
sizeof(ETHREAD),
|
|
|
|
FALSE);
|
|
|
|
InitializeListHead(&Thread->MutantListHead);
|
|
|
|
if (!First)
|
|
|
|
{
|
|
|
|
KernelStack = NULL;
|
|
|
|
|
|
|
|
MmLockAddressSpace(MmGetKernelAddressSpace());
|
|
|
|
Status = MmCreateMemoryArea(NULL,
|
|
|
|
MmGetKernelAddressSpace(),
|
|
|
|
MEMORY_AREA_KERNEL_STACK,
|
|
|
|
&KernelStack,
|
|
|
|
MM_STACK_SIZE,
|
2002-05-14 21:19:21 +00:00
|
|
|
0,
|
2001-11-25 15:21:11 +00:00
|
|
|
&StackArea,
|
2003-05-17 15:29:50 +00:00
|
|
|
FALSE,
|
2003-12-31 05:33:04 +00:00
|
|
|
FALSE,
|
|
|
|
BoundaryAddressMultiple);
|
2001-11-25 15:21:11 +00:00
|
|
|
MmUnlockAddressSpace(MmGetKernelAddressSpace());
|
|
|
|
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
DPRINT1("Failed to create thread stack\n");
|
2003-07-21 21:53:53 +00:00
|
|
|
KEBUGCHECK(0);
|
2001-11-25 15:21:11 +00:00
|
|
|
}
|
2002-10-01 19:27:25 +00:00
|
|
|
for (i = 0; i < (MM_STACK_SIZE / PAGE_SIZE); i++)
|
2001-11-25 15:21:11 +00:00
|
|
|
{
|
2002-06-04 David Welch <welch@whitehall1-5.seh.ox.ac.uk>
* ntoskrnl/ke/i386/exp.c (KiDoubleFaultHandler): Print CR3
correctly.
2002-06-04 David Welch <welch@whitehall1-5.seh.ox.ac.uk>
* ntoskrnl/include/internal/ps.h: Added KTHREAD_STACK_LIMIT definition.
* ntoskrnl/ke/i386/tskswitch.S (Ki386ContextSwitch): Force all the
pages of the kernel stack to be accessible from this process.
2002-06-04 David Welch <welch@cwcom.net>
* ntoskrnl/cc/view.c (ReadCacheSegmentChain): Changes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/cc/copy.c (CcRosCreateCacheSegment): Changes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/cc/copy.c (CcFreeCachePage): Changes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/include/internal/mm.h: Changed prototypes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/include/internal/ps.h (KPROCESS): Changed type of
page directory base to PHYSICAL_ADDRESS.
* ntoskrnl/include/internal/i386/mm.h: Changed prototypes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/ke/kthread.c (KeFreeStackPage): Changes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/ke/kthread.c (KeInitializeThread): Changes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/ke/process.c (KeAttachProcess, KeDetachProcess): Changes
to use PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/ke/kernel.c (PcrPages, KeApplicationProcessorInit): Changes
to use PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/mm/balance.c (MM_ALLOCATION_REQUEST): Changes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/mm/balance.c (MmReleasePageMemoryConsumer): Changes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/mm/balance.c (MmRequestPageMemoryConsumer): Changes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/mm/cont.c (MmFreeContinuousPage): Changes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/mm/cont.c (MmAllocateContinuousAlignedMemory): Changes to
use PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/mm/freelist.c (MmTransferOwnershipPage,
MmGetLRUFirstUserPage, MmGetLRUNextUserPage, MmGetContinuousPages,
MmInitializePageList, MmSetFlagsPage, MmSetRmapListHeadPage,
MmGetRmapListHeadPage, MmMarkPageMapped, MmMarkPageUnmapped,
MmGetFlagsPage, MmSetSavedSwapEntryPage, MmGetSavedSwapEntryPage,
MmReferencePage, MmGetReferenceCountPage, MmIsUsablePage,
MmDereferencePage, MmGetLockCountPage, MmLockPage, MmUnlockPage,
MmAllocPage): Changes to use PHYSICAL_ADDRESS type for physical
addresses.
* ntoskrnl/mm/iospace.c (MmMapIoSpace): Changes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/mm/kmap.c (ExAllocatePage, MiZeroPage, MiCopyFromUserPage,
ExAllocatePageWithPhysPage): Changes to use PHYSICAL_ADDRESS type for
physical addresses.
* ntoskrnl/mm/marea.c (MmFreeMemoryArea): Changes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/mm/mdl.c (MmUnlockPages, MmMapLockedPages,
MmProbeAndLockPages): Changes to use PHYSICAL_ADDRESS type for
physical addresses.
* ntoskrnl/mm/mm.c (MmSharedDataPagePhysicalAddress,
MmCommitPagedPoolAddress, MmNotPresentFault): Changes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/mm/mminit.c (MmInitVirtualMemory): Changes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/mm/ncache.c (MmAllocateNonCachedMemory,
MmFreeNonCachedPage): Changes to use PHYSICAL_ADDRESS type for
physical addresses.
* ntoskrnl/mm/npool.c (grow_kernel_pool): Changes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/mm/rmap.c (MmPageOutPhysicalAddress, MmInsertRmap,
MmDeleteAllRmaps, MmDeleteRmap): Changes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/mm/section.c (MiReadPage, MmNotPresentFaultSectionView,
MmAccessFaultSectionView, MmPageOutDeleteMapping,
MmPageOutSectionView, MmFreeSectionPage): Changes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/mm/slab.c (ExGrowSlabCache): Changes to use
PHYSICAL_ADDRESS type for physical address.
* ntoskrnl/mm/virtual.c (MmPageOutVirtualMemory,
MmNotPresentFaultVirtualMemory, MmFreeVirtualMemoryPage): Changes to
use PHYSICAL_ADDRESS type for physical address.
* ntoskrnl/mm/wset.c (MmTrimUserMemory): Changes to use
PHYSICAL_ADDRESS type for physical address.
* ntoskrnl/mm/page.c (Mmi386ReleaseMmInfo, MmCopyMmInfo,
MmGetPhysicalAddressForProcess, MmCreateVirtualMapping,
MmCreateVirtualMappingUnsafe, MmCreateVirtualMappingForProcess,
MmDeleteVirtualMapping): Changes to use PHYSICAL_ADDRESS type for
physical address.
* ntoskrnl/ps/process (PsInitProcessManagment): Changes to use
PHYSICAL_ADDRESS type for physical address.
* ntoskrnl/ps/thread.c (PsAllocateCallbackStack): Changes to use
PHYSICAL_ADDRESS type for physical address.
2002-06-04 David Welch <welch@cwcom.net>
* Lots of change since the ChangeLog was last updated.
svn path=/trunk/; revision=3000
2002-06-04 15:26:58 +00:00
|
|
|
PHYSICAL_ADDRESS Page;
|
2001-12-31 01:53:46 +00:00
|
|
|
Status = MmRequestPageMemoryConsumer(MC_NPPOOL, TRUE, &Page);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
2003-07-21 21:53:53 +00:00
|
|
|
KEBUGCHECK(0);
|
2001-12-31 01:53:46 +00:00
|
|
|
}
|
2001-11-25 15:21:11 +00:00
|
|
|
Status = MmCreateVirtualMapping(NULL,
|
2003-12-30 18:52:06 +00:00
|
|
|
(char*)KernelStack + (i * PAGE_SIZE),
|
2002-05-14 21:19:21 +00:00
|
|
|
PAGE_EXECUTE_READWRITE,
|
2002-06-04 David Welch <welch@whitehall1-5.seh.ox.ac.uk>
* ntoskrnl/ke/i386/exp.c (KiDoubleFaultHandler): Print CR3
correctly.
2002-06-04 David Welch <welch@whitehall1-5.seh.ox.ac.uk>
* ntoskrnl/include/internal/ps.h: Added KTHREAD_STACK_LIMIT definition.
* ntoskrnl/ke/i386/tskswitch.S (Ki386ContextSwitch): Force all the
pages of the kernel stack to be accessible from this process.
2002-06-04 David Welch <welch@cwcom.net>
* ntoskrnl/cc/view.c (ReadCacheSegmentChain): Changes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/cc/copy.c (CcRosCreateCacheSegment): Changes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/cc/copy.c (CcFreeCachePage): Changes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/include/internal/mm.h: Changed prototypes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/include/internal/ps.h (KPROCESS): Changed type of
page directory base to PHYSICAL_ADDRESS.
* ntoskrnl/include/internal/i386/mm.h: Changed prototypes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/ke/kthread.c (KeFreeStackPage): Changes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/ke/kthread.c (KeInitializeThread): Changes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/ke/process.c (KeAttachProcess, KeDetachProcess): Changes
to use PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/ke/kernel.c (PcrPages, KeApplicationProcessorInit): Changes
to use PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/mm/balance.c (MM_ALLOCATION_REQUEST): Changes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/mm/balance.c (MmReleasePageMemoryConsumer): Changes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/mm/balance.c (MmRequestPageMemoryConsumer): Changes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/mm/cont.c (MmFreeContinuousPage): Changes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/mm/cont.c (MmAllocateContinuousAlignedMemory): Changes to
use PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/mm/freelist.c (MmTransferOwnershipPage,
MmGetLRUFirstUserPage, MmGetLRUNextUserPage, MmGetContinuousPages,
MmInitializePageList, MmSetFlagsPage, MmSetRmapListHeadPage,
MmGetRmapListHeadPage, MmMarkPageMapped, MmMarkPageUnmapped,
MmGetFlagsPage, MmSetSavedSwapEntryPage, MmGetSavedSwapEntryPage,
MmReferencePage, MmGetReferenceCountPage, MmIsUsablePage,
MmDereferencePage, MmGetLockCountPage, MmLockPage, MmUnlockPage,
MmAllocPage): Changes to use PHYSICAL_ADDRESS type for physical
addresses.
* ntoskrnl/mm/iospace.c (MmMapIoSpace): Changes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/mm/kmap.c (ExAllocatePage, MiZeroPage, MiCopyFromUserPage,
ExAllocatePageWithPhysPage): Changes to use PHYSICAL_ADDRESS type for
physical addresses.
* ntoskrnl/mm/marea.c (MmFreeMemoryArea): Changes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/mm/mdl.c (MmUnlockPages, MmMapLockedPages,
MmProbeAndLockPages): Changes to use PHYSICAL_ADDRESS type for
physical addresses.
* ntoskrnl/mm/mm.c (MmSharedDataPagePhysicalAddress,
MmCommitPagedPoolAddress, MmNotPresentFault): Changes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/mm/mminit.c (MmInitVirtualMemory): Changes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/mm/ncache.c (MmAllocateNonCachedMemory,
MmFreeNonCachedPage): Changes to use PHYSICAL_ADDRESS type for
physical addresses.
* ntoskrnl/mm/npool.c (grow_kernel_pool): Changes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/mm/rmap.c (MmPageOutPhysicalAddress, MmInsertRmap,
MmDeleteAllRmaps, MmDeleteRmap): Changes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/mm/section.c (MiReadPage, MmNotPresentFaultSectionView,
MmAccessFaultSectionView, MmPageOutDeleteMapping,
MmPageOutSectionView, MmFreeSectionPage): Changes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/mm/slab.c (ExGrowSlabCache): Changes to use
PHYSICAL_ADDRESS type for physical address.
* ntoskrnl/mm/virtual.c (MmPageOutVirtualMemory,
MmNotPresentFaultVirtualMemory, MmFreeVirtualMemoryPage): Changes to
use PHYSICAL_ADDRESS type for physical address.
* ntoskrnl/mm/wset.c (MmTrimUserMemory): Changes to use
PHYSICAL_ADDRESS type for physical address.
* ntoskrnl/mm/page.c (Mmi386ReleaseMmInfo, MmCopyMmInfo,
MmGetPhysicalAddressForProcess, MmCreateVirtualMapping,
MmCreateVirtualMappingUnsafe, MmCreateVirtualMappingForProcess,
MmDeleteVirtualMapping): Changes to use PHYSICAL_ADDRESS type for
physical address.
* ntoskrnl/ps/process (PsInitProcessManagment): Changes to use
PHYSICAL_ADDRESS type for physical address.
* ntoskrnl/ps/thread.c (PsAllocateCallbackStack): Changes to use
PHYSICAL_ADDRESS type for physical address.
2002-06-04 David Welch <welch@cwcom.net>
* Lots of change since the ChangeLog was last updated.
svn path=/trunk/; revision=3000
2002-06-04 15:26:58 +00:00
|
|
|
Page,
|
2002-01-01 00:21:57 +00:00
|
|
|
TRUE);
|
2001-11-25 15:21:11 +00:00
|
|
|
}
|
2003-12-30 18:52:06 +00:00
|
|
|
Thread->InitialStack = (char*)KernelStack + MM_STACK_SIZE;
|
|
|
|
Thread->StackBase = (char*)KernelStack + MM_STACK_SIZE;
|
|
|
|
Thread->StackLimit = (ULONG)KernelStack;
|
|
|
|
Thread->KernelStack = (char*)KernelStack + MM_STACK_SIZE;
|
2001-11-25 15:21:11 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Thread->InitialStack = (PVOID)&init_stack_top;
|
|
|
|
Thread->StackBase = (PVOID)&init_stack_top;
|
|
|
|
Thread->StackLimit = (ULONG)&init_stack;
|
|
|
|
Thread->KernelStack = (PVOID)&init_stack_top;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The Native API function will initialize the TEB field later
|
|
|
|
*/
|
|
|
|
Thread->Teb = NULL;
|
|
|
|
Thread->TlsArray = NULL;
|
|
|
|
Thread->DebugActive = 0;
|
2002-07-10 15:15:00 +00:00
|
|
|
Thread->State = THREAD_STATE_INITIALIZED;
|
2001-11-25 15:21:11 +00:00
|
|
|
Thread->Alerted[0] = 0;
|
|
|
|
Thread->Alerted[1] = 0;
|
|
|
|
Thread->Iopl = 0;
|
|
|
|
/*
|
|
|
|
* FIXME: Think how this might work
|
|
|
|
*/
|
|
|
|
Thread->NpxState = 0;
|
|
|
|
|
|
|
|
Thread->Saturation = 0;
|
|
|
|
Thread->Priority = 0;
|
|
|
|
InitializeListHead(&Thread->ApcState.ApcListHead[0]);
|
|
|
|
InitializeListHead(&Thread->ApcState.ApcListHead[1]);
|
|
|
|
Thread->ApcState.Process = Process;
|
|
|
|
Thread->ApcState.KernelApcInProgress = 0;
|
|
|
|
Thread->ApcState.KernelApcPending = 0;
|
|
|
|
Thread->ApcState.UserApcPending = 0;
|
|
|
|
Thread->ContextSwitches = 0;
|
|
|
|
Thread->WaitStatus = STATUS_SUCCESS;
|
|
|
|
Thread->WaitIrql = 0;
|
|
|
|
Thread->WaitMode = 0;
|
|
|
|
Thread->WaitNext = 0;
|
|
|
|
Thread->WaitBlockList = NULL;
|
|
|
|
Thread->WaitListEntry.Flink = NULL;
|
|
|
|
Thread->WaitListEntry.Blink = NULL;
|
|
|
|
Thread->WaitTime = 0;
|
|
|
|
Thread->BasePriority = 0;
|
|
|
|
Thread->DecrementCount = 0;
|
|
|
|
Thread->PriorityDecrement = 0;
|
|
|
|
Thread->Quantum = 0;
|
|
|
|
memset(Thread->WaitBlock, 0, sizeof(KWAIT_BLOCK)*4);
|
|
|
|
Thread->LegoData = 0;
|
2003-11-27 01:13:05 +00:00
|
|
|
|
2001-11-25 15:21:11 +00:00
|
|
|
/*
|
|
|
|
* FIXME: Why this?
|
|
|
|
*/
|
2003-11-27 01:13:05 +00:00
|
|
|
// Thread->KernelApcDisable = 1;
|
|
|
|
/*
|
|
|
|
It may be correct to have regular kmode APC disabled
|
|
|
|
until the thread has been fully created, BUT the problem is: they are
|
|
|
|
currently never enabled again! So until somone figures out how
|
|
|
|
this really work, I'm setting regular kmode APC's intially enabled.
|
|
|
|
-Gunnar
|
2003-11-30 19:00:02 +00:00
|
|
|
|
|
|
|
UPDATE: After enabling regular kmode APC's I have experienced random
|
|
|
|
crashes. I'm disabling it again, until we fix the APC implementation...
|
|
|
|
-Gunnar
|
2003-11-27 01:13:05 +00:00
|
|
|
*/
|
|
|
|
|
2003-11-30 19:00:02 +00:00
|
|
|
Thread->KernelApcDisable = -1;
|
|
|
|
|
2003-11-27 01:13:05 +00:00
|
|
|
|
2001-11-25 15:21:11 +00:00
|
|
|
Thread->UserAffinity = Process->Affinity;
|
|
|
|
Thread->SystemAffinityActive = 0;
|
2003-06-16 16:45:52 +00:00
|
|
|
Thread->PowerState = 0;
|
|
|
|
Thread->NpxIrql = 0;
|
|
|
|
Thread->ServiceTable = KeServiceDescriptorTable;
|
2001-11-25 15:21:11 +00:00
|
|
|
Thread->Queue = NULL;
|
|
|
|
KeInitializeSpinLock(&Thread->ApcQueueLock);
|
|
|
|
memset(&Thread->Timer, 0, sizeof(KTIMER));
|
2003-12-30 18:52:06 +00:00
|
|
|
KeInitializeTimer(&Thread->Timer);
|
2001-11-25 15:21:11 +00:00
|
|
|
Thread->QueueListEntry.Flink = NULL;
|
|
|
|
Thread->QueueListEntry.Blink = NULL;
|
|
|
|
Thread->Affinity = Process->Affinity;
|
|
|
|
Thread->Preempted = 0;
|
|
|
|
Thread->ProcessReadyQueue = 0;
|
|
|
|
Thread->KernelStackResident = 1;
|
|
|
|
Thread->NextProcessor = 0;
|
|
|
|
Thread->CallbackStack = NULL;
|
|
|
|
Thread->Win32Thread = 0;
|
|
|
|
Thread->TrapFrame = NULL;
|
2003-11-27 01:13:05 +00:00
|
|
|
Thread->ApcStatePointer[OriginalApcEnvironment] = &Thread->ApcState;
|
|
|
|
Thread->ApcStatePointer[AttachedApcEnvironment] = &Thread->SavedApcState;
|
2001-11-25 15:21:11 +00:00
|
|
|
Thread->EnableStackSwap = 0;
|
|
|
|
Thread->LargeStack = 0;
|
|
|
|
Thread->ResourceIndex = 0;
|
|
|
|
Thread->PreviousMode = KernelMode;
|
|
|
|
Thread->KernelTime = 0;
|
|
|
|
Thread->UserTime = 0;
|
|
|
|
memset(&Thread->SavedApcState, 0, sizeof(KAPC_STATE));
|
2003-11-27 01:13:05 +00:00
|
|
|
|
|
|
|
/* FIXME: is this correct? */
|
2001-11-25 15:21:11 +00:00
|
|
|
Thread->Alertable = 1;
|
2003-11-27 01:13:05 +00:00
|
|
|
|
|
|
|
Thread->ApcStateIndex = OriginalApcEnvironment;
|
|
|
|
|
|
|
|
/* FIXME: not all thread are ApcQueueable! */
|
|
|
|
Thread->ApcQueueable = TRUE;
|
|
|
|
|
2001-11-25 15:21:11 +00:00
|
|
|
Thread->AutoAlignment = 0;
|
|
|
|
KeInitializeApc(&Thread->SuspendApc,
|
|
|
|
Thread,
|
2003-06-16 16:45:52 +00:00
|
|
|
OriginalApcEnvironment,
|
2001-11-25 15:21:11 +00:00
|
|
|
PiSuspendThreadKernelRoutine,
|
|
|
|
PiSuspendThreadRundownRoutine,
|
|
|
|
PiSuspendThreadNormalRoutine,
|
|
|
|
KernelMode,
|
|
|
|
NULL);
|
2002-08-09 17:23:57 +00:00
|
|
|
KeInitializeSemaphore(&Thread->SuspendSemaphore, 0, 128);
|
2001-11-25 15:21:11 +00:00
|
|
|
Thread->ThreadListEntry.Flink = NULL;
|
|
|
|
Thread->ThreadListEntry.Blink = NULL;
|
|
|
|
Thread->FreezeCount = 0;
|
|
|
|
Thread->SuspendCount = 0;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialize ReactOS specific members
|
|
|
|
*/
|
2002-07-17 21:04:57 +00:00
|
|
|
Thread->ProcessThreadListEntry.Flink = NULL;
|
|
|
|
Thread->ProcessThreadListEntry.Blink = NULL;
|
2000-12-10 23:42:01 +00:00
|
|
|
|
2000-10-07 13:41:58 +00:00
|
|
|
/*
|
|
|
|
* Do x86 specific part
|
|
|
|
*/
|
|
|
|
}
|
2000-12-23 02:37:41 +00:00
|
|
|
|
2003-04-06 10:45:16 +00:00
|
|
|
VOID STDCALL
|
|
|
|
KeRescheduleThread()
|
|
|
|
{
|
|
|
|
PsDispatchThread(THREAD_STATE_READY);
|
|
|
|
}
|