Removed bitops.h

svn path=/trunk/; revision=2419
This commit is contained in:
David Welch 2001-12-06 00:54:54 +00:00
parent 909d916ca5
commit 8c3f4003e7
7 changed files with 31 additions and 57 deletions

View file

@ -9,7 +9,6 @@
/* INCLUDES *****************************************************************/ /* INCLUDES *****************************************************************/
#include <ddk/ntddk.h> #include <ddk/ntddk.h>
#include <internal/bitops.h>
#include <internal/ke.h> #include <internal/ke.h>
#include <internal/ps.h> #include <internal/ps.h>

View file

@ -1,30 +0,0 @@
#ifndef _I386_BITOPS_H
#define _I386_BITOPS_H
/*
* Copyright 1992, Linus Torvalds.
*/
/*
* These have to be done with inline assembly: that way the bit-setting
* is guaranteed to be atomic. All bit operations return 0 if the bit
* was cleared before the operation and != 0 if it was not.
*
* bit 0 is the LSB of addr; bit 32 is the LSB of (addr+1).
*/
/*
* Function prototypes to keep gcc -Wall happy
*/
extern void set_bit(int nr, volatile void * addr);
extern void clear_bit(int nr, volatile void * addr);
extern void change_bit(int nr, volatile void * addr);
extern int test_and_set_bit(int nr, volatile void * addr);
extern int test_and_clear_bit(int nr, volatile void * addr);
extern int test_and_change_bit(int nr, volatile void * addr);
extern int test_bit(int nr, volatile void * addr);
extern int find_first_zero_bit(void * addr, unsigned size);
extern int find_next_zero_bit (void * addr, int size, int offset);
extern unsigned long ffz(unsigned long word);
#endif /* _I386_BITOPS_H */

View file

@ -1,4 +1,4 @@
/* $Id: kmap.c,v 1.11 2001/11/25 15:21:11 dwelch Exp $ /* $Id: kmap.c,v 1.12 2001/12/06 00:54:54 dwelch Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -11,7 +11,6 @@
#include <ddk/ntddk.h> #include <ddk/ntddk.h>
#include <internal/mm.h> #include <internal/mm.h>
#include <internal/bitops.h>
#include <internal/ntoskrnl.h> #include <internal/ntoskrnl.h>
#include <internal/pool.h> #include <internal/pool.h>
@ -44,7 +43,7 @@ ExUnmapPage(PVOID Addr)
KeAcquireSpinLock(&AllocMapLock, &oldIrql); KeAcquireSpinLock(&AllocMapLock, &oldIrql);
MmDeleteVirtualMapping(NULL, (PVOID)Addr, FALSE, NULL, NULL); MmDeleteVirtualMapping(NULL, (PVOID)Addr, FALSE, NULL, NULL);
clear_bit(i%32, &AllocMap[i/32]); AllocMap[i / 32] &= (~(1 << (i % 32)));
KeReleaseSpinLock(&AllocMapLock, oldIrql); KeReleaseSpinLock(&AllocMapLock, oldIrql);
} }
@ -103,10 +102,10 @@ ExAllocatePageWithPhysPage(ULONG PhysPage)
KeAcquireSpinLock(&AllocMapLock, &oldlvl); KeAcquireSpinLock(&AllocMapLock, &oldlvl);
for (i = 1; i < ALLOC_MAP_SIZE; i++) for (i = 1; i < ALLOC_MAP_SIZE; i++)
{ {
if (!test_bit(i % 32, &AllocMap[i / 32])) if (!(AllocMap[i / 32] & (1 << (i % 32))))
{ {
DPRINT("i %x\n",i); DPRINT("i %x\n",i);
set_bit(i % 32, &AllocMap[i / 32]); AllocMap[i / 32] |= (1 << (i % 32));
addr = (ULONG)(NonPagedPoolBase + (i*PAGESIZE)); addr = (ULONG)(NonPagedPoolBase + (i*PAGESIZE));
Status = MmCreateVirtualMapping(NULL, Status = MmCreateVirtualMapping(NULL,
(PVOID)addr, (PVOID)addr,
@ -137,10 +136,12 @@ MiFreeNonPagedPoolRegion(PVOID Addr, ULONG Count, BOOLEAN Free)
{ {
ULONG i; ULONG i;
ULONG Base = (Addr - NonPagedPoolBase) / PAGESIZE; ULONG Base = (Addr - NonPagedPoolBase) / PAGESIZE;
ULONG Offset;
for (i = 0; i < Count; i++) for (i = 0; i < Count; i++)
{ {
clear_bit((Base + i) % 32, &AllocMap[(Base + i) / 32]); Offset = Base + i;
AllocMap[Offset / 32] &= (~(1 << (Offset % 32)));
MmDeleteVirtualMapping(NULL, MmDeleteVirtualMapping(NULL,
Addr + (i * PAGESIZE), Addr + (i * PAGESIZE),
Free, Free,
@ -161,7 +162,7 @@ MiAllocNonPagedPoolRegion(ULONG nr_pages)
for (i=1; i<ALLOC_MAP_SIZE;i++) for (i=1; i<ALLOC_MAP_SIZE;i++)
{ {
if (!test_bit(i%32,&AllocMap[i/32])) if (!(AllocMap[i/32] & (1 << (i % 32))))
{ {
if (length == 0) if (length == 0)
{ {
@ -176,7 +177,7 @@ MiAllocNonPagedPoolRegion(ULONG nr_pages)
{ {
for (j=start;j<(start+length);j++) for (j=start;j<(start+length);j++)
{ {
set_bit(j%32,&AllocMap[j/32]); AllocMap[j / 32] |= (1 << (j % 32));
} }
DPRINT("returning %x\n",((start*PAGESIZE)+NonPagedPoolBase)); DPRINT("returning %x\n",((start*PAGESIZE)+NonPagedPoolBase));
return(((start*PAGESIZE)+NonPagedPoolBase)); return(((start*PAGESIZE)+NonPagedPoolBase));

View file

@ -16,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: mm.c,v 1.48 2001/04/09 02:45:04 dwelch Exp $ /* $Id: mm.c,v 1.49 2001/12/06 00:54:54 dwelch Exp $
* *
* COPYRIGHT: See COPYING in the top directory * COPYRIGHT: See COPYING in the top directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -33,7 +33,6 @@
#include <internal/i386/segment.h> #include <internal/i386/segment.h>
#include <internal/mm.h> #include <internal/mm.h>
#include <internal/ntoskrnl.h> #include <internal/ntoskrnl.h>
#include <internal/bitops.h>
#include <internal/io.h> #include <internal/io.h>
#include <internal/ps.h> #include <internal/ps.h>

View file

@ -1,4 +1,4 @@
/* $Id: mminit.c,v 1.26 2001/11/25 15:21:11 dwelch Exp $ /* $Id: mminit.c,v 1.27 2001/12/06 00:54:54 dwelch Exp $
* *
* COPYRIGHT: See COPYING in the top directory * COPYRIGHT: See COPYING in the top directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -16,7 +16,6 @@
#include <internal/i386/segment.h> #include <internal/i386/segment.h>
#include <internal/mm.h> #include <internal/mm.h>
#include <internal/ntoskrnl.h> #include <internal/ntoskrnl.h>
#include <internal/bitops.h>
#include <internal/io.h> #include <internal/io.h>
#include <internal/ps.h> #include <internal/ps.h>
#include <napi/shared_data.h> #include <napi/shared_data.h>

View file

@ -1,4 +1,4 @@
/* $Id: npool.c,v 1.49 2001/11/25 15:21:11 dwelch Exp $ /* $Id: npool.c,v 1.50 2001/12/06 00:54:54 dwelch Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -18,7 +18,6 @@
#include <ddk/ntddk.h> #include <ddk/ntddk.h>
#include <internal/mm.h> #include <internal/mm.h>
#include <internal/bitops.h>
#include <internal/ntoskrnl.h> #include <internal/ntoskrnl.h>
#include <internal/pool.h> #include <internal/pool.h>

View file

@ -16,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: pagefile.c,v 1.12 2001/10/10 21:57:00 hbirr Exp $ /* $Id: pagefile.c,v 1.13 2001/12/06 00:54:54 dwelch Exp $
* *
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
* FILE: ntoskrnl/mm/pagefile.c * FILE: ntoskrnl/mm/pagefile.c
@ -29,7 +29,6 @@
/* INCLUDES *****************************************************************/ /* INCLUDES *****************************************************************/
#include <ddk/ntddk.h> #include <ddk/ntddk.h>
#include <internal/bitops.h>
#include <internal/io.h> #include <internal/io.h>
#include <internal/mm.h> #include <internal/mm.h>
#include <napi/core.h> #include <napi/core.h>
@ -204,20 +203,28 @@ static ULONG
MiAllocPageFromPagingFile(PPAGINGFILE PagingFile) MiAllocPageFromPagingFile(PPAGINGFILE PagingFile)
{ {
KIRQL oldIrql; KIRQL oldIrql;
ULONG i; ULONG i, j;
ULONG off;
KeAcquireSpinLock(&PagingFile->AllocMapLock, &oldIrql); KeAcquireSpinLock(&PagingFile->AllocMapLock, &oldIrql);
for (i = 0; i < PagingFile->AllocMapSize; i++) for (i = 0; i < PagingFile->AllocMapSize; i++)
{ {
off = find_first_zero_bit(PagingFile->AllocMap, for (j = 0; j < 32; j++)
PagingFile->AllocMapSize * 32); {
clear_bit(off % 32, &PagingFile->AllocMap[off / 32]); if (!(PagingFile->AllocMap[i] & (1 << j)))
PagingFile->UsedPages--; {
PagingFile->FreePages++; break;
KeReleaseSpinLock(&PagingFile->AllocMapLock, oldIrql); }
return(off); }
if (j == 32)
{
continue;
}
PagingFile->AllocMap[i] |= (1 << j);
PagingFile->UsedPages--;
PagingFile->FreePages++;
KeReleaseSpinLock(&PagingFile->AllocMapLock, oldIrql);
return((i * 32) + j);
} }
KeReleaseSpinLock(&PagingFile->AllocMapLock, oldIrql); KeReleaseSpinLock(&PagingFile->AllocMapLock, oldIrql);
@ -237,7 +244,7 @@ MmFreeSwapPage(SWAPENTRY Entry)
KeAcquireSpinLock(&PagingFileListLock, &oldIrql); KeAcquireSpinLock(&PagingFileListLock, &oldIrql);
KeAcquireSpinLockAtDpcLevel(&PagingFileList[i]->AllocMapLock); KeAcquireSpinLockAtDpcLevel(&PagingFileList[i]->AllocMapLock);
set_bit(off % 32, &PagingFileList[i]->AllocMap[off / 32]); PagingFileList[i]->AllocMap[off / 32] |= (1 << (off % 32));
PagingFileList[i]->FreePages++; PagingFileList[i]->FreePages++;
PagingFileList[i]->UsedPages--; PagingFileList[i]->UsedPages--;