Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/mm/frame.c

    r74c5a1ca r7e752b2  
    7575/********************/
    7676
    77 static inline size_t frame_index(zone_t *zone, frame_t *frame)
     77NO_TRACE static inline size_t frame_index(zone_t *zone, frame_t *frame)
    7878{
    7979        return (size_t) (frame - zone->frames);
    8080}
    8181
    82 static inline size_t frame_index_abs(zone_t *zone, frame_t *frame)
     82NO_TRACE static inline size_t frame_index_abs(zone_t *zone, frame_t *frame)
    8383{
    8484        return (size_t) (frame - zone->frames) + zone->base;
    8585}
    8686
    87 static inline bool frame_index_valid(zone_t *zone, size_t index)
     87NO_TRACE static inline bool frame_index_valid(zone_t *zone, size_t index)
    8888{
    8989        return (index < zone->count);
    9090}
    9191
    92 static inline size_t make_frame_index(zone_t *zone, frame_t *frame)
     92NO_TRACE static inline size_t make_frame_index(zone_t *zone, frame_t *frame)
    9393{
    9494        return (frame - zone->frames);
     
    100100 *
    101101 */
    102 static void frame_initialize(frame_t *frame)
     102NO_TRACE static void frame_initialize(frame_t *frame)
    103103{
    104104        frame->refcount = 1;
     
    121121 *
    122122 */
    123 static size_t zones_insert_zone(pfn_t base, size_t count)
     123NO_TRACE static size_t zones_insert_zone(pfn_t base, size_t count,
     124    zone_flags_t flags)
    124125{
    125126        if (zones.count + 1 == ZONES_MAX) {
     
    131132        for (i = 0; i < zones.count; i++) {
    132133                /* Check for overlap */
    133                 if (overlaps(base, count,
    134                     zones.info[i].base, zones.info[i].count)) {
    135                         printf("Zones overlap!\n");
     134                if (overlaps(zones.info[i].base, zones.info[i].count,
     135                    base, count)) {
     136                       
     137                        /*
     138                         * If the overlaping zones are of the same type
     139                         * and the new zone is completely within the previous
     140                         * one, then quietly ignore the new zone.
     141                         *
     142                         */
     143                       
     144                        if ((zones.info[i].flags != flags) ||
     145                            (!iswithin(zones.info[i].base, zones.info[i].count,
     146                            base, count))) {
     147                                printf("Zone (%p, %p) overlaps "
     148                                    "with previous zone (%p %p)!\n",
     149                                    (void *) PFN2ADDR(base), (void *) PFN2ADDR(count),
     150                                    (void *) PFN2ADDR(zones.info[i].base),
     151                                    (void *) PFN2ADDR(zones.info[i].count));
     152                        }
     153                       
    136154                        return (size_t) -1;
    137155                }
     
    144162        for (j = zones.count; j > i; j--) {
    145163                zones.info[j] = zones.info[j - 1];
    146                 zones.info[j].buddy_system->data =
    147                     (void *) &zones.info[j - 1];
     164                if (zones.info[j].buddy_system != NULL)
     165                        zones.info[j].buddy_system->data =
     166                            (void *) &zones.info[j];
    148167        }
    149168       
     
    162181 */
    163182#ifdef CONFIG_DEBUG
    164 static size_t total_frames_free(void)
     183NO_TRACE static size_t total_frames_free(void)
    165184{
    166185        size_t total = 0;
     
    185204 *
    186205 */
    187 size_t find_zone(pfn_t frame, size_t count, size_t hint)
     206NO_TRACE size_t find_zone(pfn_t frame, size_t count, size_t hint)
    188207{
    189208        if (hint >= zones.count)
     
    206225
    207226/** @return True if zone can allocate specified order */
    208 static bool zone_can_alloc(zone_t *zone, uint8_t order)
     227NO_TRACE static bool zone_can_alloc(zone_t *zone, uint8_t order)
    209228{
    210229        return (zone_flags_available(zone->flags)
     
    222241 *
    223242 */
    224 static size_t find_free_zone(uint8_t order, zone_flags_t flags, size_t hint)
     243NO_TRACE static size_t find_free_zone(uint8_t order, zone_flags_t flags,
     244    size_t hint)
    225245{
    226246        if (hint >= zones.count)
     
    262282 *
    263283 */
    264 static link_t *zone_buddy_find_block(buddy_system_t *buddy, link_t *child,
    265     uint8_t order)
     284NO_TRACE static link_t *zone_buddy_find_block(buddy_system_t *buddy,
     285    link_t *child, uint8_t order)
    266286{
    267287        frame_t *frame = list_get_instance(child, frame_t, buddy_link);
     
    285305 *
    286306 */
    287 static link_t *zone_buddy_find_buddy(buddy_system_t *buddy, link_t *block)
     307NO_TRACE static link_t *zone_buddy_find_buddy(buddy_system_t *buddy,
     308    link_t *block)
    288309{
    289310        frame_t *frame = list_get_instance(block, frame_t, buddy_link);
     
    321342 *
    322343 */
    323 static link_t *zone_buddy_bisect(buddy_system_t *buddy, link_t *block)
     344NO_TRACE static link_t *zone_buddy_bisect(buddy_system_t *buddy, link_t *block)
    324345{
    325346        frame_t *frame_l = list_get_instance(block, frame_t, buddy_link);
     
    339360 *
    340361 */
    341 static link_t *zone_buddy_coalesce(buddy_system_t *buddy, link_t *block_1,
    342     link_t *block_2)
     362NO_TRACE static link_t *zone_buddy_coalesce(buddy_system_t *buddy,
     363    link_t *block_1, link_t *block_2)
    343364{
    344365        frame_t *frame1 = list_get_instance(block_1, frame_t, buddy_link);
     
    355376 *
    356377 */
    357 static void zone_buddy_set_order(buddy_system_t *buddy, link_t *block,
     378NO_TRACE static void zone_buddy_set_order(buddy_system_t *buddy, link_t *block,
    358379    uint8_t order)
    359380{
     
    369390 *
    370391 */
    371 static uint8_t zone_buddy_get_order(buddy_system_t *buddy, link_t *block)
     392NO_TRACE static uint8_t zone_buddy_get_order(buddy_system_t *buddy,
     393    link_t *block)
    372394{
    373395        return list_get_instance(block, frame_t, buddy_link)->buddy_order;
     
    380402 *
    381403 */
    382 static void zone_buddy_mark_busy(buddy_system_t *buddy, link_t * block)
     404NO_TRACE static void zone_buddy_mark_busy(buddy_system_t *buddy, link_t *block)
    383405{
    384406        list_get_instance(block, frame_t, buddy_link)->refcount = 1;
     
    389411 * @param buddy Buddy system.
    390412 * @param block Buddy system block.
    391  */
    392 static void zone_buddy_mark_available(buddy_system_t *buddy, link_t *block)
     413 *
     414 */
     415NO_TRACE static void zone_buddy_mark_available(buddy_system_t *buddy,
     416    link_t *block)
    393417{
    394418        list_get_instance(block, frame_t, buddy_link)->refcount = 0;
     
    421445 *
    422446 */
    423 static pfn_t zone_frame_alloc(zone_t *zone, uint8_t order)
     447NO_TRACE static pfn_t zone_frame_alloc(zone_t *zone, uint8_t order)
    424448{
    425449        ASSERT(zone_flags_available(zone->flags));
     
    449473 *
    450474 */
    451 static void zone_frame_free(zone_t *zone, size_t frame_idx)
     475NO_TRACE static void zone_frame_free(zone_t *zone, size_t frame_idx)
    452476{
    453477        ASSERT(zone_flags_available(zone->flags));
     
    470494
    471495/** Return frame from zone. */
    472 static frame_t *zone_get_frame(zone_t *zone, size_t frame_idx)
     496NO_TRACE static frame_t *zone_get_frame(zone_t *zone, size_t frame_idx)
    473497{
    474498        ASSERT(frame_idx < zone->count);
     
    477501
    478502/** Mark frame in zone unavailable to allocation. */
    479 static void zone_mark_unavailable(zone_t *zone, size_t frame_idx)
     503NO_TRACE static void zone_mark_unavailable(zone_t *zone, size_t frame_idx)
    480504{
    481505        ASSERT(zone_flags_available(zone->flags));
     
    506530 *
    507531 */
    508 static void zone_merge_internal(size_t z1, size_t z2, zone_t *old_z1, buddy_system_t *buddy)
     532NO_TRACE static void zone_merge_internal(size_t z1, size_t z2, zone_t *old_z1,
     533    buddy_system_t *buddy)
    509534{
    510535        ASSERT(zone_flags_available(zones.info[z1].flags));
     
    602627 *
    603628 */
    604 static void return_config_frames(size_t znum, pfn_t pfn, size_t count)
     629NO_TRACE static void return_config_frames(size_t znum, pfn_t pfn, size_t count)
    605630{
    606631        ASSERT(zone_flags_available(zones.info[znum].flags));
     
    637662 *
    638663 */
    639 static void zone_reduce_region(size_t znum, pfn_t frame_idx, size_t count)
     664NO_TRACE static void zone_reduce_region(size_t znum, pfn_t frame_idx,
     665    size_t count)
    640666{
    641667        ASSERT(zone_flags_available(zones.info[znum].flags));
     
    738764        for (i = z2 + 1; i < zones.count; i++) {
    739765                zones.info[i - 1] = zones.info[i];
    740                 zones.info[i - 1].buddy_system->data =
    741                     (void *) &zones.info[i - 1];
     766                if (zones.info[i - 1].buddy_system != NULL)
     767                        zones.info[i - 1].buddy_system->data =
     768                            (void *) &zones.info[i - 1];
    742769        }
    743770       
     
    777804 *
    778805 */
    779 static void zone_construct(zone_t *zone, buddy_system_t *buddy, pfn_t start,
    780     size_t count, zone_flags_t flags)
     806NO_TRACE static void zone_construct(zone_t *zone, buddy_system_t *buddy,
     807    pfn_t start, size_t count, zone_flags_t flags)
    781808{
    782809        zone->base = start;
     
    821848 *
    822849 */
    823 uintptr_t zone_conf_size(size_t count)
     850size_t zone_conf_size(size_t count)
    824851{
    825852        return (count * sizeof(frame_t) + buddy_conf_size(fnzb(count)));
     
    852879                 * the assert
    853880                 */
    854                 ASSERT(confframe != NULL);
     881                ASSERT(confframe != ADDR2PFN((uintptr_t ) NULL));
    855882               
    856883                /* If confframe is supposed to be inside our zone, then make sure
     
    888915                }
    889916               
    890                 size_t znum = zones_insert_zone(start, count);
     917                size_t znum = zones_insert_zone(start, count, flags);
    891918                if (znum == (size_t) -1) {
    892919                        irq_spinlock_unlock(&zones.lock, true);
     
    911938       
    912939        /* Non-available zone */
    913         size_t znum = zones_insert_zone(start, count);
     940        size_t znum = zones_insert_zone(start, count, flags);
    914941        if (znum == (size_t) -1) {
    915942                irq_spinlock_unlock(&zones.lock, true);
     
    10231050               
    10241051#ifdef CONFIG_DEBUG
    1025                 printf("Thread %" PRIu64 " waiting for %" PRIs " frames, "
    1026                     "%" PRIs " available.\n", THREAD->tid, size, avail);
     1052                printf("Thread %" PRIu64 " waiting for %zu frames, "
     1053                    "%zu available.\n", THREAD->tid, size, avail);
    10271054#endif
    10281055               
     
    10781105         */
    10791106        pfn_t pfn = ADDR2PFN(frame);
    1080         size_t znum = find_zone(pfn, 1, NULL);
     1107        size_t znum = find_zone(pfn, 1, 0);
    10811108       
    10821109        ASSERT(znum != (size_t) -1);
     
    11081135 *
    11091136 */
    1110 void frame_reference_add(pfn_t pfn)
     1137NO_TRACE void frame_reference_add(pfn_t pfn)
    11111138{
    11121139        irq_spinlock_lock(&zones.lock, true);
     
    11151142         * First, find host frame zone for addr.
    11161143         */
    1117         size_t znum = find_zone(pfn, 1, NULL);
     1144        size_t znum = find_zone(pfn, 1, 0);
    11181145       
    11191146        ASSERT(znum != (size_t) -1);
     
    11271154 *
    11281155 */
    1129 void frame_mark_unavailable(pfn_t start, size_t count)
     1156NO_TRACE void frame_mark_unavailable(pfn_t start, size_t count)
    11301157{
    11311158        irq_spinlock_lock(&zones.lock, true);
     
    12711298                bool available = zone_flags_available(flags);
    12721299               
    1273                 printf("%-4" PRIs, i);
     1300                printf("%-4zu", i);
    12741301               
    12751302#ifdef __32_BITS__
    1276                 printf("  %10p", base);
     1303                printf("  %p", (void *) base);
    12771304#endif
    12781305               
    12791306#ifdef __64_BITS__
    1280                 printf(" %18p", base);
     1307                printf(" %p", (void *) base);
    12811308#endif
    12821309               
    1283                 printf(" %12" PRIs " %c%c%c      ", count,
     1310                printf(" %12zu %c%c%c      ", count,
    12841311                    available ? 'A' : ' ',
    12851312                    (flags & ZONE_RESERVED) ? 'R' : ' ',
     
    12871314               
    12881315                if (available)
    1289                         printf("%14" PRIs " %14" PRIs,
     1316                        printf("%14zu %14zu",
    12901317                            free_count, busy_count);
    12911318               
     
    13281355        bool available = zone_flags_available(flags);
    13291356       
    1330         printf("Zone number:       %" PRIs "\n", znum);
    1331         printf("Zone base address: %p\n", base);
    1332         printf("Zone size:         %" PRIs " frames (%" PRIs " KiB)\n", count,
     1357        printf("Zone number:       %zu\n", znum);
     1358        printf("Zone base address: %p\n", (void *) base);
     1359        printf("Zone size:         %zu frames (%zu KiB)\n", count,
    13331360            SIZE2KB(FRAMES2SIZE(count)));
    13341361        printf("Zone flags:        %c%c%c\n",
     
    13381365       
    13391366        if (available) {
    1340                 printf("Allocated space:   %" PRIs " frames (%" PRIs " KiB)\n",
     1367                printf("Allocated space:   %zu frames (%zu KiB)\n",
    13411368                    busy_count, SIZE2KB(FRAMES2SIZE(busy_count)));
    1342                 printf("Available space:   %" PRIs " frames (%" PRIs " KiB)\n",
     1369                printf("Available space:   %zu frames (%zu KiB)\n",
    13431370                    free_count, SIZE2KB(FRAMES2SIZE(free_count)));
    13441371        }
Note: See TracChangeset for help on using the changeset viewer.