Changed functions RtlClearAllBits and RtlSetAllBits to use SizeOfBitMap

as the number of bits, not the number of bytes in the bitmap.  This was
making the whole page allocator in ntoskrnl/mm/npool.c crash early in
the boot process with whole page allocations on.  This may affect other
things adversely as well.

The documentation for RtlInitializeBitMap is here:
http://www.osronline.com/ddkx/kmarch/k109_5sfm.htm

svn path=/trunk/; revision=11039
This commit is contained in:
Art Yerkes 2004-09-25 03:20:16 +00:00
parent 9e91360716
commit 906e734ab4

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: bitmap.c,v 1.1 2004/08/10 12:00:09 ekohl Exp $ /* $Id: bitmap.c,v 1.2 2004/09/25 03:20:16 arty Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -140,13 +140,18 @@ RtlAreBitsSet(PRTL_BITMAP BitMapHeader,
/* /*
* @implemented * @implemented
*
* Note: According to the documentation, SizeOfBitmap is in bits, so the
* ALIGN(...) must be divided by the number of bits per byte here.
* This function is exercised by the whole page allocator in npool.c
* which is how i came across this error.
*/ */
VOID STDCALL VOID STDCALL
RtlClearAllBits(IN OUT PRTL_BITMAP BitMapHeader) RtlClearAllBits(IN OUT PRTL_BITMAP BitMapHeader)
{ {
memset(BitMapHeader->Buffer, memset(BitMapHeader->Buffer,
0x00, 0x00,
ALIGN(BitMapHeader->SizeOfBitMap, 8)); ALIGN(BitMapHeader->SizeOfBitMap, 8) / 8);
} }
@ -736,13 +741,18 @@ RtlNumberOfSetBits(PRTL_BITMAP BitMapHeader)
/* /*
* @implemented * @implemented
*
* Note: According to the documentation, SizeOfBitmap is in bits, so the
* ALIGN(...) must be divided by the number of bits per byte here.
* The companion function, RtlClearAllBits, is exercised by the whole page
* allocator in npool.c which is how i came across this error.
*/ */
VOID STDCALL VOID STDCALL
RtlSetAllBits(IN OUT PRTL_BITMAP BitMapHeader) RtlSetAllBits(IN OUT PRTL_BITMAP BitMapHeader)
{ {
memset(BitMapHeader->Buffer, memset(BitMapHeader->Buffer,
0xFF, 0xFF,
ALIGN(BitMapHeader->SizeOfBitMap, 8)); ALIGN(BitMapHeader->SizeOfBitMap, 8) / 8);
} }