Changeset f72906c in mainline for kernel/generic/src/adt/bitmap.c


Ignore:
Timestamp:
2013-09-12T18:09:51Z (11 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
69f5f19
Parents:
b11f6fb
Message:

prefer allocating physical frames from the so called low priority memory (< 16 MB on ia32 and amd64)
this saves the high priority memory for legacy DMA transfers, etc.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/adt/bitmap.c

    rb11f6fb rf72906c  
    258258 * @param count      Number of continuous zero bits to find.
    259259 * @param base       Address of the first bit in the bitmap.
     260 * @param prefered   Prefered address to start searching from.
    260261 * @param constraint Constraint for the address of the first zero bit.
    261262 * @param index      Place to store the index of the first zero
     
    269270 */
    270271int bitmap_allocate_range(bitmap_t *bitmap, size_t count, size_t base,
    271     size_t constraint, size_t *index)
     272    size_t prefered, size_t constraint, size_t *index)
    272273{
    273274        if (count == 0)
     
    275276       
    276277        size_t size = bitmap_size(bitmap->elements);
     278        size_t next_fit = bitmap->next_fit;
     279       
     280        /*
     281         * Adjust the next-fit value according to the address
     282         * the caller prefers to start the search at.
     283         */
     284        if ((prefered > base) && (prefered < base + bitmap->elements)) {
     285                size_t prefered_fit = (prefered - base) / BITMAP_ELEMENT;
     286               
     287                if (prefered_fit > next_fit)
     288                        next_fit = prefered_fit;
     289        }
    277290       
    278291        for (size_t pos = 0; pos < size; pos++) {
    279                 size_t byte = (bitmap->next_fit + pos) % size;
     292                size_t byte = (next_fit + pos) % size;
    280293               
    281294                /* Skip if the current byte has all bits set */
Note: See TracChangeset for help on using the changeset viewer.