Implemented /Device/PhysicalMemory

Corrected an LPC bug when terminating a process with threads waiting for
LPC messages

svn path=/trunk/; revision=1479
This commit is contained in:
David Welch 2000-12-28 03:38:08 +00:00
parent 7f10630ab4
commit 0fc13a01ee
18 changed files with 510 additions and 405 deletions

View file

@ -54,7 +54,7 @@ NET_DEVICE_DRIVERS = ne2000
SYS_APPS = shell winlogon services SYS_APPS = shell winlogon services
APPS = args hello test cat bench apc shm lpc thread event file gditest \ APPS = args hello test cat bench apc shm lpc thread event file gditest \
pteb consume dump_shared_data vmtest regtest pteb consume dump_shared_data vmtest regtest ptest
# objdir # objdir

View file

@ -1,5 +1,5 @@
/* /*
* $Id: fat.c,v 1.7 2000/12/07 16:58:42 jean Exp $ * $Id: fat.c,v 1.8 2000/12/28 03:38:08 dwelch Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -22,7 +22,8 @@
/* FUNCTIONS ****************************************************************/ /* FUNCTIONS ****************************************************************/
ULONG Fat32GetNextCluster(PDEVICE_EXTENSION DeviceExt, ULONG CurrentCluster) ULONG
Fat32GetNextCluster(PDEVICE_EXTENSION DeviceExt, ULONG CurrentCluster)
/* /*
* FUNCTION: Retrieve the next FAT32 cluster from the FAT table via a physical * FUNCTION: Retrieve the next FAT32 cluster from the FAT table via a physical
* disk read * disk read
@ -44,7 +45,8 @@ ULONG Fat32GetNextCluster(PDEVICE_EXTENSION DeviceExt, ULONG CurrentCluster)
return(CurrentCluster); return(CurrentCluster);
} }
ULONG Fat16GetNextCluster(PDEVICE_EXTENSION DeviceExt, ULONG CurrentCluster) ULONG
Fat16GetNextCluster(PDEVICE_EXTENSION DeviceExt, ULONG CurrentCluster)
/* /*
* FUNCTION: Retrieve the next FAT16 cluster from the FAT table from the * FUNCTION: Retrieve the next FAT16 cluster from the FAT table from the
* in-memory FAT * in-memory FAT
@ -59,7 +61,8 @@ ULONG Fat16GetNextCluster(PDEVICE_EXTENSION DeviceExt, ULONG CurrentCluster)
return(CurrentCluster); return(CurrentCluster);
} }
ULONG Fat12GetNextCluster(PDEVICE_EXTENSION DeviceExt, ULONG CurrentCluster) ULONG
Fat12GetNextCluster(PDEVICE_EXTENSION DeviceExt, ULONG CurrentCluster)
/* /*
* FUNCTION: Retrieve the next FAT12 cluster from the FAT table from the * FUNCTION: Retrieve the next FAT12 cluster from the FAT table from the
* in-memory FAT * in-memory FAT
@ -68,26 +71,27 @@ ULONG Fat12GetNextCluster(PDEVICE_EXTENSION DeviceExt, ULONG CurrentCluster)
unsigned char* CBlock; unsigned char* CBlock;
ULONG FATOffset; ULONG FATOffset;
ULONG Entry; ULONG Entry;
CBlock = DeviceExt->FAT; CBlock = DeviceExt->FAT;
FATOffset = (CurrentCluster * 12)/ 8;//first byte containing value FATOffset = (CurrentCluster * 12)/ 8;//first byte containing value
if ((CurrentCluster % 2) == 0) if ((CurrentCluster % 2) == 0)
{ {
Entry = CBlock[FATOffset]; Entry = CBlock[FATOffset];
Entry |= ((CBlock[FATOffset+1] & 0xf)<<8); Entry |= ((CBlock[FATOffset+1] & 0xf)<<8);
} }
else else
{ {
Entry = (CBlock[FATOffset] >> 4); Entry = (CBlock[FATOffset] >> 4);
Entry |= (CBlock[FATOffset+1] << 4); Entry |= (CBlock[FATOffset+1] << 4);
} }
DPRINT("Entry %x\n",Entry); DPRINT("Entry %x\n",Entry);
if (Entry >= 0xff8 && Entry <= 0xfff) if (Entry >= 0xff8 && Entry <= 0xfff)
Entry = 0xffffffff; Entry = 0xffffffff;
DPRINT("Returning %x\n",Entry); DPRINT("Returning %x\n",Entry);
return(Entry); return(Entry);
} }
ULONG GetNextCluster(PDEVICE_EXTENSION DeviceExt, ULONG CurrentCluster) ULONG
GetNextCluster(PDEVICE_EXTENSION DeviceExt, ULONG CurrentCluster)
/* /*
* FUNCTION: Retrieve the next cluster depending on the FAT type * FUNCTION: Retrieve the next cluster depending on the FAT type
*/ */
@ -95,21 +99,21 @@ ULONG GetNextCluster(PDEVICE_EXTENSION DeviceExt, ULONG CurrentCluster)
ULONG NextCluster; ULONG NextCluster;
DPRINT("GetNextCluster(DeviceExt %x, CurrentCluster %x)\n", DPRINT("GetNextCluster(DeviceExt %x, CurrentCluster %x)\n",
DeviceExt,CurrentCluster); DeviceExt,CurrentCluster);
ExAcquireResourceSharedLite(&DeviceExt->FatResource, TRUE); ExAcquireResourceSharedLite(&DeviceExt->FatResource, TRUE);
if (DeviceExt->FatType == FAT16) if (DeviceExt->FatType == FAT16)
{ {
NextCluster = Fat16GetNextCluster(DeviceExt, CurrentCluster); NextCluster = Fat16GetNextCluster(DeviceExt, CurrentCluster);
} }
else if (DeviceExt->FatType == FAT32) else if (DeviceExt->FatType == FAT32)
{ {
NextCluster = Fat32GetNextCluster(DeviceExt, CurrentCluster); NextCluster = Fat32GetNextCluster(DeviceExt, CurrentCluster);
} }
else else
{ {
NextCluster = Fat12GetNextCluster(DeviceExt, CurrentCluster); NextCluster = Fat12GetNextCluster(DeviceExt, CurrentCluster);
} }
ExReleaseResourceLite(&DeviceExt->FatResource); ExReleaseResourceLite(&DeviceExt->FatResource);
@ -117,7 +121,8 @@ ULONG GetNextCluster(PDEVICE_EXTENSION DeviceExt, ULONG CurrentCluster)
return(NextCluster); return(NextCluster);
} }
ULONG FAT16FindAvailableCluster(PDEVICE_EXTENSION DeviceExt) ULONG
FAT16FindAvailableCluster(PDEVICE_EXTENSION DeviceExt)
/* /*
* FUNCTION: Finds the first available cluster in a FAT16 table * FUNCTION: Finds the first available cluster in a FAT16 table
*/ */
@ -132,7 +137,8 @@ ULONG FAT16FindAvailableCluster(PDEVICE_EXTENSION DeviceExt)
return 0; return 0;
} }
ULONG FAT12FindAvailableCluster(PDEVICE_EXTENSION DeviceExt) ULONG
FAT12FindAvailableCluster(PDEVICE_EXTENSION DeviceExt)
/* /*
* FUNCTION: Finds the first available cluster in a FAT12 table * FUNCTION: Finds the first available cluster in a FAT12 table
*/ */
@ -162,7 +168,8 @@ ULONG FAT12FindAvailableCluster(PDEVICE_EXTENSION DeviceExt)
return 0; return 0;
} }
ULONG FAT32FindAvailableCluster(PDEVICE_EXTENSION DeviceExt) ULONG
FAT32FindAvailableCluster(PDEVICE_EXTENSION DeviceExt)
/* /*
* FUNCTION: Finds the first available cluster in a FAT32 table * FUNCTION: Finds the first available cluster in a FAT32 table
*/ */
@ -192,7 +199,8 @@ ULONG FAT32FindAvailableCluster(PDEVICE_EXTENSION DeviceExt)
return 0; return 0;
} }
ULONG FAT12CountAvailableClusters(PDEVICE_EXTENSION DeviceExt) ULONG
FAT12CountAvailableClusters(PDEVICE_EXTENSION DeviceExt)
/* /*
* FUNCTION: Counts free cluster in a FAT12 table * FUNCTION: Counts free cluster in a FAT12 table
*/ */
@ -227,7 +235,8 @@ ULONG FAT12CountAvailableClusters(PDEVICE_EXTENSION DeviceExt)
return ulCount; return ulCount;
} }
ULONG FAT16CountAvailableClusters(PDEVICE_EXTENSION DeviceExt) ULONG
FAT16CountAvailableClusters(PDEVICE_EXTENSION DeviceExt)
/* /*
* FUNCTION: Counts free clusters in a FAT16 table * FUNCTION: Counts free clusters in a FAT16 table
*/ */
@ -250,7 +259,8 @@ ULONG FAT16CountAvailableClusters(PDEVICE_EXTENSION DeviceExt)
return ulCount; return ulCount;
} }
ULONG FAT32CountAvailableClusters(PDEVICE_EXTENSION DeviceExt) ULONG
FAT32CountAvailableClusters(PDEVICE_EXTENSION DeviceExt)
/* /*
* FUNCTION: Counts free clusters in a FAT32 table * FUNCTION: Counts free clusters in a FAT32 table
*/ */
@ -282,8 +292,9 @@ ULONG FAT32CountAvailableClusters(PDEVICE_EXTENSION DeviceExt)
return ulCount; return ulCount;
} }
void FAT12WriteCluster(PDEVICE_EXTENSION DeviceExt, ULONG ClusterToWrite, VOID
ULONG NewValue) FAT12WriteCluster(PDEVICE_EXTENSION DeviceExt, ULONG ClusterToWrite,
ULONG NewValue)
/* /*
* FUNCTION: Writes a cluster to the FAT12 physical and in-memory tables * FUNCTION: Writes a cluster to the FAT12 physical and in-memory tables
*/ */
@ -330,8 +341,9 @@ void FAT12WriteCluster(PDEVICE_EXTENSION DeviceExt, ULONG ClusterToWrite,
} }
} }
void FAT16WriteCluster(PDEVICE_EXTENSION DeviceExt, ULONG ClusterToWrite, VOID
ULONG NewValue) FAT16WriteCluster(PDEVICE_EXTENSION DeviceExt, ULONG ClusterToWrite,
ULONG NewValue)
/* /*
* FUNCTION: Writes a cluster to the FAT16 physical and in-memory tables * FUNCTION: Writes a cluster to the FAT16 physical and in-memory tables
*/ */
@ -361,8 +373,9 @@ void FAT16WriteCluster(PDEVICE_EXTENSION DeviceExt, ULONG ClusterToWrite,
} }
} }
void FAT32WriteCluster(PDEVICE_EXTENSION DeviceExt, ULONG ClusterToWrite, VOID
ULONG NewValue) FAT32WriteCluster(PDEVICE_EXTENSION DeviceExt, ULONG ClusterToWrite,
ULONG NewValue)
/* /*
* FUNCTION: Writes a cluster to the FAT32 physical tables * FUNCTION: Writes a cluster to the FAT32 physical tables
*/ */
@ -397,8 +410,9 @@ DbgPrint("FAT32WriteCluster %u : %u\n",ClusterToWrite,NewValue);
ExFreePool(Block); ExFreePool(Block);
} }
void WriteCluster(PDEVICE_EXTENSION DeviceExt, ULONG ClusterToWrite, VOID
ULONG NewValue) WriteCluster(PDEVICE_EXTENSION DeviceExt, ULONG ClusterToWrite,
ULONG NewValue)
/* /*
* FUNCTION: Write a changed FAT entry * FUNCTION: Write a changed FAT entry
*/ */
@ -417,7 +431,8 @@ void WriteCluster(PDEVICE_EXTENSION DeviceExt, ULONG ClusterToWrite,
} }
} }
ULONG GetNextWriteCluster(PDEVICE_EXTENSION DeviceExt, ULONG CurrentCluster) ULONG
GetNextWriteCluster(PDEVICE_EXTENSION DeviceExt, ULONG CurrentCluster)
/* /*
* FUNCTION: Determines the next cluster to be written * FUNCTION: Determines the next cluster to be written
*/ */
@ -474,8 +489,9 @@ ULONG GetNextWriteCluster(PDEVICE_EXTENSION DeviceExt, ULONG CurrentCluster)
} }
} }
ULONG ClusterToSector(PDEVICE_EXTENSION DeviceExt, ULONG
unsigned long Cluster) ClusterToSector(PDEVICE_EXTENSION DeviceExt,
unsigned long Cluster)
/* /*
* FUNCTION: Converts the cluster number to a sector number for this physical * FUNCTION: Converts the cluster number to a sector number for this physical
* device * device
@ -484,7 +500,8 @@ ULONG ClusterToSector(PDEVICE_EXTENSION DeviceExt,
return DeviceExt->dataStart+((Cluster-2)*DeviceExt->Boot->SectorsPerCluster); return DeviceExt->dataStart+((Cluster-2)*DeviceExt->Boot->SectorsPerCluster);
} }
void VFATLoadCluster(PDEVICE_EXTENSION DeviceExt, PVOID Buffer, ULONG Cluster) VOID
VFATLoadCluster(PDEVICE_EXTENSION DeviceExt, PVOID Buffer, ULONG Cluster)
/* /*
* FUNCTION: Load a cluster from the physical device * FUNCTION: Load a cluster from the physical device
*/ */
@ -503,7 +520,8 @@ void VFATLoadCluster(PDEVICE_EXTENSION DeviceExt, PVOID Buffer, ULONG Cluster)
DPRINT("Finished VFATReadSectors\n"); DPRINT("Finished VFATReadSectors\n");
} }
void VFATWriteCluster(PDEVICE_EXTENSION DeviceExt, PVOID Buffer, ULONG Cluster) VOID
VFATWriteCluster(PDEVICE_EXTENSION DeviceExt, PVOID Buffer, ULONG Cluster)
/* /*
* FUNCTION: Write a cluster to the physical device * FUNCTION: Write a cluster to the physical device
*/ */

View file

@ -24,7 +24,7 @@ cp apps/cat/cat.exe $1/reactos/bin
cp subsys/smss/smss.exe $1/reactos/system32 cp subsys/smss/smss.exe $1/reactos/system32
cp subsys/csrss/csrss.exe $1/reactos/system32 cp subsys/csrss/csrss.exe $1/reactos/system32
cp subsys/win32k/win32k.sys $1/reactos/system32/drivers cp subsys/win32k/win32k.sys $1/reactos/system32/drivers
#cp apps/system/winlogon/winlogon.exe $1/reactos/system32/ cp apps/system/winlogon/winlogon.exe $1/reactos/system32/
cp apps/apc/apc.exe $1/reactos/bin cp apps/apc/apc.exe $1/reactos/bin
cp apps/shm/shmsrv.exe $1/reactos/bin cp apps/shm/shmsrv.exe $1/reactos/bin
cp apps/shm/shmclt.exe $1/reactos/bin cp apps/shm/shmclt.exe $1/reactos/bin
@ -40,3 +40,4 @@ cp apps/dump_shared_data/dump_shared_data.exe $1/reactos/bin
cp apps/vmtest/vmtest.exe $1/reactos/bin cp apps/vmtest/vmtest.exe $1/reactos/bin
cp apps/uitest/uitest.exe $1/reactos/bin/ cp apps/uitest/uitest.exe $1/reactos/bin/
cp apps/gditest/gditest.exe $1/reactos/bin/ cp apps/gditest/gditest.exe $1/reactos/bin/
cp apps/ptest/ptest.exe $1/reactos/bin

View file

@ -1,25 +0,0 @@
%macro DECLARE_EXTERNAL_SYMBOL 1
%ifdef coff
extern _%1
%elifdef win32
extern _%1
%elifdef elf
extern %1
_%1:
call %1
ret
%endif
%endmacro
%macro DECLARE_GLOBAL_SYMBOL 1
%ifdef coff
global _%1
_%1:
%elifdef win32
global _%1
_%1:
%elifdef elf
global %1
%1:
%endif
%endmacro

View file

@ -1,10 +1,7 @@
#ifndef __INCLUDE_INTERNAL_CC_H #ifndef __INCLUDE_INTERNAL_CC_H
#define __INCLUDE_INTERNAL_CCS_H #define __INCLUDE_INTERNAL_CCS_H
/* $Id: cc.h,v 1.1 2000/06/29 23:35:36 dwelch Exp $ */ /* $Id: cc.h,v 1.2 2000/12/28 03:38:07 dwelch Exp $ */
VOID VOID STDCALL
STDCALL CcMdlReadCompleteDev (IN PMDL MdlChain,
CcMdlReadCompleteDev ( IN PDEVICE_OBJECT DeviceObject);
IN PMDL MdlChain,
IN PDEVICE_OBJECT DeviceObject
);
#endif #endif

View file

@ -4,7 +4,8 @@
#include <napi/dbg.h> #include <napi/dbg.h>
#include <internal/port.h> #include <internal/port.h>
NTSTATUS STDCALL LpcSendDebugMessagePort(PEPORT Port, NTSTATUS STDCALL
PLPC_DBG_MESSAGE Message); LpcSendDebugMessagePort(PEPORT Port,
PLPC_DBG_MESSAGE Message);
#endif /* __INCLUDE_INTERNAL_DBG_H */ #endif /* __INCLUDE_INTERNAL_DBG_H */

View file

@ -2,8 +2,8 @@
* internal executive prototypes * internal executive prototypes
*/ */
#ifndef _INCLUDE_INTERNAL_EXECUTIVE_H #ifndef __NTOSKRNL_INCLUDE_INTERNAL_EXECUTIVE_H
#define _INCLUDE_INTERNAL_EXECUTIVE_H #define __NTOSKRNL_INCLUDE_INTERNAL_EXECUTIVE_H
#include <ddk/ntddk.h> #include <ddk/ntddk.h>
#include <ntos/time.h> #include <ntos/time.h>
@ -14,10 +14,13 @@ TIME_ZONE_INFORMATION SystemTimeZoneInfo;
/* INITIALIZATION FUNCTIONS *************************************************/ /* INITIALIZATION FUNCTIONS *************************************************/
VOID ExInit (VOID); VOID
VOID ExInitTimeZoneInfo (VOID); ExInit (VOID);
VOID ExInitializeWorkerThreads(VOID); VOID
ExInitTimeZoneInfo (VOID);
VOID
ExInitializeWorkerThreads(VOID);
#endif /* _INCLUDE_INTERNAL_EXECUTIVE_H */ #endif /* __NTOSKRNL_INCLUDE_INTERNAL_EXECUTIVE_H */

View file

@ -20,27 +20,26 @@
* FILE: ntoskrnl/include/internal/i386/segment.h * FILE: ntoskrnl/include/internal/i386/segment.h
* PURPOSE: Segment selector definitions * PURPOSE: Segment selector definitions
* PROGRAMMER: David Welch (welch@cwcom.net) * PROGRAMMER: David Welch (welch@cwcom.net)
* UPDATE HISTORY:
* Created ??/??/??
*/ */
/* INCLUDES *****************************************************************/ /* INCLUDES *****************************************************************/
#ifndef __INCLUDE_INTERNAL_I386_SEGMENT_H #ifndef __NTOSKRNL_INCLUDE_INTERNAL_I386_SEGMENT_H
#define __INCLUDE_INTERNAL_i386_SEGMENT_H #define __NTOSKRNL_INCLUDE_INTERNAL_i386_SEGMENT_H
#define NULL_SELECTOR (0x0) #define NULL_SELECTOR (0x0)
#define KERNEL_CS (0x8) #define KERNEL_CS (0x8)
#define KERNEL_DS (0x10) #define KERNEL_DS (0x10)
#define USER_CS (0x18 + 0x3) #define USER_CS (0x18 + 0x3)
#define USER_DS (0x20 + 0x3) #define USER_DS (0x20 + 0x3)
/* /* Task State Segment */
* FIXME: We actually have one TSS per thread
*/
#define TSS_SELECTOR (0x28) #define TSS_SELECTOR (0x28)
/* Processor Control Region */
#define PCR_SELECTOR (0x30) #define PCR_SELECTOR (0x30)
/* Thread Environment Block */
#define TEB_SELECTOR (0x38 + 0x3) #define TEB_SELECTOR (0x38 + 0x3)
#define RESERVED1_SELECTOR (0x40) #define RESERVED_SELECTOR (0x40)
/* Local Descriptor Table */
#define LDT_SELECTOR (0x48) #define LDT_SELECTOR (0x48)
#endif /* __INCLUDE_INTERNAL_I386_SEGMENT_H */ #endif /* __NTOSKRNL_INCLUDE_INTERNAL_I386_SEGMENT_H */

View file

@ -1,4 +1,22 @@
/* $Id: io.h,v 1.6 2000/10/05 19:12:55 ekohl Exp $ /*
* ReactOS kernel
* Copyright (C) 2000 David Welch <welch@cwcom.net>
*
* 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.
*/
/* $Id: io.h,v 1.7 2000/12/28 03:38:07 dwelch Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -9,8 +27,8 @@
* 28/05/97: Created * 28/05/97: Created
*/ */
#ifndef __INCLUDE_INTERNAL_IO_H #ifndef __NTOSKRNL_INCLUDE_INTERNAL_IO_H
#define __INCLUDE_INTERNAL_IO_H #define __NTOSKRNL_INCLUDE_INTERNAL_IO_H
#include <ddk/ntddk.h> #include <ddk/ntddk.h>
#include <internal/ob.h> #include <internal/ob.h>
@ -23,14 +41,17 @@ extern POBJECT_TYPE IoSymbolicLinkType;
* entry = pointer to the driver initialization routine * entry = pointer to the driver initialization routine
* RETURNS: Success or failure * RETURNS: Success or failure
*/ */
NTSTATUS IoInitializeDriver(PDRIVER_INITIALIZE DriverEntry); NTSTATUS
IoInitializeDriver(PDRIVER_INITIALIZE DriverEntry);
VOID
IoInitCancelHandling(VOID);
VOID IoInitCancelHandling(VOID); VOID
VOID IoInitSymbolicLinkImplementation(VOID); IoInitSymbolicLinkImplementation(VOID);
VOID IoInitFileSystemImplementation(VOID); VOID
VOID IoInitVpbImplementation (VOID); IoInitFileSystemImplementation(VOID);
VOID
IoInitVpbImplementation (VOID);
NTSTATUS IoTryToMountStorageDevice(PDEVICE_OBJECT DeviceObject); NTSTATUS IoTryToMountStorageDevice(PDEVICE_OBJECT DeviceObject);
POBJECT IoOpenSymlink(POBJECT SymbolicLink); POBJECT IoOpenSymlink(POBJECT SymbolicLink);

View file

@ -1,4 +1,4 @@
/* $Id: kd.h,v 1.1 2000/06/29 23:35:36 dwelch Exp $ /* $Id: kd.h,v 1.2 2000/12/28 03:38:07 dwelch Exp $
* *
* kernel debugger prototypes * kernel debugger prototypes
*/ */
@ -6,8 +6,7 @@
#ifndef __INCLUDE_INTERNAL_KERNEL_DEBUGGER_H #ifndef __INCLUDE_INTERNAL_KERNEL_DEBUGGER_H
#define __INCLUDE_INTERNAL_KERNEL_DEBUGGER_H #define __INCLUDE_INTERNAL_KERNEL_DEBUGGER_H
ULONG
ULONG KdpPrintString (PANSI_STRING String); KdpPrintString (PANSI_STRING String);
#endif /* __INCLUDE_INTERNAL_KERNEL_DEBUGGER_H */ #endif /* __INCLUDE_INTERNAL_KERNEL_DEBUGGER_H */

View file

@ -1,9 +1,24 @@
/* /*
* Various useful prototypes * ReactOS kernel
* Copyright (C) 2000 David Welch <welch@cwcom.net>
*
* 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.
*/ */
#ifndef __INCLUDE_INTERNAL_KERNEL_H #ifndef __NTOSKRNL_INCLUDE_INTERNAL_KERNEL_H
#define __INCLUDE_INTERNAL_KERNEL_H #define __NTOSKRNL_INCLUDE_INTERNAL_KERNEL_H
/* INCLUDES *****************************************************************/ /* INCLUDES *****************************************************************/

View file

@ -42,6 +42,8 @@ enum
#define SPE_DIRTY (0x8) #define SPE_DIRTY (0x8)
#define SPE_IN_PAGEFILE (0x10) #define SPE_IN_PAGEFILE (0x10)
#define SO_PHYSICAL_MEMORY (0x1)
typedef struct typedef struct
{ {
ULONG Pages[NR_SECTION_PAGE_ENTRIES]; ULONG Pages[NR_SECTION_PAGE_ENTRIES];
@ -54,16 +56,17 @@ typedef struct
typedef struct typedef struct
{ {
CSHORT Type; CSHORT Type;
CSHORT Size; CSHORT Size;
LARGE_INTEGER MaximumSize; LARGE_INTEGER MaximumSize;
ULONG SectionPageProtection; ULONG SectionPageProtection;
ULONG AllocateAttributes; ULONG AllocateAttributes;
PFILE_OBJECT FileObject; PFILE_OBJECT FileObject;
LIST_ENTRY ViewListHead; LIST_ENTRY ViewListHead;
KSPIN_LOCK ViewListLock; KSPIN_LOCK ViewListLock;
KMUTEX Lock; KMUTEX Lock;
SECTION_PAGE_DIRECTORY PageDirectory; SECTION_PAGE_DIRECTORY PageDirectory;
ULONG Flags;
} SECTION_OBJECT, *PSECTION_OBJECT; } SECTION_OBJECT, *PSECTION_OBJECT;
typedef struct typedef struct
@ -299,6 +302,8 @@ VOID MmUnlockPage(PVOID PhysicalPage);
NTSTATUS MmSafeCopyFromUser(PVOID Dest, PVOID Src, ULONG Count); NTSTATUS MmSafeCopyFromUser(PVOID Dest, PVOID Src, ULONG Count);
NTSTATUS MmSafeCopyToUser(PVOID Dest, PVOID Src, ULONG Count); NTSTATUS MmSafeCopyToUser(PVOID Dest, PVOID Src, ULONG Count);
NTSTATUS
MmCreatePhysicalMemorySection(VOID);
#define MM_PHYSICAL_PAGE_MPW_PENDING (0x8) #define MM_PHYSICAL_PAGE_MPW_PENDING (0x8)

View file

@ -34,9 +34,7 @@
/* GLOBALS *******************************************************************/ /* GLOBALS *******************************************************************/
#define NR_TASKS 128 USHORT KiGdt[10 * 4] =
USHORT KiGdt[(8 + NR_TASKS) * 4] =
{ {
0x0, 0x0, 0x0, 0x0, /* Null */ 0x0, 0x0, 0x0, 0x0, /* Null */
0xffff, 0x0, 0x9a00, 0xcf, /* Kernel CS */ 0xffff, 0x0, 0x9a00, 0xcf, /* Kernel CS */
@ -53,8 +51,9 @@ static KSPIN_LOCK GdtLock;
/* FUNCTIONS *****************************************************************/ /* FUNCTIONS *****************************************************************/
VOID KeSetBaseGdtSelector(ULONG Entry, VOID
PVOID Base) KeSetBaseGdtSelector(ULONG Entry,
PVOID Base)
{ {
KIRQL oldIrql; KIRQL oldIrql;
@ -84,7 +83,8 @@ VOID KeSetBaseGdtSelector(ULONG Entry,
KeReleaseSpinLock(&GdtLock, oldIrql); KeReleaseSpinLock(&GdtLock, oldIrql);
} }
VOID KeDumpGdtSelector(ULONG Entry) VOID
KeDumpGdtSelector(ULONG Entry)
{ {
USHORT a, b, c, d; USHORT a, b, c, d;
ULONG RawLimit; ULONG RawLimit;
@ -143,7 +143,8 @@ VOID KeFreeGdtSelector(ULONG Entry)
#endif #endif
#if 0 #if 0
ULONG KeAllocateGdtSelector(ULONG Desc[2]) ULONG
KeAllocateGdtSelector(ULONG Desc[2])
/* /*
* FUNCTION: Allocate a gdt selector * FUNCTION: Allocate a gdt selector
* ARGUMENTS: * ARGUMENTS:

View file

@ -3,8 +3,6 @@
#define KERNEL_BASE (0xc0000000) #define KERNEL_BASE (0xc0000000)
#define NR_TASKS (128)
#define MULTIBOOT_HEADER_MAGIC (0x1BADB002) #define MULTIBOOT_HEADER_MAGIC (0x1BADB002)
#define MULTIBOOT_HEADER_FLAGS (0x00010003) #define MULTIBOOT_HEADER_FLAGS (0x00010003)
@ -708,7 +706,7 @@ lowmem_pagetable:
.long 0x3f8007,0x3f9007,0x3fa007,0x3fb007,0x3fc007,0x3fd007,0x3fe007,0x3ff007 .long 0x3f8007,0x3f9007,0x3fa007,0x3fb007,0x3fc007,0x3fd007,0x3fe007,0x3ff007
_gdt_descr: _gdt_descr:
.word ((8+NR_TASKS)*8)-1 .word (10*8)-1
.long _KiGdt .long _KiGdt
_idt_descr: _idt_descr:

View file

@ -1,4 +1,4 @@
/* $Id: queue.c,v 1.2 2000/10/22 16:36:51 ekohl Exp $ /* $Id: queue.c,v 1.3 2000/12/28 03:38:07 dwelch Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -20,67 +20,59 @@
#include <internal/debug.h> #include <internal/debug.h>
VOID VOID STDCALL
STDCALL EiEnqueueMessagePort (IN OUT PEPORT Port,
EiEnqueueMessagePort ( IN PQUEUEDMESSAGE Message)
IN OUT PEPORT Port,
IN PQUEUEDMESSAGE Message
)
{ {
InsertTailList ( InsertTailList (&Port->QueueListHead,
& Port->QueueListHead, &Message->QueueListEntry);
& Message->QueueListEntry Port->QueueLength++;
);
Port->QueueLength++;
} }
PQUEUEDMESSAGE PQUEUEDMESSAGE STDCALL
STDCALL EiDequeueMessagePort (IN OUT PEPORT Port)
EiDequeueMessagePort (
IN OUT PEPORT Port
)
{ {
PQUEUEDMESSAGE Message; PQUEUEDMESSAGE Message;
PLIST_ENTRY entry; PLIST_ENTRY entry;
entry = RemoveHeadList (& Port->QueueListHead); if (IsListEmpty(&Port->QueueListHead))
Message = CONTAINING_RECORD (entry, QUEUEDMESSAGE, QueueListEntry); {
Port->QueueLength--; return(NULL);
}
entry = RemoveHeadList (&Port->QueueListHead);
Message = CONTAINING_RECORD (entry, QUEUEDMESSAGE, QueueListEntry);
Port->QueueLength--;
return (Message); return (Message);
} }
VOID VOID STDCALL
STDCALL EiEnqueueConnectMessagePort (IN OUT PEPORT Port,
EiEnqueueConnectMessagePort ( IN PQUEUEDMESSAGE Message)
IN OUT PEPORT Port,
IN PQUEUEDMESSAGE Message
)
{ {
InsertTailList ( InsertTailList (&Port->ConnectQueueListHead,
& Port->ConnectQueueListHead, &Message->QueueListEntry);
& Message->QueueListEntry Port->ConnectQueueLength++;
);
Port->ConnectQueueLength++;
} }
PQUEUEDMESSAGE PQUEUEDMESSAGE STDCALL
STDCALL EiDequeueConnectMessagePort (IN OUT PEPORT Port)
EiDequeueConnectMessagePort (
IN OUT PEPORT Port
)
{ {
PQUEUEDMESSAGE Message; PQUEUEDMESSAGE Message;
PLIST_ENTRY entry; PLIST_ENTRY entry;
entry = RemoveHeadList (& Port->ConnectQueueListHead); if (IsListEmpty(&Port->ConnectQueueListHead))
Message = CONTAINING_RECORD (entry, QUEUEDMESSAGE, QueueListEntry); {
Port->ConnectQueueLength--; return(NULL);
}
entry = RemoveHeadList (&Port->ConnectQueueListHead);
Message = CONTAINING_RECORD (entry, QUEUEDMESSAGE, QueueListEntry);
Port->ConnectQueueLength--;
return (Message); return (Message);
} }

View file

@ -1,4 +1,4 @@
/* $Id: reply.c,v 1.2 2000/10/22 16:36:51 ekohl Exp $ /* $Id: reply.c,v 1.3 2000/12/28 03:38:07 dwelch Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -9,7 +9,7 @@
* Created 22/05/98 * Created 22/05/98
*/ */
/* INCLUDES *****************************************************************/ /* INCLUDES ******************************************************************/
#include <ddk/ntddk.h> #include <ddk/ntddk.h>
#include <internal/ob.h> #include <internal/ob.h>
@ -19,7 +19,7 @@
#define NDEBUG #define NDEBUG
#include <internal/debug.h> #include <internal/debug.h>
/* FUNCTIONS *****************************************************************/
/********************************************************************** /**********************************************************************
* NAME * NAME
@ -33,14 +33,11 @@
* REVISIONS * REVISIONS
* *
*/ */
NTSTATUS NTSTATUS STDCALL
STDCALL EiReplyOrRequestPort (IN PEPORT Port,
EiReplyOrRequestPort ( IN PLPC_MESSAGE LpcReply,
IN PEPORT Port, IN ULONG MessageType,
IN PLPC_MESSAGE LpcReply, IN PEPORT Sender)
IN ULONG MessageType,
IN PEPORT Sender
)
{ {
KIRQL oldIrql; KIRQL oldIrql;
PQUEUEDMESSAGE MessageReply; PQUEUEDMESSAGE MessageReply;
@ -78,12 +75,9 @@ EiReplyOrRequestPort (
* REVISIONS * REVISIONS
* *
*/ */
NTSTATUS NTSTATUS STDCALL
STDCALL NtReplyPort (IN HANDLE PortHandle,
NtReplyPort ( IN PLPC_MESSAGE LpcReply)
IN HANDLE PortHandle,
IN PLPC_MESSAGE LpcReply
)
{ {
NTSTATUS Status; NTSTATUS Status;
PEPORT Port; PEPORT Port;
@ -126,14 +120,11 @@ NtReplyPort (
* REVISIONS * REVISIONS
* *
*/ */
NTSTATUS NTSTATUS STDCALL
STDCALL NtReplyWaitReceivePort (HANDLE PortHandle,
NtReplyWaitReceivePort ( PULONG PortId,
HANDLE PortHandle, PLPC_MESSAGE LpcReply,
PULONG PortId, PLPC_MESSAGE LpcMessage)
PLPC_MESSAGE LpcReply,
PLPC_MESSAGE LpcMessage
)
{ {
NTSTATUS Status; NTSTATUS Status;
PEPORT Port; PEPORT Port;
@ -176,33 +167,49 @@ NtReplyWaitReceivePort (
/* /*
* Want for a message to be received * Want for a message to be received
*/ */
DPRINT("Entering wait for message\n"); do
KeWaitForSingleObject(&Port->Event, {
UserRequest, Status = KeWaitForSingleObject(&Port->Event,
UserMode, UserRequest,
FALSE, UserMode,
NULL); FALSE,
DPRINT("Woke from wait for message\n"); NULL);
if (!NT_SUCCESS(Status))
{
return(Status);
}
/*
* Dequeue the message
*/
KeAcquireSpinLock(&Port->Lock, &oldIrql);
Request = EiDequeueMessagePort(Port);
/*
* There is a race between the event being set and the port being
* taken in which another thread may dequeue the same request so
* we may need to loop.
*/
if (Request == NULL)
{
KeReleaseSpinLock(&Port->Lock, oldIrql);
}
} while(Request == NULL);
/*
* Dequeue the message
*/
KeAcquireSpinLock(&Port->Lock, &oldIrql);
Request = EiDequeueMessagePort(Port);
memcpy(LpcMessage, &Request->Message, Request->Message.MessageSize); memcpy(LpcMessage, &Request->Message, Request->Message.MessageSize);
if (Request->Message.MessageType == LPC_CONNECTION_REQUEST) if (Request->Message.MessageType == LPC_CONNECTION_REQUEST)
{ {
EiEnqueueConnectMessagePort(Port, Request); EiEnqueueConnectMessagePort(Port, Request);
KeReleaseSpinLock(&Port->Lock, oldIrql); KeReleaseSpinLock(&Port->Lock, oldIrql);
} }
else else
{ {
KeReleaseSpinLock(&Port->Lock, oldIrql); KeReleaseSpinLock(&Port->Lock, oldIrql);
ExFreePool(Request); ExFreePool(Request);
} }
/* /*
* * Dereference the port
*/ */
ObDereferenceObject(Port); ObDereferenceObject(Port);
return(STATUS_SUCCESS); return(STATUS_SUCCESS);
@ -221,14 +228,11 @@ NtReplyWaitReceivePort (
* REVISIONS * REVISIONS
* *
*/ */
NTSTATUS NTSTATUS STDCALL
STDCALL NtReplyWaitReplyPort (HANDLE PortHandle,
NtReplyWaitReplyPort ( PLPC_MESSAGE ReplyMessage)
HANDLE PortHandle,
PLPC_MESSAGE ReplyMessage
)
{ {
UNIMPLEMENTED; UNIMPLEMENTED;
} }

View file

@ -1,4 +1,4 @@
/* $Id: mminit.c,v 1.11 2000/12/20 18:44:20 jean Exp $ /* $Id: mminit.c,v 1.12 2000/12/28 03:38:07 dwelch Exp $
* *
* COPYRIGHT: See COPYING in the top directory * COPYRIGHT: See COPYING in the top directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -273,6 +273,8 @@ VOID MmInit2(VOID)
VOID MmInit3(VOID) VOID MmInit3(VOID)
{ {
MmInitPagerThread(); MmInitPagerThread();
MmCreatePhysicalMemorySection();
/* FIXME: Read parameters from memory */ /* FIXME: Read parameters from memory */
} }

View file

@ -1,4 +1,4 @@
/* $Id: section.c,v 1.39 2000/10/22 16:36:52 ekohl Exp $ /* $Id: section.c,v 1.40 2000/12/28 03:38:07 dwelch Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -43,14 +43,16 @@ VOID MmLockSection(PSECTION_OBJECT Section)
NULL); NULL);
} }
VOID MmUnlockSection(PSECTION_OBJECT Section) VOID
MmUnlockSection(PSECTION_OBJECT Section)
{ {
KeReleaseMutex(&Section->Lock, FALSE); KeReleaseMutex(&Section->Lock, FALSE);
} }
VOID MmSetPageEntrySection(PSECTION_OBJECT Section, VOID
ULONG Offset, MmSetPageEntrySection(PSECTION_OBJECT Section,
ULONG Entry) ULONG Offset,
ULONG Entry)
{ {
PSECTION_PAGE_TABLE Table; PSECTION_PAGE_TABLE Table;
ULONG DirectoryOffset; ULONG DirectoryOffset;
@ -70,8 +72,9 @@ VOID MmSetPageEntrySection(PSECTION_OBJECT Section,
Table->Pages[TableOffset] = Entry; Table->Pages[TableOffset] = Entry;
} }
ULONG MmGetPageEntrySection(PSECTION_OBJECT Section, ULONG
ULONG Offset) MmGetPageEntrySection(PSECTION_OBJECT Section,
ULONG Offset)
{ {
PSECTION_PAGE_TABLE Table; PSECTION_PAGE_TABLE Table;
ULONG Entry; ULONG Entry;
@ -92,9 +95,10 @@ ULONG MmGetPageEntrySection(PSECTION_OBJECT Section,
return(Entry); return(Entry);
} }
NTSTATUS MmUnalignedLoadPageForSection(PMADDRESS_SPACE AddressSpace, NTSTATUS
MEMORY_AREA* MemoryArea, MmUnalignedLoadPageForSection(PMADDRESS_SPACE AddressSpace,
PVOID Address) MEMORY_AREA* MemoryArea,
PVOID Address)
{ {
LARGE_INTEGER Offset; LARGE_INTEGER Offset;
IO_STATUS_BLOCK IoStatus; IO_STATUS_BLOCK IoStatus;
@ -128,6 +132,15 @@ NTSTATUS MmUnalignedLoadPageForSection(PMADDRESS_SPACE AddressSpace,
MmLockSection(Section); MmLockSection(Section);
/*
* Don't do an unaligned mapping of physical memory
*/
if (Section->Flags & SO_PHYSICAL_MEMORY)
{
MmUnlockSection(Section);
return(STATUS_UNSUCCESSFUL);
}
Page = MmAllocPageMaybeSwap(0); Page = MmAllocPageMaybeSwap(0);
Mdl = MmCreateMdl(NULL, NULL, PAGESIZE); Mdl = MmCreateMdl(NULL, NULL, PAGESIZE);
MmBuildMdlFromPages(Mdl, (PULONG)&Page); MmBuildMdlFromPages(Mdl, (PULONG)&Page);
@ -162,12 +175,13 @@ NTSTATUS MmUnalignedLoadPageForSection(PMADDRESS_SPACE AddressSpace,
} }
NTSTATUS MmWaitForPendingOperationSection(PMADDRESS_SPACE AddressSpace, NTSTATUS
PMEMORY_AREA MemoryArea, MmWaitForPendingOperationSection(PMADDRESS_SPACE AddressSpace,
PVOID Address, PMEMORY_AREA MemoryArea,
PSECTION_OBJECT Section, PVOID Address,
LARGE_INTEGER Offset, PSECTION_OBJECT Section,
ULONG Entry) LARGE_INTEGER Offset,
ULONG Entry)
{ {
PVOID Page; PVOID Page;
NTSTATUS Status; NTSTATUS Status;
@ -264,9 +278,10 @@ NTSTATUS MmWaitForPendingOperationSection(PMADDRESS_SPACE AddressSpace,
return(STATUS_SUCCESS); return(STATUS_SUCCESS);
} }
NTSTATUS MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace, NTSTATUS
MEMORY_AREA* MemoryArea, MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace,
PVOID Address) MEMORY_AREA* MemoryArea,
PVOID Address)
{ {
LARGE_INTEGER Offset; LARGE_INTEGER Offset;
IO_STATUS_BLOCK IoStatus; IO_STATUS_BLOCK IoStatus;
@ -308,17 +323,25 @@ NTSTATUS MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace,
Address)); 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);
/* /*
* Lock the section * Lock the section
*/ */
Section = MemoryArea->Data.SectionData.Section; Section = MemoryArea->Data.SectionData.Section;
MmLockSection(Section); MmLockSection(Section);
if (Section->Flags & SO_PHYSICAL_MEMORY)
{
/*
* Just map the desired physical page
*/
Status = MmCreateVirtualMapping(NULL,
Address,
MemoryArea->Attributes,
Offset.QuadPart);
MmUnlockSection(Section);
return(STATUS_SUCCESS);
}
/* /*
* Get the entry corresponding to the offset within the section * Get the entry corresponding to the offset within the section
*/ */
@ -496,22 +519,25 @@ NTSTATUS MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace,
} }
} }
ULONG MmPageOutSectionView(PMADDRESS_SPACE AddressSpace, ULONG
MEMORY_AREA* MemoryArea, MmPageOutSectionView(PMADDRESS_SPACE AddressSpace,
PVOID Address, MEMORY_AREA* MemoryArea,
PBOOLEAN Ul) PVOID Address,
PBOOLEAN Ul)
{ {
(*Ul) = FALSE; (*Ul) = FALSE;
return(0); return(0);
} }
VOID MmpDeleteSection(PVOID ObjectBody) VOID
MmpDeleteSection(PVOID ObjectBody)
{ {
DPRINT("MmpDeleteSection(ObjectBody %x)\n", ObjectBody); DPRINT("MmpDeleteSection(ObjectBody %x)\n", ObjectBody);
} }
VOID MmpCloseSection(PVOID ObjectBody, VOID
ULONG HandleCount) MmpCloseSection(PVOID ObjectBody,
ULONG HandleCount)
{ {
DPRINT("MmpCloseSection(OB %x, HC %d) RC %d\n", DPRINT("MmpCloseSection(OB %x, HC %d) RC %d\n",
ObjectBody, HandleCount, ObGetReferenceCount(ObjectBody)); ObjectBody, HandleCount, ObGetReferenceCount(ObjectBody));
@ -552,40 +578,91 @@ NTSTATUS MmpCreateSection(PVOID ObjectBody,
return(STATUS_SUCCESS); return(STATUS_SUCCESS);
} }
NTSTATUS MmInitSectionImplementation(VOID) NTSTATUS
MmCreatePhysicalMemorySection(VOID)
{ {
MmSectionObjectType = ExAllocatePool(NonPagedPool,sizeof(OBJECT_TYPE)); HANDLE PhysSectionH;
PSECTION_OBJECT PhysSection;
NTSTATUS Status;
OBJECT_ATTRIBUTES Obj;
UNICODE_STRING Name;
LARGE_INTEGER SectionSize;
RtlInitUnicodeString(&MmSectionObjectType->TypeName, L"Section"); /*
* Create the section mapping physical memory
*/
SectionSize.QuadPart = 0xFFFFFFFF;
RtlInitUnicodeString(&Name, L"\\Device\\PhysicalMemory");
InitializeObjectAttributes(&Obj,
&Name,
0,
NULL,
NULL);
Status = NtCreateSection(&PhysSectionH,
SECTION_ALL_ACCESS,
&Obj,
&SectionSize,
PAGE_EXECUTE_READWRITE,
0,
NULL);
if (!NT_SUCCESS(Status))
{
DbgPrint("Failed to create PhysicalMemory section\n");
KeBugCheck(0);
}
Status = ObReferenceObjectByHandle(PhysSectionH,
SECTION_ALL_ACCESS,
NULL,
KernelMode,
(PVOID*)&PhysSection,
NULL);
if (!NT_SUCCESS(Status))
{
DbgPrint("Failed to reference PhysicalMemory section\n");
KeBugCheck(0);
}
PhysSection->Flags = PhysSection->Flags | SO_PHYSICAL_MEMORY;
ObDereferenceObject((PVOID)PhysSection);
MmSectionObjectType->TotalObjects = 0; return(STATUS_SUCCESS);
MmSectionObjectType->TotalHandles = 0; }
MmSectionObjectType->MaxObjects = ULONG_MAX;
MmSectionObjectType->MaxHandles = ULONG_MAX;
MmSectionObjectType->PagedPoolCharge = 0;
MmSectionObjectType->NonpagedPoolCharge = sizeof(SECTION_OBJECT);
MmSectionObjectType->Dump = NULL;
MmSectionObjectType->Open = NULL;
MmSectionObjectType->Close = MmpCloseSection;
MmSectionObjectType->Delete = MmpDeleteSection;
MmSectionObjectType->Parse = NULL;
MmSectionObjectType->Security = NULL;
MmSectionObjectType->QueryName = NULL;
MmSectionObjectType->OkayToClose = NULL;
MmSectionObjectType->Create = MmpCreateSection;
return(STATUS_SUCCESS); NTSTATUS
MmInitSectionImplementation(VOID)
{
MmSectionObjectType = ExAllocatePool(NonPagedPool,sizeof(OBJECT_TYPE));
RtlInitUnicodeString(&MmSectionObjectType->TypeName, L"Section");
MmSectionObjectType->TotalObjects = 0;
MmSectionObjectType->TotalHandles = 0;
MmSectionObjectType->MaxObjects = ULONG_MAX;
MmSectionObjectType->MaxHandles = ULONG_MAX;
MmSectionObjectType->PagedPoolCharge = 0;
MmSectionObjectType->NonpagedPoolCharge = sizeof(SECTION_OBJECT);
MmSectionObjectType->Dump = NULL;
MmSectionObjectType->Open = NULL;
MmSectionObjectType->Close = MmpCloseSection;
MmSectionObjectType->Delete = MmpDeleteSection;
MmSectionObjectType->Parse = NULL;
MmSectionObjectType->Security = NULL;
MmSectionObjectType->QueryName = NULL;
MmSectionObjectType->OkayToClose = NULL;
MmSectionObjectType->Create = MmpCreateSection;
return(STATUS_SUCCESS);
} }
/* FIXME: NtCS should call MmCS */ /* FIXME: NtCS should call MmCS */
NTSTATUS STDCALL NtCreateSection (OUT PHANDLE SectionHandle, NTSTATUS STDCALL
IN ACCESS_MASK DesiredAccess, NtCreateSection (OUT PHANDLE SectionHandle,
IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, IN ACCESS_MASK DesiredAccess,
IN PLARGE_INTEGER MaximumSize OPTIONAL, IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
IN ULONG SectionPageProtection OPTIONAL, IN PLARGE_INTEGER MaximumSize OPTIONAL,
IN ULONG AllocationAttributes, IN ULONG SectionPageProtection OPTIONAL,
IN HANDLE FileHandle OPTIONAL) IN ULONG AllocationAttributes,
IN HANDLE FileHandle OPTIONAL)
/* /*
* FUNCTION: Creates a section object. * FUNCTION: Creates a section object.
* ARGUMENTS: * ARGUMENTS:
@ -640,8 +717,9 @@ NTSTATUS STDCALL NtCreateSection (OUT PHANDLE SectionHandle,
KeInitializeSpinLock(&Section->ViewListLock); KeInitializeSpinLock(&Section->ViewListLock);
KeInitializeMutex(&Section->Lock, 0); KeInitializeMutex(&Section->Lock, 0);
memset(&Section->PageDirectory, 0, sizeof(Section->PageDirectory)); memset(&Section->PageDirectory, 0, sizeof(Section->PageDirectory));
Section->Flags = 0;
if (FileHandle != (HANDLE)0xffffffff) if (FileHandle != (HANDLE)0)
{ {
Status = ObReferenceObjectByHandle(FileHandle, Status = ObReferenceObjectByHandle(FileHandle,
FILE_READ_DATA, FILE_READ_DATA,
@ -686,9 +764,10 @@ NTSTATUS STDCALL NtCreateSection (OUT PHANDLE SectionHandle,
* REVISIONS * REVISIONS
* *
*/ */
NTSTATUS STDCALL NtOpenSection(PHANDLE SectionHandle, NTSTATUS STDCALL
ACCESS_MASK DesiredAccess, NtOpenSection(PHANDLE SectionHandle,
POBJECT_ATTRIBUTES ObjectAttributes) ACCESS_MASK DesiredAccess,
POBJECT_ATTRIBUTES ObjectAttributes)
{ {
PVOID Object; PVOID Object;
NTSTATUS Status; NTSTATUS Status;
@ -765,16 +844,17 @@ NTSTATUS STDCALL NtOpenSection(PHANDLE SectionHandle,
* RETURN VALUE * RETURN VALUE
* Status. * Status.
*/ */
NTSTATUS STDCALL NtMapViewOfSection(HANDLE SectionHandle, NTSTATUS STDCALL
HANDLE ProcessHandle, NtMapViewOfSection(HANDLE SectionHandle,
PVOID* BaseAddress, HANDLE ProcessHandle,
ULONG ZeroBits, PVOID* BaseAddress,
ULONG CommitSize, ULONG ZeroBits,
PLARGE_INTEGER SectionOffset, ULONG CommitSize,
PULONG ViewSize, PLARGE_INTEGER SectionOffset,
SECTION_INHERIT InheritDisposition, PULONG ViewSize,
ULONG AllocationType, SECTION_INHERIT InheritDisposition,
ULONG Protect) ULONG AllocationType,
ULONG Protect)
{ {
PSECTION_OBJECT Section; PSECTION_OBJECT Section;
PEPROCESS Process; PEPROCESS Process;
@ -803,7 +883,7 @@ NTSTATUS STDCALL NtMapViewOfSection(HANDLE SectionHandle,
if (!(NT_SUCCESS(Status))) if (!(NT_SUCCESS(Status)))
{ {
DPRINT("ObReference failed rc=%x\n",Status); DPRINT("ObReference failed rc=%x\n",Status);
return Status; return(Status);
} }
DPRINT("Section %x\n",Section); DPRINT("Section %x\n",Section);
@ -821,7 +901,7 @@ NTSTATUS STDCALL NtMapViewOfSection(HANDLE SectionHandle,
Status); Status);
MmUnlockSection(Section); MmUnlockSection(Section);
ObDereferenceObject(Section); ObDereferenceObject(Section);
return Status; return(Status);
} }
AddressSpace = &Process->AddressSpace; AddressSpace = &Process->AddressSpace;
@ -839,9 +919,9 @@ NTSTATUS STDCALL NtMapViewOfSection(HANDLE SectionHandle,
} }
if (((*ViewSize)+ViewOffset) > Section->MaximumSize.u.LowPart) if (((*ViewSize)+ViewOffset) > Section->MaximumSize.u.LowPart)
{ {
(*ViewSize) = Section->MaximumSize.u.LowPart - ViewOffset; (*ViewSize) = Section->MaximumSize.u.LowPart - ViewOffset;
} }
DPRINT("Creating memory area\n"); DPRINT("Creating memory area\n");
MmLockAddressSpace(AddressSpace); MmLockAddressSpace(AddressSpace);
@ -861,7 +941,7 @@ NTSTATUS STDCALL NtMapViewOfSection(HANDLE SectionHandle,
MmUnlockSection(Section); MmUnlockSection(Section);
ObDereferenceObject(Section); ObDereferenceObject(Section);
return Status; return(Status);
} }
KeAcquireSpinLock(&Section->ViewListLock, &oldIrql); KeAcquireSpinLock(&Section->ViewListLock, &oldIrql);
@ -884,8 +964,9 @@ NTSTATUS STDCALL NtMapViewOfSection(HANDLE SectionHandle,
return(STATUS_SUCCESS); return(STATUS_SUCCESS);
} }
NTSTATUS STDCALL MmUnmapViewOfSection(PEPROCESS Process, NTSTATUS STDCALL
PMEMORY_AREA MemoryArea) MmUnmapViewOfSection(PEPROCESS Process,
PMEMORY_AREA MemoryArea)
{ {
PSECTION_OBJECT Section; PSECTION_OBJECT Section;
KIRQL oldIrql; KIRQL oldIrql;
@ -922,8 +1003,9 @@ NTSTATUS STDCALL MmUnmapViewOfSection(PEPROCESS Process,
* REVISIONS * REVISIONS
* *
*/ */
NTSTATUS STDCALL NtUnmapViewOfSection (HANDLE ProcessHandle, NTSTATUS STDCALL
PVOID BaseAddress) NtUnmapViewOfSection (HANDLE ProcessHandle,
PVOID BaseAddress)
{ {
PEPROCESS Process; PEPROCESS Process;
NTSTATUS Status; NTSTATUS Status;
@ -964,10 +1046,20 @@ NTSTATUS STDCALL NtUnmapViewOfSection (HANDLE ProcessHandle,
MemoryArea); MemoryArea);
DPRINT("MmFreeMemoryArea()\n"); DPRINT("MmFreeMemoryArea()\n");
Status = MmFreeMemoryArea(&Process->AddressSpace, if (MemoryArea->Data.SectionData.Section->Flags & SO_PHYSICAL_MEMORY)
BaseAddress, {
0, Status = MmFreeMemoryArea(&Process->AddressSpace,
TRUE); BaseAddress,
0,
FALSE);
}
else
{
Status = MmFreeMemoryArea(&Process->AddressSpace,
BaseAddress,
0,
TRUE);
}
MmUnlockAddressSpace(AddressSpace); MmUnlockAddressSpace(AddressSpace);
ObDereferenceObject(Process); ObDereferenceObject(Process);
@ -975,11 +1067,12 @@ NTSTATUS STDCALL NtUnmapViewOfSection (HANDLE ProcessHandle,
} }
NTSTATUS STDCALL NtQuerySection (IN HANDLE SectionHandle, NTSTATUS STDCALL
IN CINT SectionInformationClass, NtQuerySection (IN HANDLE SectionHandle,
OUT PVOID SectionInformation, IN CINT SectionInformationClass,
IN ULONG Length, OUT PVOID SectionInformation,
OUT PULONG ResultLength) IN ULONG Length,
OUT PULONG ResultLength)
/* /*
* FUNCTION: Queries the information of a section object. * FUNCTION: Queries the information of a section object.
* ARGUMENTS: * ARGUMENTS:
@ -997,8 +1090,9 @@ NTSTATUS STDCALL NtQuerySection (IN HANDLE SectionHandle,
} }
NTSTATUS STDCALL NtExtendSection(IN HANDLE SectionHandle, NTSTATUS STDCALL
IN ULONG NewMaximumSize) NtExtendSection(IN HANDLE SectionHandle,
IN ULONG NewMaximumSize)
{ {
UNIMPLEMENTED; UNIMPLEMENTED;
} }
@ -1021,7 +1115,8 @@ NTSTATUS STDCALL NtExtendSection(IN HANDLE SectionHandle,
* REVISIONS * REVISIONS
* *
*/ */
PVOID STDCALL MmAllocateSection (IN ULONG Length) PVOID STDCALL
MmAllocateSection (IN ULONG Length)
{ {
PVOID Result; PVOID Result;
MEMORY_AREA* marea; MEMORY_AREA* marea;
@ -1077,107 +1172,83 @@ PVOID STDCALL MmAllocateSection (IN ULONG Length)
* Status. * Status.
* *
*/ */
PVOID PVOID STDCALL
STDCALL MmMapViewOfSection (DWORD Unknown0,
MmMapViewOfSection ( DWORD Unknown1,
DWORD Unknown0, DWORD Unknown2,
DWORD Unknown1, DWORD Unknown3,
DWORD Unknown2, DWORD Unknown4,
DWORD Unknown3, DWORD Unknown5,
DWORD Unknown4, DWORD Unknown6,
DWORD Unknown5, DWORD Unknown7,
DWORD Unknown6, DWORD Unknown8,
DWORD Unknown7, DWORD Unknown9)
DWORD Unknown8,
DWORD Unknown9
)
{ {
UNIMPLEMENTED; UNIMPLEMENTED;
return (NULL); return (NULL);
} }
BOOLEAN BOOLEAN STDCALL
STDCALL MmCanFileBeTruncated (IN PSECTION_OBJECT_POINTERS SectionObjectPointer,
MmCanFileBeTruncated ( IN PLARGE_INTEGER NewFileSize)
IN PSECTION_OBJECT_POINTERS SectionObjectPointer,
IN PLARGE_INTEGER NewFileSize
)
{ {
UNIMPLEMENTED; UNIMPLEMENTED;
return (FALSE); return (FALSE);
} }
BOOLEAN BOOLEAN STDCALL
STDCALL MmDisableModifiedWriteOfSection (DWORD Unknown0)
MmDisableModifiedWriteOfSection (
DWORD Unknown0
)
{ {
UNIMPLEMENTED; UNIMPLEMENTED;
return (FALSE); return (FALSE);
} }
BOOLEAN BOOLEAN STDCALL
STDCALL MmFlushImageSection (IN PSECTION_OBJECT_POINTERS SectionObjectPointer,
MmFlushImageSection ( IN MMFLUSH_TYPE FlushType)
IN PSECTION_OBJECT_POINTERS SectionObjectPointer,
IN MMFLUSH_TYPE FlushType
)
{ {
UNIMPLEMENTED; UNIMPLEMENTED;
return (FALSE); return (FALSE);
} }
BOOLEAN BOOLEAN STDCALL
STDCALL MmForceSectionClosed (DWORD Unknown0,
MmForceSectionClosed ( DWORD Unknown1)
DWORD Unknown0,
DWORD Unknown1
)
{ {
UNIMPLEMENTED; UNIMPLEMENTED;
return (FALSE); return (FALSE);
} }
NTSTATUS NTSTATUS STDCALL
STDCALL MmMapViewInSystemSpace (IN PVOID Section,
MmMapViewInSystemSpace ( OUT PVOID * MappedBase,
IN PVOID Section, IN PULONG ViewSize)
OUT PVOID * MappedBase,
IN PULONG ViewSize
)
{ {
UNIMPLEMENTED; UNIMPLEMENTED;
return (STATUS_NOT_IMPLEMENTED); return (STATUS_NOT_IMPLEMENTED);
} }
NTSTATUS NTSTATUS STDCALL
STDCALL MmUnmapViewInSystemSpace (DWORD Unknown0)
MmUnmapViewInSystemSpace (
DWORD Unknown0
)
{ {
UNIMPLEMENTED; UNIMPLEMENTED;
return (STATUS_NOT_IMPLEMENTED); return (STATUS_NOT_IMPLEMENTED);
} }
NTSTATUS NTSTATUS STDCALL
STDCALL MmSetBankedSection (DWORD Unknown0,
MmSetBankedSection ( DWORD Unknown1,
DWORD Unknown0, DWORD Unknown2,
DWORD Unknown1, DWORD Unknown3,
DWORD Unknown2, DWORD Unknown4,
DWORD Unknown3, DWORD Unknown5)
DWORD Unknown4,
DWORD Unknown5
)
{ {
UNIMPLEMENTED; UNIMPLEMENTED;
return (STATUS_NOT_IMPLEMENTED); return (STATUS_NOT_IMPLEMENTED);
} }
@ -1234,20 +1305,23 @@ MmSetBankedSection (
* RETURN VALUE * RETURN VALUE
* Status. * Status.
*/ */
NTSTATUS NTSTATUS STDCALL
STDCALL MmCreateSection (OUT PSECTION_OBJECT * SectionObject,
MmCreateSection ( IN ACCESS_MASK DesiredAccess,
OUT PSECTION_OBJECT * SectionObject, IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
IN ACCESS_MASK DesiredAccess, IN PLARGE_INTEGER MaximumSize,
IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, IN ULONG SectionPageProtection,
IN PLARGE_INTEGER MaximumSize, IN ULONG AllocationAttributes,
IN ULONG SectionPageProtection, IN HANDLE FileHandle OPTIONAL,
IN ULONG AllocationAttributes, IN PFILE_OBJECT File OPTIONAL)
IN HANDLE FileHandle OPTIONAL,
IN PFILE_OBJECT File OPTIONAL
)
{ {
return (STATUS_NOT_IMPLEMENTED); return (STATUS_NOT_IMPLEMENTED);
} }
/* EOF */ /* EOF */