Automatic dependency tracking

svn path=/trunk/; revision=1663
This commit is contained in:
David Welch 2001-03-06 14:41:18 +00:00
parent 2d5f3d1c74
commit 044ab2b0df
6 changed files with 195 additions and 143 deletions

View file

@ -1,4 +1,4 @@
# $Id: Makefile,v 1.8 2001/02/14 02:53:52 dwelch Exp $ # $Id: Makefile,v 1.9 2001/03/06 14:41:18 dwelch Exp $
# #
# ReactOS Operating System # ReactOS Operating System
# #
@ -282,6 +282,12 @@ OBJECTS_KD = \
kd/service.o \ kd/service.o \
kd/dlog.o kd/dlog.o
C_OBJECTS = $(OBJECTS_NT) $(OBJECTS_HAL) $(OBJECTS_MM) $(OBJECTS_MM_I386) \
$(OBJECTS_IO) $(OBJECTS_KE) $(OBJECTS_KE_I386) $(OBJECTS_OB) \
$(OBJECTS_PS) $(OBJECTS_EX) $(OBJECTS_CC) $(OBJECTS_FS) $(OBJECTS_SE) \
$(OBJECTS_DBG) $(OBJECTS_CM) $(OBJECTS_LDR) $(OBJECTS_LPC) \
$(OBJECTS_PO) $(OBJECTS_KD)
# Resources # Resources
OBJECTS_RESOURCE = \ OBJECTS_RESOURCE = \
$(TARGETNAME).coff $(TARGETNAME).coff
@ -445,13 +451,13 @@ CLEAN_FILES = $(OBJECTS_PATH)\*.o cc\*.o cm\*.o dbg\*.o ex\*.o hal\x86\*.o io\*.
ke\*.o ldr\*.o mm\*.o nt\*.o ob\*.o ps\*.o rtl\*.o se\*.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 \ ke\i386\*.o mm\i386\*.o fs\*.o po\*.o nls\*.o lpc\*.o \
kd\*.o $(TARGETNAME).o $(TARGETNAME).a junk.tmp base.tmp temp.exp \ kd\*.o $(TARGETNAME).o $(TARGETNAME).a junk.tmp base.tmp temp.exp \
$(TARGETNAME).exe $(TARGETNAME).nostrip.exe $(TARGETNAME).sym $(TARGETNAME).coff $(TARGETNAME).exe $(TARGETNAME).nostrip.exe $(TARGETNAME).sym $(TARGETNAME).coff $(filter-out nt/zw.%, $(C_OBJECTS:.o=.d))
else else
CLEAN_FILES = $(OBJECTS_PATH)/*.o cc/*.o cm/*.o dbg/*.o ex/*.o hal/x86/*.o io/*.o \ 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/*.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 \ ke/i386/*.o mm/i386/*.o fs/*.o po/*.o nls/*.o lpc/*.o \
kd/*.o $(TARGETNAME).o $(TARGETNAME).a junk.tmp base.tmp temp.exp \ kd/*.o $(TARGETNAME).o $(TARGETNAME).a junk.tmp base.tmp temp.exp \
$(TARGETNAME).exe $(TARGETNAME).nostrip.exe $(TARGETNAME).sym $(TARGETNAME).coff $(TARGETNAME).exe $(TARGETNAME).nostrip.exe $(TARGETNAME).sym $(TARGETNAME).coff $(filter-out nt/zw.%, $(C_OBJECTS:.o=.d))
endif endif
@ -564,6 +570,17 @@ ex/napi.o: ex/napi.c ../include/ntdll/napi.h
ke/main.o: ke/main.c ../include/reactos/buildno.h ke/main.o: ke/main.c ../include/reactos/buildno.h
#include $(filter-out nt/zw.%, $(C_OBJECTS:.o=.d))
%.d: %.c
$(CC) $(CFLAGS) -M -MG $< | sed -e 's#$(*F).o#$(@D)/&#g' | sed -e 's@ /[^ ]*@@g' -e 's@^\(.*\)\.o:@\1.d \1.o:@' > $@
%.d: %.s
$(CC) $(CFLAGS) -M -MG $< | sed -e 's#$(*F).o#$(@D)/&#g' | sed -e 's@ /[^ ]*@@g' -e 's@^\(.*\)\.o:@\1.d \1.o:@' > $@
%.d: %.S
$(CC) $(CFLAGS) -M -MG $< | sed -e 's#$(*F).o#$(@D)/&#g' | sed -e 's@ /[^ ]*@@g' -e 's@^\(.*\)\.o:@\1.d \1.o:@' > $@
include $(PATH_TO_TOP)/rules.mak include $(PATH_TO_TOP)/rules.mak
# EOF # EOF

View file

@ -1,7 +1,6 @@
/* /*
* ReactOS kernel * ReactOS kernel
* Copyright (C) 2000, 1999, 1998 David Welch <welch@cwcom.net> * Copyright (C) 1998, 1999, 2000, 2001 David Welch <welch@cwcom.net>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -17,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* $Id: view.c,v 1.14 2001/02/10 22:51:08 dwelch Exp $ /* $Id: view.c,v 1.15 2001/03/06 14:41:18 dwelch Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel

View file

@ -412,4 +412,7 @@ typedef struct _MM_PAGEOP
ULONG Offset; ULONG Offset;
} MM_PAGEOP, *PMM_PAGEOP; } MM_PAGEOP, *PMM_PAGEOP;
VOID
MiDebugDumpNonPagedPool(VOID);
#endif #endif

View file

@ -1,4 +1,4 @@
/* $Id: npool.c,v 1.33 2001/01/08 02:14:06 dwelch Exp $ /* $Id: npool.c,v 1.34 2001/03/06 14:41:18 dwelch Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -47,14 +47,15 @@
/* /*
* fields present at the start of a block (this is for internal use only) * fields present at the start of a block (this is for internal use only)
*/ */
typedef struct _block_hdr typedef struct _BLOCK_HDR
{ {
ULONG magic; ULONG magic;
ULONG size; ULONG size;
struct _block_hdr* previous; struct _BLOCK_HDR* previous;
struct _block_hdr* next; struct _BLOCK_HDR* next;
ULONG tag; ULONG Tag;
} block_hdr; PVOID Caller;
} BLOCK_HDR;
/* GLOBALS *****************************************************************/ /* GLOBALS *****************************************************************/
@ -66,8 +67,8 @@ static unsigned int kernel_pool_base = 0;
/* /*
* Pointer to the first block in the free list * Pointer to the first block in the free list
*/ */
static block_hdr* free_list_head = NULL; static BLOCK_HDR* free_list_head = NULL;
static block_hdr* used_list_head = NULL; static BLOCK_HDR* used_list_head = NULL;
static ULONG nr_free_blocks; static ULONG nr_free_blocks;
ULONG EiNrUsedBlocks = 0; ULONG EiNrUsedBlocks = 0;
@ -88,13 +89,33 @@ VOID ExInitNonPagedPool(ULONG BaseAddress)
MmInitKernelMap((PVOID)BaseAddress); MmInitKernelMap((PVOID)BaseAddress);
} }
VOID
MiDebugDumpNonPagedPool(VOID)
{
BLOCK_HDR* current = used_list_head;
KIRQL oldIrql;
KeAcquireSpinLock(&MmNpoolLock, &oldIrql);
DbgPrint("******* Dumping non paging pool contents ******\n");
while (current!=NULL)
{
DPRINT("Size 0x%x Tag 0x%x Allocator 0x%x\n",
current->size, current->Tag, current->Caller);
current=current->next;
}
DbgPrint("***************** Dump Complete ***************\n");
KeReleaseSpinLock(&MmNpoolLock, oldIrql);
}
#if 0 #if 0
static void validate_free_list(void) static void validate_free_list(void)
/* /*
* FUNCTION: Validate the integrity of the list of free blocks * FUNCTION: Validate the integrity of the list of free blocks
*/ */
{ {
block_hdr* current=free_list_head; BLOCK_HDR* current=free_list_head;
unsigned int blocks_seen=0; unsigned int blocks_seen=0;
while (current!=NULL) while (current!=NULL)
@ -134,7 +155,7 @@ static void validate_free_list(void)
KeBugCheck(KBUG_POOL_FREE_LIST_CORRUPT); KeBugCheck(KBUG_POOL_FREE_LIST_CORRUPT);
} }
current=current->next; current=current->next;
} }
} }
static void validate_used_list(void) static void validate_used_list(void)
@ -142,7 +163,7 @@ static void validate_used_list(void)
* FUNCTION: Validate the integrity of the list of used blocks * FUNCTION: Validate the integrity of the list of used blocks
*/ */
{ {
block_hdr* current=used_list_head; BLOCK_HDR* current=used_list_head;
unsigned int blocks_seen=0; unsigned int blocks_seen=0;
while (current!=NULL) while (current!=NULL)
@ -179,7 +200,7 @@ static void validate_used_list(void)
} }
} }
static void check_duplicates(block_hdr* blk) static void check_duplicates(BLOCK_HDR* blk)
/* /*
* FUNCTION: Check a block has no duplicates * FUNCTION: Check a block has no duplicates
* ARGUMENTS: * ARGUMENTS:
@ -188,9 +209,9 @@ static void check_duplicates(block_hdr* blk)
*/ */
{ {
unsigned int base = (int)blk; unsigned int base = (int)blk;
unsigned int last = ((int)blk) + +sizeof(block_hdr) + blk->size; unsigned int last = ((int)blk) + +sizeof(BLOCK_HDR) + blk->size;
block_hdr* current=free_list_head; BLOCK_HDR* current=free_list_head;
while (current!=NULL) while (current!=NULL)
{ {
if (current->magic != BLOCK_HDR_MAGIC) if (current->magic != BLOCK_HDR_MAGIC)
@ -206,7 +227,7 @@ static void check_duplicates(block_hdr* blk)
for(;;); for(;;);
} }
if ( (int)current < base && if ( (int)current < base &&
((int)current + current->size + sizeof(block_hdr)) ((int)current + current->size + sizeof(BLOCK_HDR))
> base ) > base )
{ {
DbgPrint("intersecting blocks on list\n"); DbgPrint("intersecting blocks on list\n");
@ -223,7 +244,7 @@ static void check_duplicates(block_hdr* blk)
for(;;); for(;;);
} }
if ( (int)current < base && if ( (int)current < base &&
((int)current + current->size + sizeof(block_hdr)) ((int)current + current->size + sizeof(BLOCK_HDR))
> base ) > base )
{ {
DbgPrint("intersecting blocks on list\n"); DbgPrint("intersecting blocks on list\n");
@ -239,7 +260,7 @@ static void validate_kernel_pool(void)
* FUNCTION: Checks the integrity of the kernel memory heap * FUNCTION: Checks the integrity of the kernel memory heap
*/ */
{ {
block_hdr* current=NULL; BLOCK_HDR* current=NULL;
validate_free_list(); validate_free_list();
validate_used_list(); validate_used_list();
@ -259,7 +280,7 @@ static void validate_kernel_pool(void)
} }
#endif #endif
static void add_to_free_list(block_hdr* blk) static void add_to_free_list(BLOCK_HDR* blk)
/* /*
* FUNCTION: add the block to the free list (internal) * FUNCTION: add the block to the free list (internal)
*/ */
@ -274,7 +295,7 @@ static void add_to_free_list(block_hdr* blk)
nr_free_blocks++; nr_free_blocks++;
} }
static void add_to_used_list(block_hdr* blk) static void add_to_used_list(BLOCK_HDR* blk)
/* /*
* FUNCTION: add the block to the used list (internal) * FUNCTION: add the block to the used list (internal)
*/ */
@ -290,7 +311,7 @@ static void add_to_used_list(block_hdr* blk)
} }
static void remove_from_free_list(block_hdr* current) static void remove_from_free_list(BLOCK_HDR* current)
{ {
if (current->next==NULL&&current->previous==NULL) if (current->next==NULL&&current->previous==NULL)
{ {
@ -317,7 +338,7 @@ static void remove_from_free_list(block_hdr* current)
} }
static void remove_from_used_list(block_hdr* current) static void remove_from_used_list(BLOCK_HDR* current)
{ {
if (current->next==NULL&&current->previous==NULL) if (current->next==NULL&&current->previous==NULL)
{ {
@ -347,32 +368,32 @@ static void remove_from_used_list(block_hdr* current)
} }
inline static void* block_to_address(block_hdr* blk) inline static void* block_to_address(BLOCK_HDR* blk)
/* /*
* FUNCTION: Translate a block header address to the corresponding block * FUNCTION: Translate a block header address to the corresponding block
* address (internal) * address (internal)
*/ */
{ {
return ( (void *) ((int)blk + sizeof(block_hdr)) ); return ( (void *) ((int)blk + sizeof(BLOCK_HDR)) );
} }
inline static block_hdr* address_to_block(void* addr) inline static BLOCK_HDR* address_to_block(void* addr)
{ {
return (block_hdr *) return (BLOCK_HDR *)
( ((int)addr) - sizeof(block_hdr) ); ( ((int)addr) - sizeof(BLOCK_HDR) );
} }
static block_hdr* grow_kernel_pool(unsigned int size) static BLOCK_HDR* grow_kernel_pool(unsigned int size, ULONG Tag, PVOID Caller)
/* /*
* FUNCTION: Grow the executive heap to accomodate a block of at least 'size' * FUNCTION: Grow the executive heap to accomodate a block of at least 'size'
* bytes * bytes
*/ */
{ {
unsigned int total_size = size + sizeof(block_hdr); unsigned int total_size = size + sizeof(BLOCK_HDR);
unsigned int nr_pages = PAGE_ROUND_UP(total_size) / PAGESIZE; unsigned int nr_pages = PAGE_ROUND_UP(total_size) / PAGESIZE;
unsigned int start = alloc_pool_region(nr_pages); unsigned int start = alloc_pool_region(nr_pages);
block_hdr* used_blk=NULL; BLOCK_HDR* used_blk=NULL;
block_hdr* free_blk=NULL; BLOCK_HDR* free_blk=NULL;
int i; int i;
NTSTATUS Status; NTSTATUS Status;
@ -393,18 +414,18 @@ static block_hdr* grow_kernel_pool(unsigned int size)
} }
if ((PAGESIZE-(total_size%PAGESIZE))>(2*sizeof(block_hdr))) if ((PAGESIZE-(total_size%PAGESIZE))>(2*sizeof(BLOCK_HDR)))
{ {
used_blk = (struct _block_hdr *)start; used_blk = (struct _BLOCK_HDR *)start;
OLD_DPRINT("Creating block at %x\n",start); OLD_DPRINT("Creating block at %x\n",start);
used_blk->magic = BLOCK_HDR_MAGIC; used_blk->magic = BLOCK_HDR_MAGIC;
used_blk->size = size; used_blk->size = size;
add_to_used_list(used_blk); add_to_used_list(used_blk);
free_blk = (block_hdr *)(start + sizeof(block_hdr) + size); free_blk = (BLOCK_HDR *)(start + sizeof(BLOCK_HDR) + size);
OLD_DPRINT("Creating block at %x\n",free_blk); OLD_DPRINT("Creating block at %x\n",free_blk);
free_blk->magic = BLOCK_HDR_MAGIC; free_blk->magic = BLOCK_HDR_MAGIC;
free_blk->size = (nr_pages * PAGESIZE) -((sizeof(block_hdr)*2) + size); free_blk->size = (nr_pages * PAGESIZE) -((sizeof(BLOCK_HDR)*2) + size);
add_to_free_list(free_blk); add_to_free_list(free_blk);
EiFreeNonPagedPool = EiFreeNonPagedPool + free_blk->size; EiFreeNonPagedPool = EiFreeNonPagedPool + free_blk->size;
@ -412,19 +433,23 @@ static block_hdr* grow_kernel_pool(unsigned int size)
} }
else else
{ {
used_blk = (struct _block_hdr *)start; used_blk = (struct _BLOCK_HDR *)start;
used_blk->magic = BLOCK_HDR_MAGIC; used_blk->magic = BLOCK_HDR_MAGIC;
used_blk->size = (nr_pages * PAGESIZE) - sizeof(block_hdr); used_blk->size = (nr_pages * PAGESIZE) - sizeof(BLOCK_HDR);
add_to_used_list(used_blk); add_to_used_list(used_blk);
EiUsedNonPagedPool = EiUsedNonPagedPool + used_blk->size; EiUsedNonPagedPool = EiUsedNonPagedPool + used_blk->size;
} }
used_blk->Tag = Tag;
used_blk->Caller = Caller;
VALIDATE_POOL; VALIDATE_POOL;
return(used_blk); return(used_blk);
} }
static void* take_block(block_hdr* current, unsigned int size) static void* take_block(BLOCK_HDR* current, unsigned int size,
ULONG Tag, PVOID Caller)
/* /*
* FUNCTION: Allocate a used block of least 'size' from the specified * FUNCTION: Allocate a used block of least 'size' from the specified
* free block * free block
@ -437,9 +462,9 @@ static void* take_block(block_hdr* current, unsigned int size)
* between the sizes is marginal it makes no sense to have the * between the sizes is marginal it makes no sense to have the
* extra overhead * extra overhead
*/ */
if (current->size > (1 + size + sizeof(block_hdr))) if (current->size > (1 + size + sizeof(BLOCK_HDR)))
{ {
block_hdr* free_blk; BLOCK_HDR* free_blk;
EiFreeNonPagedPool = EiFreeNonPagedPool - current->size; EiFreeNonPagedPool = EiFreeNonPagedPool - current->size;
@ -447,8 +472,8 @@ static void* take_block(block_hdr* current, unsigned int size)
* Replace the bigger block with a smaller block in the * Replace the bigger block with a smaller block in the
* same position in the list * same position in the list
*/ */
free_blk = (block_hdr *)(((int)current) free_blk = (BLOCK_HDR *)(((int)current)
+ sizeof(block_hdr) + size); + sizeof(BLOCK_HDR) + size);
free_blk->magic = BLOCK_HDR_MAGIC; free_blk->magic = BLOCK_HDR_MAGIC;
free_blk->next = current->next; free_blk->next = current->next;
free_blk->previous = current->previous; free_blk->previous = current->previous;
@ -460,11 +485,11 @@ static void* take_block(block_hdr* current, unsigned int size)
{ {
current->previous->next = free_blk; current->previous->next = free_blk;
} }
free_blk->size = current->size - (sizeof(block_hdr) + size); free_blk->size = current->size - (sizeof(BLOCK_HDR) + size);
if (current==free_list_head) if (current==free_list_head)
{ {
free_list_head=free_blk; free_list_head=free_blk;
} }
current->size=size; current->size=size;
add_to_used_list(current); add_to_used_list(current);
@ -485,6 +510,9 @@ static void* take_block(block_hdr* current, unsigned int size)
EiFreeNonPagedPool = EiFreeNonPagedPool - current->size; EiFreeNonPagedPool = EiFreeNonPagedPool - current->size;
EiUsedNonPagedPool = EiUsedNonPagedPool + current->size; EiUsedNonPagedPool = EiUsedNonPagedPool + current->size;
current->Tag = Tag;
current->Caller = Caller;
VALIDATE_POOL; VALIDATE_POOL;
return(block_to_address(current)); return(block_to_address(current));
} }
@ -496,7 +524,7 @@ VOID STDCALL ExFreePool (PVOID block)
* block = block to free * block = block to free
*/ */
{ {
block_hdr* blk=address_to_block(block); BLOCK_HDR* blk=address_to_block(block);
KIRQL oldIrql; KIRQL oldIrql;
OLD_DPRINT("(%s:%d) freeing block %x\n",__FILE__,__LINE__,blk); OLD_DPRINT("(%s:%d) freeing block %x\n",__FILE__,__LINE__,blk);
@ -531,30 +559,27 @@ VOID STDCALL ExFreePool (PVOID block)
KeReleaseSpinLock(&MmNpoolLock, oldIrql); KeReleaseSpinLock(&MmNpoolLock, oldIrql);
} }
PVOID STDCALL ExAllocateNonPagedPoolWithTag(ULONG type, PVOID STDCALL ExAllocateNonPagedPoolWithTag(ULONG Type,
ULONG size, ULONG Size,
ULONG Tag, ULONG Tag,
PVOID Caller) PVOID Caller)
{ {
block_hdr* current = NULL; BLOCK_HDR* current = NULL;
PVOID block; PVOID block;
block_hdr* best = NULL; BLOCK_HDR* best = NULL;
KIRQL oldIrql; KIRQL oldIrql;
POOL_TRACE("ExAllocatePool(NumberOfBytes %d) caller %x ", POOL_TRACE("ExAllocatePool(NumberOfBytes %d) caller %x ",
size,Caller); Size,Caller);
KeAcquireSpinLock(&MmNpoolLock, &oldIrql); KeAcquireSpinLock(&MmNpoolLock, &oldIrql);
// DbgPrint("Blocks on free list %d\n",nr_free_blocks);
// DbgPrint("Blocks on used list %d\n",eiNrUsedblocks);
// OLD_DPRINT("ExAllocateNonPagedPool(type %d, size %d)\n",type,size);
VALIDATE_POOL; VALIDATE_POOL;
/* /*
* accomodate this useful idiom * accomodate this useful idiom
*/ */
if (size==0) if (Size == 0)
{ {
POOL_TRACE("= NULL\n"); POOL_TRACE("= NULL\n");
KeReleaseSpinLock(&MmNpoolLock, oldIrql); KeReleaseSpinLock(&MmNpoolLock, oldIrql);
@ -572,7 +597,7 @@ PVOID STDCALL ExAllocateNonPagedPoolWithTag(ULONG type,
{ {
OLD_DPRINT("current %x size %x next %x\n",current,current->size, OLD_DPRINT("current %x size %x next %x\n",current,current->size,
current->next); current->next);
if (current->size>=size && if (current->size>=Size &&
(best == NULL || (best == NULL ||
current->size < best->size)) current->size < best->size))
{ {
@ -583,9 +608,9 @@ PVOID STDCALL ExAllocateNonPagedPoolWithTag(ULONG type,
if (best != NULL) if (best != NULL)
{ {
OLD_DPRINT("found block %x of size %d\n",best,size); OLD_DPRINT("found block %x of size %d\n",best,size);
block=take_block(best,size); block=take_block(best, Size, Tag, Caller);
VALIDATE_POOL; VALIDATE_POOL;
memset(block,0,size); memset(block,0,Size);
POOL_TRACE("= %x\n",block); POOL_TRACE("= %x\n",block);
KeReleaseSpinLock(&MmNpoolLock, oldIrql); KeReleaseSpinLock(&MmNpoolLock, oldIrql);
return(block); return(block);
@ -595,9 +620,9 @@ PVOID STDCALL ExAllocateNonPagedPoolWithTag(ULONG type,
/* /*
* Otherwise create a new block * Otherwise create a new block
*/ */
block=block_to_address(grow_kernel_pool(size)); block=block_to_address(grow_kernel_pool(Size, Tag, Caller));
VALIDATE_POOL; VALIDATE_POOL;
memset(block,0,size); memset(block,0,Size);
POOL_TRACE("= %x\n",block); POOL_TRACE("= %x\n",block);
KeReleaseSpinLock(&MmNpoolLock, oldIrql); KeReleaseSpinLock(&MmNpoolLock, oldIrql);
return(block); return(block);

View file

@ -1,4 +1,4 @@
/* $Id: pool.c,v 1.10 2000/03/01 22:52:28 ea Exp $ /* $Id: pool.c,v 1.11 2001/03/06 14:41:18 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,6 +22,50 @@
/* FUNCTIONS ***************************************************************/ /* FUNCTIONS ***************************************************************/
PVOID STDCALL STATIC
EiAllocatePool(POOL_TYPE PoolType,
ULONG NumberOfBytes,
ULONG Tag,
PVOID Caller)
{
PVOID Block;
if (PoolType == NonPagedPoolCacheAligned ||
PoolType == NonPagedPoolCacheAlignedMustS)
{
UNIMPLEMENTED;
}
switch(PoolType)
{
case NonPagedPool:
case NonPagedPoolMustSucceed:
case NonPagedPoolCacheAligned:
case NonPagedPoolCacheAlignedMustS:
Block =
ExAllocateNonPagedPoolWithTag(PoolType,
NumberOfBytes,
Tag,
Caller);
break;
case PagedPool:
case PagedPoolCacheAligned:
Block = ExAllocatePagedPoolWithTag(PoolType,NumberOfBytes,Tag);
break;
default:
return(NULL);
};
if ((PoolType==NonPagedPoolMustSucceed ||
PoolType==NonPagedPoolCacheAlignedMustS) && Block==NULL)
{
KeBugCheck(MUST_SUCCEED_POOL_EMPTY);
}
return(Block);
}
PVOID PVOID
STDCALL STDCALL
ExAllocatePool (POOL_TYPE PoolType, ULONG NumberOfBytes) ExAllocatePool (POOL_TYPE PoolType, ULONG NumberOfBytes)
@ -48,52 +92,22 @@ ExAllocatePool (POOL_TYPE PoolType, ULONG NumberOfBytes)
*/ */
{ {
PVOID Block; PVOID Block;
Block = ExAllocateNonPagedPoolWithTag(PoolType, Block = EiAllocatePool(PoolType,
NumberOfBytes, NumberOfBytes,
TAG_NONE, TAG_NONE,
(PVOID)(&PoolType)[-1]); (PVOID)__builtin_return_address(0));
return(Block); return(Block);
} }
PVOID PVOID STDCALL
STDCALL
ExAllocatePoolWithTag (ULONG PoolType, ULONG NumberOfBytes, ULONG Tag) ExAllocatePoolWithTag (ULONG PoolType, ULONG NumberOfBytes, ULONG Tag)
{ {
PVOID Block; PVOID Block;
Block = EiAllocatePool(PoolType,
if (PoolType == NonPagedPoolCacheAligned || NumberOfBytes,
PoolType == NonPagedPoolCacheAlignedMustS) Tag,
{ (PVOID)__builtin_return_address(0));
UNIMPLEMENTED;
}
switch(PoolType)
{
case NonPagedPool:
case NonPagedPoolMustSucceed:
case NonPagedPoolCacheAligned:
case NonPagedPoolCacheAlignedMustS:
Block = ExAllocateNonPagedPoolWithTag(PoolType,
NumberOfBytes,
Tag,
(PVOID)(&PoolType)[-1]);
break;
case PagedPool:
case PagedPoolCacheAligned:
Block = ExAllocatePagedPoolWithTag(PoolType,NumberOfBytes,Tag);
break;
default:
return(NULL);
};
if ((PoolType==NonPagedPoolMustSucceed ||
PoolType==NonPagedPoolCacheAlignedMustS) && Block==NULL)
{
KeBugCheck(MUST_SUCCEED_POOL_EMPTY);
}
return(Block); return(Block);
} }
@ -102,28 +116,32 @@ PVOID
STDCALL STDCALL
ExAllocatePoolWithQuota (POOL_TYPE PoolType, ULONG NumberOfBytes) ExAllocatePoolWithQuota (POOL_TYPE PoolType, ULONG NumberOfBytes)
{ {
// return(ExAllocatePoolWithQuotaTag(PoolType,NumberOfBytes,TAG_NONE)); #if 0
UNIMPLEMENTED; PVOID Block;
Block = EiAllocatePool(PoolType,
NumberOfBytes,
TAG_NONE,
(PVOID)__builtin_return_address(0));
return(Block);
#endif
UNIMPLEMENTED;
} }
PVOID PVOID STDCALL
STDCALL ExAllocatePoolWithQuotaTag (IN POOL_TYPE PoolType,
ExAllocatePoolWithQuotaTag ( IN ULONG NumberOfBytes,
IN POOL_TYPE PoolType, IN ULONG Tag)
IN ULONG NumberOfBytes,
IN ULONG Tag
)
{ {
PVOID Address = NULL; #if 0
PVOID Block;
UNIMPLEMENTED; /* FIXME */ Block = EiAllocatePool(PoolType,
NumberOfBytes,
if (NULL == Address) Tag,
{ (PVOID)__builtin_return_address(0));
ExRaiseStatus (STATUS_INSUFFICIENT_RESOURCES); return(Block);
} #endif
return Address; UNIMPLEMENTED;
} }

View file

@ -1,4 +1,4 @@
/* $Id: ppool.c,v 1.2 2000/03/01 22:52:28 ea Exp $ /* $Id: ppool.c,v 1.3 2001/03/06 14:41:18 dwelch Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -29,23 +29,13 @@
* *
* RETURN VALUE * RETURN VALUE
*/ */
PVOID PVOID STDCALL
STDCALL ExAllocatePagedPoolWithTag (IN POOL_TYPE PoolType,
ExAllocatePagedPoolWithTag ( IN ULONG NumberOfBytes,
IN POOL_TYPE PoolType, IN ULONG Tag)
IN ULONG NumberOfBytes,
IN ULONG Tag
)
{ {
PVOID Address = NULL; UNIMPLEMENTED; /* FIXME: */
return(NULL);
UNIMPLEMENTED; /* FIXME: */
if (NULL == Address)
{
ExRaiseStatus (STATUS_INSUFFICIENT_RESOURCES);
}
return Address;
} }