Final macro fixes

Minor fixes

svn path=/trunk/; revision=1222
This commit is contained in:
Eric Kohl 2000-07-02 17:33:15 +00:00
parent add4b2d35b
commit bad7efb0e7
10 changed files with 414 additions and 409 deletions

View file

@ -43,11 +43,49 @@ ExAcquireSharedWaitForExclusive (
PERESOURCE Resource,
BOOLEAN Wait
);
/*
* PVOID
* ExAllocateFromNPagedLookasideList (
* PNPAGED_LOOKASIDE_LIST LookSide
* );
*
* FUNCTION:
* Removes (pops) the first entry from the specified nonpaged
* lookaside list.
*
* ARGUMENTS:
* Lookaside = Pointer to a nonpaged lookaside list
*
* RETURNS:
* Address of the allocated list entry
*/
static
inline
PVOID
STDCALL
ExAllocateFromNPagedLookasideList (
PNPAGED_LOOKASIDE_LIST LookSide
);
IN PNPAGED_LOOKASIDE_LIST Lookaside
)
{
#if 0
PVOID Entry;
Lookaside->TotalAllocates++;
Entry = ExInterlockedPopEntrySList (&Lookaside->ListHead,
&Lookaside->Lock);
if (Entry == NULL)
{
Lookaside->AllocateMisses++;
Entry = (Lookaside->Allocate)(Lookaside->Type,
Lookaside->Size,
Lookaside->Tag);
}
return Entry;
#endif
return NULL;
}
PVOID
STDCALL
ExAllocateFromPagedLookasideList (
@ -58,6 +96,27 @@ STDCALL
ExAllocateFromZone (
PZONE_HEADER Zone
);
/*
* PVOID
* ExAllocateFromZone (
* PZONE_HEADER Zone
* );
*
* FUNCTION:
* Allocate a block from a zone
*
* ARGUMENTS:
* Zone = Zone to allocate from
*
* RETURNS:
* The base address of the block allocated
*/
#define ExAllocateFromZone(Zone) \
(PVOID)((Zone)->FreeList.Next); \
if ((Zone)->FreeList.Next) \
(Zone)->FreeList.Next = (Zone)->FreeList.Next->Next
/*
* FUNCTION: Allocates memory from the nonpaged pool
* ARGUMENTS:
@ -137,36 +196,80 @@ ExFreePool (
PVOID block
);
/*
* VOID
* ExFreeToNPagedLookasideList (
* PNPAGED_LOOKASIDE_LIST Lookaside,
* PVOID Entry
* );
*
* FUNCTION:
* Inserts (pushes) the specified entry into the specified
* nonpaged lookaside list.
*
* ARGUMENTS:
* Lookaside = Pointer to the nonpaged lookaside list
* Entry = Pointer to the entry that is inserted in the lookaside list
*/
static
inline
VOID
STDCALL
ExFreeToNPagedLookasideList (
PNPAGED_LOOKASIDE_LIST Lookaside,
PVOID Entry
);
IN PNPAGED_LOOKASIDE_LIST Lookaside,
IN PVOID Entry
)
{
#if 0
Lookaside->TotalFrees++;
if (ExQueryDepthSList (&Lookaside->ListHead) >= Lookaside->Depth)
{
Lookaside->FreeMisses++;
(Lookaside->Free)(Entry);
}
else
{
ExInterlockedPushEntrySList (&Lookaside->ListHead,
(PSINGLE_LIST_ENTRY)Entry,
&Lookaside->Lock);
}
#endif
}
VOID
STDCALL
ExFreeToPagedLookasideList (
PPAGED_LOOKASIDE_LIST Lookaside,
PVOID Entry
);
PVOID
STDCALL
ExFreeToZone (
PZONE_HEADER Zone,
PVOID Block
);
/*
ERESOURCE_THREAD
STDCALL
ExGetCurrentResourceThread (
VOID
);
*/
* PVOID
* ExFreeToZone (
* PZONE_HEADER Zone,
* PVOID Block
* );
*
* FUNCTION:
* Frees a block from a zone
*
* ARGUMENTS:
* Zone = Zone the block was allocated from
* Block = Block to free
*/
#define ExFreeToZone(Zone,Block) \
(((PSINGLE_LIST_ENTRY)(Block))->Next = (Zone)->FreeList.Next, \
(Zone)->FreeList.Next = ((PSINGLE_LIST_ENTRY)(Block)), \
((PSINGLE_LIST_ENTRY)(Block))->Next)
/*
* ERESOURCE_THREAD
* ExGetCurrentResourceThread (
* VOID
* );
*/
#define ExGetCurrentResourceThread() \
((ERESOURCE_THREAD)PsGetCurrentThread())
ULONG
STDCALL
ExGetExclusiveWaiterCount (
@ -182,8 +285,8 @@ ExGetSharedWaiterCount (
/*
* VOID
* ExInitializeFastMutex (
* PFAST_MUTEX FastMutex
* );
* PFAST_MUTEX FastMutex
* );
*/
#define ExInitializeFastMutex(_FastMutex) \
(_FastMutex)->Count = 1; \
@ -231,7 +334,7 @@ ExInitializeResourceLite (
* ExInitializeSListHead (
* PSLIST_HEADER SListHead
* );
*/
*/
#define ExInitializeSListHead(ListHead) \
(ListHead)->Alignment = 0
@ -281,12 +384,18 @@ ExInterlockedAddUlong (
ULONG Increment,
PKSPIN_LOCK Lock
);
PVOID
STDCALL
ExInterlockedAllocateFromZone (
PZONE_HEADER Zone,
PKSPIN_LOCK Lock
);
/*
* PVOID
* STDCALL
* ExInterlockedAllocateFromZone (
* PZONE_HEADER Zone,
* PKSPIN_LOCK Lock
* );
*/
#define ExInterlockedAllocateFromZone(Zone,Lock) \
(PVOID)ExInterlockedPopEntryList(&(Zone)->FreeList,Lock)
INTERLOCKED_RESULT
STDCALL
ExInterlockedDecrementLong (
@ -308,13 +417,18 @@ ExInterlockedExtendZone (
ULONG SegmentSize,
PKSPIN_LOCK Lock
);
PVOID
STDCALL
ExInterlockedFreeToZone (
PZONE_HEADER Zone,
PVOID Block,
PKSPIN_LOCK Lock
);
/*
* PVOID
* ExInterlockedFreeToZone (
* PZONE_HEADER Zone,
* PVOID Block,
* PKSPIN_LOCK Lock
* );
*/
#define ExInterlockedFreeToZone(Zone,Block,Lock) \
ExInterlockedPushEntryList(&(Zone)->FreeList,((PSINGLE_LIST_ENTRY)(Block)),(Lock))
INTERLOCKED_RESULT
STDCALL
ExInterlockedIncrementLong (
@ -375,17 +489,27 @@ ExInterlockedRemoveHeadList (
PLIST_ENTRY Head,
PKSPIN_LOCK Lock
);
BOOLEAN
STDCALL
ExIsFullZone (
PZONE_HEADER Zone
);
BOOLEAN
STDCALL
ExIsObjectInFirstZoneSegment (
PZONE_HEADER Zone,
PVOID Object
);
/*
* BOOLEAN
* ExIsFullZone (
* PZONE_HEADER Zone
* );
*/
#define ExIsFullZone(Zone) \
((Zone)->FreeList.Next==(PSINGLE_LIST_ENTRY)NULL)
/*
* BOOLEAN
* ExIsObjectInFirstZoneSegment (
* PZONE_HEADER Zone,
* PVOID Object
* );
*/
#define ExIsObjectInFirstZoneSegment(Zone,Object) \
(((PUCHAR)(Object)>=(PUCHAR)(Zone)->SegmentList.Next) && \
((PUCHAR)(Object)<(PUCHAR)(Zone)->SegmentList.Next+(Zone)->TotalSegmentSize))
BOOLEAN
STDCALL
ExIsResourceAcquiredExclusiveLite (

View file

@ -1,6 +1,6 @@
#ifndef _INCLUDE_DDK_MMFUNCS_H
#define _INCLUDE_DDK_MMFUNCS_H
/* $Id: mmfuncs.h,v 1.6 2000/06/29 23:35:12 dwelch Exp $ */
/* $Id: mmfuncs.h,v 1.7 2000/07/02 17:30:31 ekohl Exp $ */
/* MEMORY MANAGMENT ******************************************************/
#include <ddk/i386/pagesize.h>
@ -176,7 +176,8 @@ MmFreeNonCachedMemory (
* Mdl = the mdl
* RETURNS: The offset in bytes
*/
#define MmGetMdlByteOffset(Mdl) ((Mdl)->ByteOffset)
#define MmGetMdlByteOffset(Mdl) \
((Mdl)->ByteOffset)
/*
* FUNCTION: Returns the initial virtual address for a buffer described
@ -185,7 +186,7 @@ MmFreeNonCachedMemory (
* Mdl = the mdl
* RETURNS: The initial virtual address
*/
#define MmGetMdlVirtualAddress(Mdl) \
#define MmGetMdlVirtualAddress(Mdl) \
((PVOID) ((PCHAR) (Mdl)->StartVa + (Mdl)->ByteOffset))
/*
@ -200,33 +201,67 @@ STDCALL
MmGetPhysicalAddress (
IN PVOID BaseAddress
);
#define MmGetProcedureAddress(Address) (Address)
/*
* FUNCTION: Maps the physical pages described by an MDL into system space
* PVOID
* MmGetSystemAddressForMdl (
* PMDL Mdl
* );
*
* FUNCTION:
* Maps the physical pages described by an MDL into system space
*
* ARGUMENTS:
* Mdl = mdl
* RETURNS: The base system address for the mapped buffer
* Mdl = mdl
*
* RETURNS:
* The base system address for the mapped buffer
*/
PVOID MmGetSystemAddressForMdl(PMDL Mdl);
#define MmGetSystemAddressForMdl(Mdl) \
(((Mdl)->MdlFlags & (MDL_MAPPED_TO_SYSTEM_VA | MDL_SOURCE_IS_NONPAGED_POOL)) ? \
((Mdl)->MappedSystemVa):(MmMapLockedPages((Mdl),KernelMode)))
NTSTATUS
STDCALL
MmGrowKernelStack (
DWORD Unknown0
);
#ifdef __NTOSKRNL__
extern PVOID EXPORTED MmHighestUserAddress;
#else
extern PVOID IMPORTED MmHighestUserAddress;
#endif
/*
* FUNCTION: Initalizes an mdl
* ARGUMENTS:
* MemoryDescriptorList = MDL to be initalized
* BaseVa = Base virtual address of the buffer
* Length = Length in bytes of the buffer
* VOID
* MmInitializeMdl (
* PMDL MemoryDescriptorList,
* PVOID BaseVa,
* ULONG Length
* );
*
* FUNCTION:
* Initalizes an MDL
*
* ARGUMENTS:
* MemoryDescriptorList = MDL to be initalized
* BaseVa = Base virtual address of the buffer
* Length = Length in bytes of the buffer
*/
VOID MmInitializeMdl(PMDL MemoryDescriptorList, PVOID BaseVa, ULONG Length);
#define MmInitializeMdl(MemoryDescriptorList,BaseVa,Length) \
{ \
(MemoryDescriptorList)->Next = (PMDL)NULL; \
(MemoryDescriptorList)->Size = (CSHORT)(sizeof(MDL) + \
(ADDRESS_AND_SIZE_TO_SPAN_PAGES((BaseVa),(Length)) * sizeof(ULONG))); \
(MemoryDescriptorList)->MdlFlags = 0; \
(MemoryDescriptorList)->StartVa = (PVOID)PAGE_ROUND_DOWN((BaseVa)); \
(MemoryDescriptorList)->ByteOffset = (ULONG)((BaseVa) - PAGE_ROUND_DOWN((BaseVa))); \
(MemoryDescriptorList)->ByteCount = (Length); \
(MemoryDescriptorList)->Process = PsGetCurrentProcess(); \
}
/*
* FUNCTION: Checks whether an address is valid for read/write
@ -266,7 +301,8 @@ MmIsThisAnNtAsSystem (
* AddressWithinSection = Any address in the region
* RETURNS: A handle to the region
*/
#define MmLockPagableCodeSection(Address) MmLockPagableDataSection(Address)
#define MmLockPagableCodeSection(Address) \
MmLockPagableDataSection(Address)
/*
* FUNCTION: Locks a section of the driver's data into memory
@ -359,6 +395,58 @@ STDCALL
MmPageEntireDriver (
PVOID AddressWithinSection
);
/*
* VOID
* MmPrepareMdlForReuse (
* PMDL Mdl
* );
*
* FUNCTION:
* Reinitializes a caller-allocated MDL
*
* ARGUMENTS:
* Mdl = Points to the MDL that will be reused
*/
#define MmPrepareMdlForReuse(Mdl) \
if (((Mdl)->MdlFlags & MDL_PARTIAL_HAS_BEEN_MAPPED) != 0) \
{ \
assert(((Mdl)->MdlFlags & MDL_PARTIAL) != 0); \
MmUnmapLockedPages ((Mdl)->MappedSystemVa, (Mdl)); \
} \
else if (((Mdl)->MdlFlags & MDL_PARTIAL) == 0) \
{ \
assert(((Mdl)->MdlFlags & MDL_MAPPED_TO_SYSTEM_VA) == 0); \
}
/*
* FUNCTION: Probes the specified pages, makes them resident and locks
* the physical pages mapped by the virtual address range
* ARGUMENTS:
* MemoryDescriptorList = MDL which supplies the virtual address,
* byte offset and length
* AccessMode = Access mode with which to probe the arguments
* Operation = Types of operation for which the pages should be
* probed
*/
VOID
STDCALL
MmProbeAndLockPages (
PMDL MemoryDescriptorList,
KPROCESSOR_MODE AccessMode,
LOCK_OPERATION Operation
);
/*
* FUNCTION: Returns an estimate of the amount of memory in the system
* RETURNS: Either MmSmallSystem, MmMediumSystem or MmLargeSystem
*/
MM_SYSTEM_SIZE
STDCALL
MmQuerySystemSize (
VOID
);
/*
* FUNCTION: Resets the pageable status of a driver's sections to their
* compile time settings
@ -370,6 +458,7 @@ STDCALL
MmResetDriverPaging (
PVOID AddressWithinSection
);
DWORD
STDCALL
MmSecureVirtualMemory (
@ -393,39 +482,7 @@ MmSetBankedSection (
DWORD Unknown4,
DWORD Unknown5
);
/*
* FUNCTION: Reinitializes a caller-allocated MDL
* ARGUMENTS:
* Mdl = Points to the MDL that will be reused
*/
VOID MmPrepareMdlForReuse(PMDL Mdl);
/*
* FUNCTION: Probes the specified pages, makes them resident and locks
* the physical pages mapped by the virtual address range
* ARGUMENTS:
* MemoryDescriptorList = MDL which supplies the virtual address,
* byte offset and length
* AccessMode = Access mode with which to probe the arguments
* Operation = Types of operation for which the pages should be
* probed
*/
VOID
STDCALL
MmProbeAndLockPages (
PMDL MemoryDescriptorList,
KPROCESSOR_MODE AccessMode,
LOCK_OPERATION Operation
);
/*
* FUNCTION: Returns an estimate of the amount of memory in the system
* RETURNS: Either MmSmallSystem, MmMediumSystem or MmLargeSystem
*/
MM_SYSTEM_SIZE
STDCALL
MmQuerySystemSize (
VOID
);
/*
* FUNCTION: Returns the number of bytes to allocate for an MDL
* describing a given address range

View file

@ -1,4 +1,4 @@
/* $Id: rtl.h,v 1.37 2000/07/02 10:46:35 ekohl Exp $
/* $Id: rtl.h,v 1.38 2000/07/02 17:30:31 ekohl Exp $
*
*/
@ -139,6 +139,27 @@ enum
RTL_REGISTRY_VALUE,
};
#define SHORT_SIZE (sizeof(USHORT))
#define SHORT_MASK (SHORT_SIZE-1)
#define LONG_SIZE (sizeof(ULONG))
#define LONG_MASK (LONG_SIZE-1)
#define LOWBYTE_MASK 0x00FF
#define FIRSTBYTE(Value) ((Value) & LOWBYTE_MASK)
#define SECONDBYTE(Value) (((Value) >> 8) & LOWBYTE_MASK)
#define THIRDBYTE(Value) (((Value) >> 16) & LOWBYTE_MASK)
#define FOURTHBYTE(Value) (((Value) >> 24) & LOWBYTE_MASK)
/* FIXME: reverse byte-order on big-endian machines (e.g. MIPS) */
#define SHORT_LEAST_SIGNIFICANT_BIT 0
#define SHORT_MOST_SIGNIFICANT_BIT 1
#define LONG_LEAST_SIGNIFICANT_BIT 0
#define LONG_3RD_MOST_SIGNIFICANT_BIT 1
#define LONG_2RD_MOST_SIGNIFICANT_BIT 2
#define LONG_MOST_SIGNIFICANT_BIT 3
#if defined(__NTOSKRNL__) || defined(__NTDLL__)
#define NLS_MB_CODE_PAGE_TAG NlsMbCodePageTag
@ -1301,17 +1322,43 @@ RtlReAllocateHeap (
DWORD size
);
VOID
RtlRetrieveUlong (
PULONG DestinationAddress,
PULONG SourceAddress
);
/*
* VOID
* RtlRetrieveUlong (
* PULONG DestinationAddress,
* PULONG SourceAddress
* );
*/
#define RtlRetrieveUlong(DestAddress,SrcAddress) \
if ((ULONG)(SrcAddress) & LONG_MASK) \
{ \
((PUCHAR)(DestAddress))[0]=((PUCHAR)(SrcAddress))[0]; \
((PUCHAR)(DestAddress))[1]=((PUCHAR)(SrcAddress))[1]; \
((PUCHAR)(DestAddress))[2]=((PUCHAR)(SrcAddress))[2]; \
((PUCHAR)(DestAddress))[3]=((PUCHAR)(SrcAddress))[3]; \
} \
else \
{ \
*((PULONG)(DestAddress))=*((PULONG)(SrcAddress)); \
}
VOID
RtlRetrieveUshort (
PUSHORT DestinationAddress,
PUSHORT SourceAddress
);
/*
* VOID
* RtlRetrieveUshort (
* PUSHORT DestinationAddress,
* PUSHORT SourceAddress
* );
*/
#define RtlRetrieveUshort(DestAddress,SrcAddress) \
if ((ULONG)(SrcAddress) & SHORT_MASK) \
{ \
((PUCHAR)(DestAddress))[0]=((PUCHAR)(SrcAddress))[0]; \
((PUCHAR)(DestAddress))[1]=((PUCHAR)(SrcAddress))[1]; \
} \
else \
{ \
*((PUSHORT)(DestAddress))=*((PUSHORT)(SrcAddress)); \
}
VOID
STDCALL
@ -1358,23 +1405,43 @@ RtlSizeHeap (
PVOID pmem
);
VOID
RtlStoreLong (
PULONG Address,
ULONG Value
);
/*
* VOID
* RtlStoreUlong (
* PULONG Address,
* ULONG Value
* );
*/
#define RtlStoreUlong(Address,Value) \
if ((ULONG)(Address) & LONG_MASK) \
{ \
((PUCHAR)(Address))[LONG_LEAST_SIGNIFICANT_BIT]=(UCHAR)(FIRSTBYTE(Value)); \
((PUCHAR)(Address))[LONG_3RD_MOST_SIGNIFICANT_BIT]=(UCHAR)(FIRSTBYTE(Value)); \
((PUCHAR)(Address))[LONG_2ND_MOST_SIGNIFICANT_BIT]=(UCHAR)(THIRDBYTE(Value)); \
((PUCHAR)(Address))[LONG_MOST_SIGNIFICANT_BIT]=(UCHAR)(FOURTHBYTE(Value)); \
} \
else \
{ \
*((PULONG)(Address))=(ULONG)(Value); \
}
VOID
RtlStoreUlong (
PULONG Address,
ULONG Value
);
VOID
RtlStoreUshort (
PUSHORT Address,
USHORT Value
);
/*
* VOID
* RtlStoreUshort (
* PUSHORT Address,
* USHORT Value
* );
*/
#define RtlStoreUshort(Address,Value) \
if ((ULONG)(Address) & SHORT_MASK) \
{ \
((PUCHAR)(Address))[SHORT_LEAST_SIGNIFICANT_BIT]=(UCHAR)(FIRSTBYTE(Value)); \
((PUCHAR)(Address))[SHORT_MOST_SIGNIFICANT_BIT]=(UCHAR)(SECONDBYTE(Value)); \
} \
else \
{ \
*((PUSHORT)(Address))=(USHORT)(Value); \
}
BOOLEAN
STDCALL

View file

@ -1,4 +1,4 @@
/* $Id: lookas.c,v 1.1 2000/07/02 10:48:31 ekohl Exp $
/* $Id: lookas.c,v 1.2 2000/07/02 17:31:49 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -17,15 +17,6 @@
/* FUNCTIONS *****************************************************************/
PVOID
STDCALL
ExAllocateFromNPagedLookasideList (
PNPAGED_LOOKASIDE_LIST Lookaside
)
{
UNIMPLEMENTED;
}
PVOID
STDCALL
ExAllocateFromPagedLookasideList (
@ -53,16 +44,6 @@ ExDeletePagedLookasideList (
UNIMPLEMENTED;
}
VOID
STDCALL
ExFreeToNPagedLookasideList (
PNPAGED_LOOKASIDE_LIST Lookaside,
PVOID Entry
)
{
UNIMPLEMENTED;
}
VOID
STDCALL
ExFreeToPagedLookasideList (

View file

@ -1,4 +1,4 @@
/* $Id: zone.c,v 1.1 2000/07/02 10:48:31 ekohl Exp $
/* $Id: zone.c,v 1.2 2000/07/02 17:31:49 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -13,30 +13,6 @@
/* FUNCTIONS ***************************************************************/
inline static PZONE_ENTRY block_to_entry(PVOID Block)
{
return( (PZONE_ENTRY)(Block - sizeof(ZONE_ENTRY)) );
}
inline static PVOID entry_to_block(PZONE_ENTRY Entry)
{
return( (PVOID)( ((PVOID)Entry) + sizeof(ZONE_ENTRY)));
}
BOOLEAN
STDCALL
ExIsObjectInFirstZoneSegment (
PZONE_HEADER Zone,
PVOID Object
)
{
PVOID Base = (PVOID)(Zone + sizeof(ZONE_HEADER) + sizeof(ZONE_SEGMENT) +
sizeof(ZONE_ENTRY));
PZONE_SEGMENT seg = (PZONE_SEGMENT)(Zone + sizeof(ZONE_HEADER));
ULONG length = seg->size;
return( (Object > Base) && (Object < (Base + length)));
}
NTSTATUS
STDCALL
ExExtendZone (
@ -65,6 +41,7 @@ ExExtendZone (
return(STATUS_SUCCESS);
}
NTSTATUS
STDCALL
ExInterlockedExtendZone (
@ -83,50 +60,6 @@ ExInterlockedExtendZone (
return(ret);
}
BOOLEAN
STDCALL
ExIsFullZone (
PZONE_HEADER Zone
)
{
return(Zone->FreeList.Next==NULL);
}
PVOID
STDCALL
ExAllocateFromZone (
PZONE_HEADER Zone
)
/*
* FUNCTION: Allocate a block from a zone
* ARGUMENTS:
* Zone = Zone to allocate from
* RETURNS: The base address of the block allocated
*/
{
PSINGLE_LIST_ENTRY list_entry = PopEntryList(&Zone->FreeList);
PZONE_ENTRY entry = CONTAINING_RECORD(list_entry,ZONE_ENTRY,Entry);
return(entry_to_block(entry));
}
PVOID
STDCALL
ExFreeToZone (
PZONE_HEADER Zone,
PVOID Block
)
/*
* FUNCTION: Frees a block from a zone
* ARGUMENTS:
* Zone = Zone the block was allocated from
* Block = Block to free
*/
{
PZONE_ENTRY entry = block_to_entry(Block);
PZONE_ENTRY ret = entry_to_block((PZONE_ENTRY)Zone->FreeList.Next);
PushEntryList(&Zone->FreeList,&entry->Entry);
return(ret);
}
NTSTATUS
STDCALL
@ -167,41 +100,8 @@ ExInitializeZone (
PushEntryList(&Zone->FreeList,&entry->Entry);
entry = (PZONE_ENTRY)(((PVOID)entry) + sizeof(ZONE_ENTRY) + BlockSize);
}
return(STATUS_SUCCESS);
}
PVOID
STDCALL
ExInterlockedFreeToZone (
PZONE_HEADER Zone,
PVOID Block,
PKSPIN_LOCK Lock
)
{
KIRQL oldlvl;
PVOID ret;
KeAcquireSpinLock(Lock,&oldlvl);
ret=ExFreeToZone(Zone,Block);
KeReleaseSpinLock(Lock,oldlvl);
return(ret);
}
PVOID
STDCALL
ExInterlockedAllocateFromZone (
PZONE_HEADER Zone,
PKSPIN_LOCK Lock
)
{
PVOID ret;
KIRQL oldlvl;
KeAcquireSpinLock(Lock,&oldlvl);
ret=ExAllocateFromZone(Zone);
KeReleaseSpinLock(Lock,oldlvl);
return(ret);
}
/* EOF */

View file

@ -1,4 +1,4 @@
# $Id: makefile_rex,v 1.77 2000/07/02 10:47:28 ekohl Exp $
# $Id: makefile_rex,v 1.78 2000/07/02 17:31:31 ekohl Exp $
#
# ReactOS Operating System
#
@ -54,7 +54,6 @@ OBJECTS_RTL = \
rtl/string.o \
rtl/swprintf.o \
rtl/time.o \
rtl/unalign.o \
rtl/unicode.o \
rtl/wstring.o
@ -423,14 +422,14 @@ ifeq ($(DOSCLI),yes)
CLEAN_FILES = $(OBJECTS_PATH)\*.o cc\*.o cm\*.o dbg\*.o ex\*.o hal\x86\*.o io\*.o \
ke\*.o ldr\*.o mm\*.o nt\*.o ob\*.o ps\*.o rtl\*.o se\*.o \
ke\i386\*.o mm\i386\*.o fs\*.o po\*.o nls\*.o lpc\*.o \
kd\*.o utils\export\export.exe $(TARGETNAME).o $(TARGETNAME).a junk.tmp \
base.tmp temp.exp $(TARGETNAME).exe $(TARGETNAME).sym $(TARGETNAME).coff
kd\*.o $(TARGETNAME).o $(TARGETNAME).a junk.tmp base.tmp temp.exp \
$(TARGETNAME).exe $(TARGETNAME).nostrip.exe $(TARGETNAME).sym $(TARGETNAME).coff
else
CLEAN_FILES = $(OBJECTS_PATH)/*.o cc/*.o cm/*.o dbg/*.o ex/*.o hal/x86/*.o io/*.o \
ke/*.o ldr/*.o mm/*.o nt/*.o ob/*.o ps/*.o rtl/*.o se/*.o \
ke/i386/*.o mm/i386/*.o fs/*.o po/*.o nls/*.o lpc/*.o \
kd/*.o utils/export/export $(TARGETNAME).o $(TARGETNAME).a junk.tmp \
base.tmp temp.exp $(TARGETNAME).exe $(TARGETNAME).nostrip.exe $(TARGETNAME).sym $(TARGETNAME).coff
kd/*.o $(TARGETNAME).o $(TARGETNAME).a junk.tmp base.tmp temp.exp \
$(TARGETNAME).exe $(TARGETNAME).nostrip.exe $(TARGETNAME).sym $(TARGETNAME).coff
endif

View file

@ -1,4 +1,4 @@
/* $Id: mdl.c,v 1.19 2000/07/01 18:27:03 ekohl Exp $
/* $Id: mdl.c,v 1.20 2000/07/02 17:32:51 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -85,9 +85,11 @@ PVOID STDCALL MmMapLockedPages(PMDL Mdl, KPROCESSOR_MODE AccessMode)
}
DPRINT("base %x\n",base);
Mdl->MdlFlags = Mdl->MdlFlags | MDL_MAPPED_TO_SYSTEM_VA;
Mdl->MappedSystemVa = base + Mdl->ByteOffset;
return(base + Mdl->ByteOffset);
}
VOID STDCALL MmUnmapLockedPages(PVOID BaseAddress, PMDL Mdl)
/*
* FUNCTION: Releases a mapping set up by a preceding call to MmMapLockedPages
@ -101,13 +103,11 @@ VOID STDCALL MmUnmapLockedPages(PVOID BaseAddress, PMDL Mdl)
BaseAddress-Mdl->ByteOffset,
Mdl->ByteCount,
FALSE);
Mdl->MdlFlags = Mdl->MdlFlags & ~MDL_MAPPED_TO_SYSTEM_VA;
Mdl->MappedSystemVa = NULL;
DPRINT("MmUnmapLockedPages() finished\n");
}
VOID MmPrepareMdlForReuse(PMDL Mdl)
{
UNIMPLEMENTED;
}
VOID MmBuildMdlFromPages(PMDL Mdl)
{
@ -121,13 +121,16 @@ VOID MmBuildMdlFromPages(PMDL Mdl)
mdl_pages[i] = (ULONG)MmAllocPage();
DPRINT("mdl_pages[i] %x\n",mdl_pages[i]);
}
}
VOID STDCALL MmProbeAndLockPages(PMDL Mdl,
KPROCESSOR_MODE AccessMode,
LOCK_OPERATION Operation)
VOID
STDCALL
MmProbeAndLockPages (
PMDL Mdl,
KPROCESSOR_MODE AccessMode,
LOCK_OPERATION Operation
)
/*
* FUNCTION: Probes the specified pages, makes them resident and locks them
* ARGUMENTS:
@ -157,9 +160,7 @@ VOID STDCALL MmProbeAndLockPages(PMDL Mdl,
marea = MmOpenMemoryAreaByAddress(AddressSpace,
Mdl->StartVa);
DPRINT("marea %x\n",marea);
/*
* Check the area is valid
*/
@ -169,7 +170,7 @@ VOID STDCALL MmProbeAndLockPages(PMDL Mdl,
MmUnlockAddressSpace(AddressSpace);
ExRaiseStatus(STATUS_INVALID_PARAMETER);
}
/*
* Lock the memory area
* (We can't allow it to be freed while an I/O operation to it is
@ -184,42 +185,19 @@ VOID STDCALL MmProbeAndLockPages(PMDL Mdl,
for (i=0;i<(PAGE_ROUND_UP(Mdl->ByteOffset+Mdl->ByteCount)/PAGESIZE);i++)
{
Address = Mdl->StartVa + (i*PAGESIZE);
mdl_pages[i] = (MmGetPhysicalAddress(Address)).u.LowPart;
mdl_pages[i] = (MmGetPhysicalAddress(Address)).u.LowPart;
DPRINT("mdl_pages[i] %x\n",mdl_pages[i]);
}
MmUnlockAddressSpace(AddressSpace);
}
#if 0
ULONG MmGetMdlByteCount(PMDL Mdl)
/*
* FUNCTION: MmGetMdlByteCount returns the length in bytes described
* by a given MDL.
* ARGUMENTS:
* Mdl = Points to an MDL
* RETURN: MmGetMdlByteCount returns the byte count of the buffer described
* by Mdl.
*/
{
return(Mdl->ByteCount);
}
#endif
#if 0
ULONG MmGetMdlByteOffset(PMDL Mdl)
/*
* FUNCTION: Returns the byte offset within its page of the buffer described
* by the given MDL
* ARGUMENTS:
* Mdl = the mdl to query
* RETURNS: The offset in bytes
*/
{
return(Mdl->ByteOffset);
}
#endif
ULONG STDCALL MmSizeOfMdl(PVOID Base, ULONG Length)
ULONG
STDCALL
MmSizeOfMdl (
PVOID Base,
ULONG Length
)
/*
* FUNCTION: Returns the number of bytes to allocate for an MDL describing
* the given address range
@ -234,36 +212,12 @@ ULONG STDCALL MmSizeOfMdl(PVOID Base, ULONG Length)
return(sizeof(MDL)+(len*sizeof(ULONG)));
}
#if 0
PVOID MmGetMdlVirtualAddress(PMDL Mdl)
{
return(Mdl->StartVa + Mdl->ByteOffset);
}
#endif
PVOID MmGetSystemAddressForMdl(PMDL Mdl)
/*
* FUNCTION: Returns a nonpaged system-space virtual address for the buffer
* described by the MDL. It maps the physical pages described by a given
* MDL into system space, if they are not already mapped to system space.
* ARGUMENTS:
* Mdl = Mdl to map
* RETURNS: The base system-space virtual address that maps the physical
* pages described by the given MDL.
*/
{
DPRINT("MmGetSystemAddressForMdl(Mdl %x)\n", Mdl);
if (!( (Mdl->MdlFlags & MDL_MAPPED_TO_SYSTEM_VA) ||
(Mdl->MdlFlags & MDL_SOURCE_IS_NONPAGED_POOL) ))
{
Mdl->MappedSystemVa = MmMapLockedPages(Mdl,KernelMode);
}
DPRINT("Returning %x\n",Mdl->MappedSystemVa);
return(Mdl->MappedSystemVa);
}
VOID STDCALL MmBuildMdlForNonPagedPool(PMDL Mdl)
VOID
STDCALL
MmBuildMdlForNonPagedPool (
PMDL Mdl
)
/*
* FUNCTION: Fills in the corresponding physical page array of a given
* MDL for a buffer in nonpaged system space
@ -282,26 +236,14 @@ VOID STDCALL MmBuildMdlForNonPagedPool(PMDL Mdl)
Mdl->MappedSystemVa = Mdl->StartVa;
}
VOID MmInitializeMdl(PMDL MemoryDescriptorList, PVOID Base, ULONG Length)
/*
* FUNCTION: Initializes the header of an MDL
* ARGUMENTS:
* MemoryDescriptorList = Points to the MDL to be initialized
* BaseVa = Points to the base virtual address of a buffer
* Length = Specifies the length (in bytes) of a buffer
*/
{
memset(MemoryDescriptorList,0,sizeof(MDL));
MemoryDescriptorList->StartVa = (PVOID)PAGE_ROUND_DOWN(Base);
MemoryDescriptorList->ByteOffset = (ULONG)(Base - PAGE_ROUND_DOWN(Base));
MemoryDescriptorList->MdlFlags = 0;
MemoryDescriptorList->ByteCount = Length;
MemoryDescriptorList->Size = sizeof(MDL) +
(ADDRESS_AND_SIZE_TO_SPAN_PAGES(Base,Length) * sizeof(ULONG));
MemoryDescriptorList->Process = PsGetCurrentProcess();
}
PMDL STDCALL MmCreateMdl(PMDL MemoryDescriptorList, PVOID Base, ULONG Length)
PMDL
STDCALL
MmCreateMdl (
PMDL MemoryDescriptorList,
PVOID Base,
ULONG Length
)
/*
* FUNCTION: Allocates and initalizes an MDL
* ARGUMENTS:
@ -311,7 +253,7 @@ PMDL STDCALL MmCreateMdl(PMDL MemoryDescriptorList, PVOID Base, ULONG Length)
* Length = Length in bytes of the buffer
* RETURNS: A pointer to initalized MDL
*/
{
{
if (MemoryDescriptorList == NULL)
{
ULONG Size;

View file

@ -1,4 +1,4 @@
; $Id: ntoskrnl.def,v 1.79 2000/07/02 10:47:28 ekohl Exp $
; $Id: ntoskrnl.def,v 1.80 2000/07/02 17:31:32 ekohl Exp $
;
; reactos/ntoskrnl/ntoskrnl.def
;
@ -21,7 +21,6 @@ ExAcquireResourceExclusiveLite@8
ExAcquireResourceSharedLite@8
ExAcquireSharedStarveExclusive@8
ExAcquireSharedWaitForExclusive@8
ExAllocateFromNPagedLookasideList@4
ExAllocateFromPagedLookasideList@4
ExAllocatePool@8
ExAllocatePoolWithQuota@8
@ -38,7 +37,6 @@ ExDesktopObjectType DATA
ExEventObjectType DATA
ExExtendZone@12
ExFreePool@4
ExFreeToNPagedLookasideList@8
ExFreeToPagedLookasideList@8
ExGetExclusiveWaiterCount@4
;ExGetPreviousMode
@ -1002,16 +1000,6 @@ wcsstr
wcstombs
wctomb
;
; ReactOS Extensions (these should be macros!)
;
ExAllocateFromZone@4
ExFreeToZone@8
ExInterlockedAllocateFromZone@8
ExInterlockedFreeToZone@12
ExIsFullZone@4
ExIsObjectInFirstZoneSegment@8
MmGetSystemAddressForMdl
;
;
; exports from hal.dll
;

View file

@ -1,4 +1,4 @@
; $Id: ntoskrnl.edf,v 1.66 2000/07/02 10:47:28 ekohl Exp $
; $Id: ntoskrnl.edf,v 1.67 2000/07/02 17:31:32 ekohl Exp $
;
; reactos/ntoskrnl/ntoskrnl.def
;
@ -21,7 +21,6 @@ ExAcquireResourceExclusiveLite=ExAcquireResourceExclusiveLite@8
ExAcquireResourceSharedLite=ExAcquireResourceSharedLite@8
ExAcquireSharedStarveExclusive=ExAcquireSharedStarveExclusive@8
ExAcquireSharedWaitForExclusive=ExAcquireSharedWaitForExclusive@8
ExAllocateFromNPagedLookasideList=ExAllocateFromNPagedLookasideList@4
ExAllocateFromPagedLookasideList=ExAllocateFromPagedLookasideList@4
ExAllocatePool=ExAllocatePool@8
ExAllocatePoolWithQuota=ExAllocatePoolWithQuota@8
@ -38,7 +37,6 @@ ExDesktopObjectType DATA
ExEventObjectType DATA
ExExtendZone=ExExtendZone@12
ExFreePool=ExFreePool@4
ExFreeToNPagedLookasideList=ExFreeToNPagedLookasideList@8
ExFreeToPagedLookasideList=ExFreeToPagedLookasideList@8
ExGetExclusiveWaiterCount=ExGetExclusiveWaiterCount@4
;ExGetPreviousMode
@ -938,16 +936,6 @@ wcsstr
wcstombs
wctomb
;
; ReactOS Extensions
;
ExAllocateFromZone=ExAllocateFromZone@4
ExFreeToZone=ExFreeToZone@8
ExInterlockedAllocateFromZone=ExInterlockedAllocateFromZone@8
ExInterlockedFreeToZone=ExInterlockedFreeToZone@12
ExIsFullZone=ExIsFullZone@4
ExIsObjectInFirstZoneSegment=ExIsObjectInFirstZoneSegment@8
MmGetSystemAddressForMdl
;
;
; exports from hal.dll
;

View file

@ -1,41 +0,0 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/rtl/unalign.c
* PURPOSE: Unaligned stores and loads
* PROGRAMMER: David Welch (welch@mcmail.com)
* UPDATE HISTORY:
* Created 22/05/98
*/
/* INCLUDES *****************************************************************/
#include <ddk/ntddk.h>
#include <internal/debug.h>
/* FUNCTIONS *****************************************************************/
VOID RtlStoreUlong(PULONG Address,
ULONG Value)
{
*Address=Value;
}
VOID RtlStoreUshort(PUSHORT Address,
USHORT Value)
{
*Address=Value;
}
VOID RtlRetrieveUlong(PULONG DestinationAddress,
PULONG SourceAddress)
{
*DestinationAddress = *SourceAddress;
}
VOID RtlRetrieveUshort(PUSHORT DestinationAddress,
PUSHORT SourceAddress)
{
*DestinationAddress = *SourceAddress;
}