EFIAPI SetMemN ( OUT VOID *Buffer, IN UINTN Length, IN UINTN Value ) { if (sizeof (UINTN) == sizeof (UINT64)) { return SetMem64 (Buffer, Length, (UINT64)Value); } else { return SetMem32 (Buffer, Length, (UINT32)Value); } }
/** Set corresponding bits in bitmap table to 1 according to the address. @param[in] Address Start address to set for. @param[in] BitNumber Number of bits to set. @param[in] BitMap Pointer to bitmap which covers the Address. @return VOID **/ STATIC VOID SetBits ( IN EFI_PHYSICAL_ADDRESS Address, IN UINTN BitNumber, IN UINT64 *BitMap ) { UINTN Lsbs; UINTN Qwords; UINTN Msbs; UINTN StartBit; UINTN EndBit; StartBit = (UINTN)GUARDED_HEAP_MAP_ENTRY_BIT_INDEX (Address); EndBit = (StartBit + BitNumber - 1) % GUARDED_HEAP_MAP_ENTRY_BITS; if ((StartBit + BitNumber) >= GUARDED_HEAP_MAP_ENTRY_BITS) { Msbs = (GUARDED_HEAP_MAP_ENTRY_BITS - StartBit) % GUARDED_HEAP_MAP_ENTRY_BITS; Lsbs = (EndBit + 1) % GUARDED_HEAP_MAP_ENTRY_BITS; Qwords = (BitNumber - Msbs) / GUARDED_HEAP_MAP_ENTRY_BITS; } else { Msbs = BitNumber; Lsbs = 0; Qwords = 0; } if (Msbs > 0) { *BitMap |= LShiftU64 (LShiftU64 (1, Msbs) - 1, StartBit); BitMap += 1; } if (Qwords > 0) { SetMem64 ((VOID *)BitMap, Qwords * GUARDED_HEAP_MAP_ENTRY_BYTES, (UINT64)-1); BitMap += Qwords; } if (Lsbs > 0) { *BitMap |= (LShiftU64 (1, Lsbs) - 1); } }