VirtualBox

Ignore:
Timestamp:
Nov 19, 2015 5:20:00 PM (9 years ago)
Author:
vboxsync
Message:

bs3kit: Core allocator code.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-SlabInit.c

    r58720 r58777  
    11/* $Id$ */
    22/** @file
    3  * BS3Kit - Bs3SlabListAdd
     3 * BS3Kit - Bs3SlabInit
    44 */
    55
     
    3131BS3_DECL(void) Bs3SlabInit(PBS3SLABCLT pSlabCtl, size_t cbSlabCtl, uint32_t uFlatSlabPtr, uint32_t cbSlab, uint16_t cbChunk)
    3232{
     33    uint16_t cBits;
    3334    BS3_ASSERT(RT_IS_POWER_OF_TWO(cbChunk));
    3435    BS3_ASSERT(cbSlab >= cbChunk * 4);
     
    3940    BS3_XPTR_SET_FLAT(BS3SLABCLT, pSlabCtl->pbStart, uFlatSlabPtr);
    4041    pSlabCtl->cbChunk           = cbChunk;
    41     pSlabCtl->cChunks           = cbSlab / cbChunk;
     42    pSlabCtl->cChunkShift       = ASMBitFirstSetU16(cbChunk) - 1;
     43    pSlabCtl->cChunks           = cbSlab >> pSlabCtl->cChunkShift;
    4244    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);
    4648
    4749    /* Mark excess bitmap padding bits as allocated. */
    48     if (pSlabCtl->cBits != pSlabCtl->cChunks)
     50    if (cBits != pSlabCtl->cChunks)
    4951    {
    5052        uint16_t iBit;
    51         for (iBit = pSlabCtl->cChunks; iBit < pSlabCtl->cBits; iBit++)
     53        for (iBit = pSlabCtl->cChunks; iBit < cBits; iBit++)
    5254            ASMBitSet(pSlabCtl->bmAllocated, iBit);
    5355    }
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette