mirror of
https://github.com/reactos/reactos.git
synced 2024-12-27 09:34:43 +00:00
Removed bitops.h
svn path=/trunk/; revision=2419
This commit is contained in:
parent
909d916ca5
commit
8c3f4003e7
7 changed files with 31 additions and 57 deletions
|
@ -9,7 +9,6 @@
|
|||
/* INCLUDES *****************************************************************/
|
||||
|
||||
#include <ddk/ntddk.h>
|
||||
#include <internal/bitops.h>
|
||||
#include <internal/ke.h>
|
||||
#include <internal/ps.h>
|
||||
|
||||
|
|
|
@ -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 */
|
|
@ -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
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -11,7 +11,6 @@
|
|||
|
||||
#include <ddk/ntddk.h>
|
||||
#include <internal/mm.h>
|
||||
#include <internal/bitops.h>
|
||||
#include <internal/ntoskrnl.h>
|
||||
#include <internal/pool.h>
|
||||
|
||||
|
@ -44,7 +43,7 @@ ExUnmapPage(PVOID Addr)
|
|||
|
||||
KeAcquireSpinLock(&AllocMapLock, &oldIrql);
|
||||
MmDeleteVirtualMapping(NULL, (PVOID)Addr, FALSE, NULL, NULL);
|
||||
clear_bit(i%32, &AllocMap[i/32]);
|
||||
AllocMap[i / 32] &= (~(1 << (i % 32)));
|
||||
KeReleaseSpinLock(&AllocMapLock, oldIrql);
|
||||
}
|
||||
|
||||
|
@ -103,10 +102,10 @@ ExAllocatePageWithPhysPage(ULONG PhysPage)
|
|||
KeAcquireSpinLock(&AllocMapLock, &oldlvl);
|
||||
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);
|
||||
set_bit(i % 32, &AllocMap[i / 32]);
|
||||
AllocMap[i / 32] |= (1 << (i % 32));
|
||||
addr = (ULONG)(NonPagedPoolBase + (i*PAGESIZE));
|
||||
Status = MmCreateVirtualMapping(NULL,
|
||||
(PVOID)addr,
|
||||
|
@ -137,10 +136,12 @@ MiFreeNonPagedPoolRegion(PVOID Addr, ULONG Count, BOOLEAN Free)
|
|||
{
|
||||
ULONG i;
|
||||
ULONG Base = (Addr - NonPagedPoolBase) / PAGESIZE;
|
||||
ULONG Offset;
|
||||
|
||||
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,
|
||||
Addr + (i * PAGESIZE),
|
||||
Free,
|
||||
|
@ -161,7 +162,7 @@ MiAllocNonPagedPoolRegion(ULONG nr_pages)
|
|||
|
||||
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)
|
||||
{
|
||||
|
@ -176,7 +177,7 @@ MiAllocNonPagedPoolRegion(ULONG nr_pages)
|
|||
{
|
||||
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));
|
||||
return(((start*PAGESIZE)+NonPagedPoolBase));
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* 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
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -33,7 +33,6 @@
|
|||
#include <internal/i386/segment.h>
|
||||
#include <internal/mm.h>
|
||||
#include <internal/ntoskrnl.h>
|
||||
#include <internal/bitops.h>
|
||||
#include <internal/io.h>
|
||||
#include <internal/ps.h>
|
||||
|
||||
|
|
|
@ -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
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -16,7 +16,6 @@
|
|||
#include <internal/i386/segment.h>
|
||||
#include <internal/mm.h>
|
||||
#include <internal/ntoskrnl.h>
|
||||
#include <internal/bitops.h>
|
||||
#include <internal/io.h>
|
||||
#include <internal/ps.h>
|
||||
#include <napi/shared_data.h>
|
||||
|
|
|
@ -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
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -18,7 +18,6 @@
|
|||
|
||||
#include <ddk/ntddk.h>
|
||||
#include <internal/mm.h>
|
||||
#include <internal/bitops.h>
|
||||
#include <internal/ntoskrnl.h>
|
||||
#include <internal/pool.h>
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* 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
|
||||
* FILE: ntoskrnl/mm/pagefile.c
|
||||
|
@ -29,7 +29,6 @@
|
|||
/* INCLUDES *****************************************************************/
|
||||
|
||||
#include <ddk/ntddk.h>
|
||||
#include <internal/bitops.h>
|
||||
#include <internal/io.h>
|
||||
#include <internal/mm.h>
|
||||
#include <napi/core.h>
|
||||
|
@ -204,20 +203,28 @@ static ULONG
|
|||
MiAllocPageFromPagingFile(PPAGINGFILE PagingFile)
|
||||
{
|
||||
KIRQL oldIrql;
|
||||
ULONG i;
|
||||
ULONG off;
|
||||
ULONG i, j;
|
||||
|
||||
KeAcquireSpinLock(&PagingFile->AllocMapLock, &oldIrql);
|
||||
|
||||
for (i = 0; i < PagingFile->AllocMapSize; i++)
|
||||
{
|
||||
off = find_first_zero_bit(PagingFile->AllocMap,
|
||||
PagingFile->AllocMapSize * 32);
|
||||
clear_bit(off % 32, &PagingFile->AllocMap[off / 32]);
|
||||
PagingFile->UsedPages--;
|
||||
PagingFile->FreePages++;
|
||||
KeReleaseSpinLock(&PagingFile->AllocMapLock, oldIrql);
|
||||
return(off);
|
||||
for (j = 0; j < 32; j++)
|
||||
{
|
||||
if (!(PagingFile->AllocMap[i] & (1 << j)))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
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);
|
||||
|
@ -237,7 +244,7 @@ MmFreeSwapPage(SWAPENTRY Entry)
|
|||
KeAcquireSpinLock(&PagingFileListLock, &oldIrql);
|
||||
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]->UsedPages--;
|
||||
|
|
Loading…
Reference in a new issue