23 lines
746 B
C
23 lines
746 B
C
#include <VM/PMM.h>
|
|
|
|
static inline Size BitmapGetByteIndex(Address address) {
|
|
return (address / kVMPageSize) / kVMBlocksPerByte;
|
|
}
|
|
|
|
static inline UInt8 BitmapGetBitOffset(Address address) {
|
|
return (UInt8)((address / kVMPageSize) % kVMBlocksPerByte);
|
|
}
|
|
|
|
static inline Boolean BitmapTest(const MemoryPointer bitmap, Address address) {
|
|
return (bitmap[BitmapGetByteIndex(address)] & (1U << BitmapGetBitOffset(address))) != 0;
|
|
}
|
|
|
|
static inline void BitmapSet(MemoryPointer bitmap, Address address) {
|
|
bitmap[BitmapGetByteIndex(address)] |= (1U << BitmapGetBitOffset(address));
|
|
}
|
|
|
|
static inline void BitmapUnset(MemoryPointer bitmap, Address address) {
|
|
bitmap[BitmapGetByteIndex(address)] &= ~(1U << BitmapGetBitOffset(address));
|
|
}
|
|
|