Changeset 61e6c39 in mainline


Ignore:
Timestamp:
2005-12-05T17:56:23Z (19 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
eef75f6
Parents:
4457455
Message:

Buddy allocator cleanup and fixes II.

  • Rewrite IS_BUDDY_LEFT_BLOCK so that it does not need floating point on some architectures (e.g. IA-64).
  • Get rid of IS_BUDDY_RIGHT_BLOCK.
  • Make sparc64 use zone_create_in_region.
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • arch/sparc64/src/mm/frame.c

    r4457455 r61e6c39  
    3030#include <mm/frame.h>
    3131#include <config.h>
    32 #include <panic.h>
    3332
    3433void frame_arch_init(void)
    3534{
    36         zone_t *z;
    37        
    38         z = zone_create(0, config.memory_size, 0);
    39         if (!z) {
    40                 panic("Can't allocate zone (%dB).\n", config.memory_size);
    41         }
    42         zone_attach(z);
     35        zone_create_in_region(0, config.memory_size & ~(FRAME_SIZE - 1));
    4336}
  • generic/include/mm/frame.h

    r4457455 r61e6c39  
    4242#define FRAME2ADDR(zone, frame)                 ((zone)->base + ((frame) - (zone)->frames) * FRAME_SIZE)
    4343#define ADDR2FRAME(zone, addr)                  (&((zone)->frames[((addr) - (zone)->base) / FRAME_SIZE]))
    44 #define FRAME_INDEX(zone, frame)                ((count_t)((frame) - (zone)->frames))
     44#define FRAME_INDEX(zone, frame)                ((index_t)((frame) - (zone)->frames))
    4545#define FRAME_INDEX_VALID(zone, index)          (((index) >= 0) && ((index) < ((zone)->free_count + (zone)->busy_count)))
    46 #define IS_BUDDY_LEFT_BLOCK(zone, frame)        ((FRAME_INDEX((zone), (frame)) % (1 << ((frame)->buddy_order + 1))) == 0)
    47 #define IS_BUDDY_RIGHT_BLOCK(zone, frame)       ((FRAME_INDEX((zone), (frame)) % (1 << ((frame)->buddy_order + 1))) == (1 << (frame)->buddy_order))
     46#define IS_BUDDY_LEFT_BLOCK(zone, frame)        ((FRAME_INDEX((zone), (frame)) & ~(((__native) -1)<<((frame)->buddy_order + 1))) == 0)
    4847
    4948#define ZONE_BLACKLIST_SIZE     3
  • generic/src/mm/frame.c

    r4457455 r61e6c39  
    389389
    390390        is_left = IS_BUDDY_LEFT_BLOCK(zone, frame);
    391         is_right = IS_BUDDY_RIGHT_BLOCK(zone, frame);
    392        
    393         ASSERT((is_left || is_right) && (!is_left || !is_right));
     391        is_right = !is_left;
    394392       
    395393        /*
Note: See TracChangeset for help on using the changeset viewer.