Changeset 4457455 in mainline


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

Buddy system cleanup and fixes.

  • missing use of KA2PA in frame_init
  • truncating black list addresses to frame boundaries
  • removal of left-over obsolete structures
  • fixing some comments
Files:
4 edited

Legend:

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

    r9ebc238 r4457455  
    4242{
    4343        zone_t *z;
    44         __address start, stop;
    45         size_t size;
    4644        __u8 i;
    4745       
     
    5452                frame_region_not_free(BOOTSTRAP_OFFSET, hardcoded_unmapped_ktext_size + hardcoded_unmapped_kdata_size);
    5553               
    56                 for (i=0;i<e820counter;i++) {
    57                         if (e820table[i].type==MEMMAP_MEMORY_AVAILABLE) {
     54                for (i = 0; i < e820counter; i++) {
     55                        if (e820table[i].type == MEMMAP_MEMORY_AVAILABLE) {
    5856                                zone_create_in_region(e820table[i].base_address,  e820table[i].size & ~(FRAME_SIZE-1));
    5957                        }
  • arch/ia64/include/mm/page.h

    r9ebc238 r4457455  
    3535#define PAGE_SIZE       FRAME_SIZE
    3636
    37 #define KA2PA(x)        (((__address) (x))-0x8000000000000000)
    38 #define PA2KA(x)        (((__address) (x))+0x8000000000000000)
     37#define KA2PA(x)        ((__address) (x))
     38#define PA2KA(x)        ((__address) (x))
    3939
    4040#define page_arch_init()        ;
  • generic/include/mm/frame.h

    r9ebc238 r4457455  
    5555        __address base;         /**< physical address of the first frame in the frames array */
    5656        frame_t *frames;        /**< array of frame_t structures in this zone */
    57         link_t free_head;       /**< list of free frame_t structures */
    5857        count_t free_count;     /**< number of frame_t structures in free list */
    5958        count_t busy_count;     /**< number of frame_t structures not in free list */
     
    6463
    6564struct frame {
    66         count_t refcount;       /**< when == 0, the frame is in free list */
    67         link_t link;            /**< link to zone free list when refcount == 0 */
     65        count_t refcount;       /**< tracking of shared frames  */
    6866        __u8 buddy_order;       /**< buddy system block order */
    69         link_t buddy_link;      /**< link to the next free block inside one order*/
     67        link_t buddy_link;      /**< link to the next free block inside one order */
    7068};
    7169
  • generic/src/mm/frame.c

    r9ebc238 r4457455  
    6464        if (config.cpu_active == 1) {
    6565                zone_init();
    66                 frame_region_not_free(config.base, config.kernel_size);
     66                frame_region_not_free(KA2PA(config.base), config.kernel_size);
    6767        }
    6868
     
    7070}
    7171
    72 /** Allocate a frame
    73  *
    74  * Allocate a frame of physical memory.
     72/** Allocate power-of-two frames of physical memory.
    7573 *
    7674 * @param flags Flags for host zone selection and address processing.
     75 * @param order Allocate exactly 2^order frames.
    7776 *
    7877 * @return Allocated frame.
     
    203202 * Mark frame region not free.
    204203 *
    205  * @param start First address.
    206  * @param stop Last address.
     204 * @param base Base address of non-available region.
     205 * @param size Size of non-available region.
    207206 */
    208207void frame_region_not_free(__address base, size_t size)
    209208{
    210         count_t index;
     209        index_t index;
    211210        index = zone_blacklist_count++;
    212         ASSERT(base % FRAME_SIZE == 0);
    213        
    214         if (size % FRAME_SIZE != 0) {
    215                 size = ALIGN(size, FRAME_SIZE);
    216         }
    217         ASSERT(size % FRAME_SIZE == 0);
     211
     212        /* Force base to the nearest lower address frame boundary. */
     213        base &= ~(FRAME_SIZE - 1);
     214        /* Align size to frame boundary. */
     215        size = ALIGN(size, FRAME_SIZE);
     216
    218217        ASSERT(zone_blacklist_count <= ZONE_BLACKLIST_SIZE);
    219218        zone_blacklist[index].base = base;
     
    236235        int i;
    237236        zone_t * z;
    238         __address s; size_t sz;
     237        __address s;
     238        size_t sz;
    239239       
    240240        ASSERT(base % FRAME_SIZE == 0);
    241241        ASSERT(size % FRAME_SIZE == 0);
    242242       
    243         if (!size) return;
    244        
     243        if (!size)
     244                return;
     245
    245246        for (i = 0; i < zone_blacklist_count; i++) {
    246247                if (zone_blacklist[i].base >= base && zone_blacklist[i].base < base + size) {
     
    304305
    305306                z->free_count = cnt;
    306                 list_initialize(&z->free_head);
    307 
    308307                z->busy_count = 0;
    309308               
     
    316315                for (i = 0; i<cnt; i++) {
    317316                        frame_initialize(&z->frames[i], z);
    318                         list_append(&z->frames[i].link, &z->free_head);
    319317                }
    320318               
     
    322320                 * Create buddy system for the zone
    323321                 */
    324                 for (max_order = 0; cnt >> max_order; max_order++);
     322                for (max_order = 0; cnt >> max_order; max_order++)
     323                        ;
    325324                z->buddy_system = buddy_system_create(max_order, &zone_buddy_system_operations, (void *) z);
    326325               
     
    364363        frame->refcount = 1;
    365364        frame->buddy_order = 0;
    366         link_initialize(&frame->link);
    367365}
    368366
Note: See TracChangeset for help on using the changeset viewer.