Changeset 58777 in vbox for trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SlabInit.c
- Timestamp:
- Nov 19, 2015 5:20:00 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SlabInit.c
r58720 r58777 1 1 /* $Id$ */ 2 2 /** @file 3 * BS3Kit - Bs3Slab ListAdd3 * BS3Kit - Bs3SlabInit 4 4 */ 5 5 … … 31 31 BS3_DECL(void) Bs3SlabInit(PBS3SLABCLT pSlabCtl, size_t cbSlabCtl, uint32_t uFlatSlabPtr, uint32_t cbSlab, uint16_t cbChunk) 32 32 { 33 uint16_t cBits; 33 34 BS3_ASSERT(RT_IS_POWER_OF_TWO(cbChunk)); 34 35 BS3_ASSERT(cbSlab >= cbChunk * 4); … … 39 40 BS3_XPTR_SET_FLAT(BS3SLABCLT, pSlabCtl->pbStart, uFlatSlabPtr); 40 41 pSlabCtl->cbChunk = cbChunk; 41 pSlabCtl->cChunks = cbSlab / cbChunk; 42 pSlabCtl->cChunkShift = ASMBitFirstSetU16(cbChunk) - 1; 43 pSlabCtl->cChunks = cbSlab >> pSlabCtl->cChunkShift; 42 44 pSlabCtl->cFreeChunks = pSlabCtl->cChunks; 43 pSlabCtl->cBits= RT_ALIGN_T(pSlabCtl->cChunks, 32, uint16_t);44 BS3_ASSERT(cbSlabCtl >= RT_OFFSETOF(BS3SLABCTL, bmAllocated[ pSlabCtl->cBits >> 3]));45 Bs3MemZero(&pSlabCtl->bmAllocated, pSlabCtl->cBits >> 3);45 cBits = RT_ALIGN_T(pSlabCtl->cChunks, 32, uint16_t); 46 BS3_ASSERT(cbSlabCtl >= RT_OFFSETOF(BS3SLABCTL, bmAllocated[cBits >> 3])); 47 Bs3MemZero(&pSlabCtl->bmAllocated, cBits >> 3); 46 48 47 49 /* Mark excess bitmap padding bits as allocated. */ 48 if ( pSlabCtl->cBits != pSlabCtl->cChunks)50 if (cBits != pSlabCtl->cChunks) 49 51 { 50 52 uint16_t iBit; 51 for (iBit = pSlabCtl->cChunks; iBit < pSlabCtl->cBits; iBit++)53 for (iBit = pSlabCtl->cChunks; iBit < cBits; iBit++) 52 54 ASMBitSet(pSlabCtl->bmAllocated, iBit); 53 55 }
Note:
See TracChangeset
for help on using the changeset viewer.