Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/ia64/src/mm/frame.c

    rbbe4828 r40c8c17  
    5151#define MINCONF 1
    5252
    53 uintptr_t last_frame = 0;
     53static void frame_common_arch_init(bool low)
     54{
     55        unsigned int i;
    5456
    55 void frame_arch_init(void)
    56 {
    57         if (config.cpu_active == 1) {
    58                 unsigned int i;
    59                 for (i = 0; i < bootinfo->memmap_items; i++) {
    60                         if (bootinfo->memmap[i].type == MEMMAP_FREE_MEM) {
    61                                 uint64_t base = bootinfo->memmap[i].base;
    62                                 uint64_t size = bootinfo->memmap[i].size;
    63                                 uint64_t abase = ALIGN_UP(base, FRAME_SIZE);
     57        for (i = 0; i < bootinfo->memmap_items; i++) {
     58                if (bootinfo->memmap[i].type != MEMMAP_FREE_MEM)
     59                        continue;
    6460
    65                                 if (size > FRAME_SIZE)
    66                                         size -= abase - base;
     61                uintptr_t base = bootinfo->memmap[i].base;
     62                size_t size = bootinfo->memmap[i].size;
     63                uintptr_t abase = ALIGN_UP(base, FRAME_SIZE);
    6764
    68                                 if (size > MIN_ZONE_SIZE) {
    69                                         zone_create(abase >> FRAME_WIDTH,
    70                                             size >> FRAME_WIDTH,
    71                                             max(MINCONF, abase >> FRAME_WIDTH),
    72                                             0);
    73                                 }
    74                                 if (abase + size > last_frame)
    75                                         last_frame = abase + size;
     65                if (size > FRAME_SIZE)
     66                        size -= abase - base;
     67
     68                if (!frame_adjust_zone_bounds(low, &abase, &size))
     69                        continue;
     70
     71                if (size > MIN_ZONE_SIZE) {
     72                        pfn_t pfn = ADDR2PFN(abase);
     73                        size_t count = SIZE2FRAMES(size);
     74
     75                        if (low) {
     76                                zone_create(pfn, count, max(MINCONF, pfn),
     77                                    ZONE_AVAILABLE | ZONE_LOWMEM);
     78                        } else {
     79                                pfn_t conf;
     80
     81                                conf = zone_external_conf_alloc(count);
     82                                zone_create(pfn, count, conf,
     83                                    ZONE_AVAILABLE | ZONE_HIGHMEM);
    7684                        }
    7785                }
    78                
    79                 /*
    80                  * Blacklist ROM regions.
    81                  */
    82                 frame_mark_unavailable(ADDR2PFN(ROM_BASE),
    83                     SIZE2FRAMES(ROM_SIZE));
     86        }
     87}
    8488
    85                 frame_mark_unavailable(ADDR2PFN(KERNEL_RESERVED_AREA_BASE),
    86                     SIZE2FRAMES(KERNEL_RESERVED_AREA_SIZE));
    87         }       
     89void frame_low_arch_init(void)
     90{
     91        if (config.cpu_active > 1)
     92                return;
     93       
     94        frame_common_arch_init(true);
     95       
     96        /*
     97         * Blacklist ROM regions.
     98         */
     99        frame_mark_unavailable(ADDR2PFN(ROM_BASE),
     100            SIZE2FRAMES(ROM_SIZE));
     101
     102        frame_mark_unavailable(ADDR2PFN(KERNEL_RESERVED_AREA_BASE),
     103            SIZE2FRAMES(KERNEL_RESERVED_AREA_SIZE));
     104}
     105
     106void frame_high_arch_init(void)
     107{
     108        if (config.cpu_active > 1)
     109                return;
     110       
     111        frame_common_arch_init(false);
    88112}
    89113
Note: See TracChangeset for help on using the changeset viewer.