Changeset e49e234 in mainline for kernel/arch/ia32/src/mm/frame.c


Ignore:
Timestamp:
2009-02-27T11:32:31Z (16 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
c1f7f6ea
Parents:
5f0f29ce
Message:

kernel memory management revisited (phase 2): map physical memory according to zones

  • ia32: register reserved and ACPI zones
  • pareas are now used only for mapping of present physical memory (hw_area() is gone)
  • firmware zones and physical addresses outside any zones are allowed to be mapped generally
  • fix nasty antient bug in zones_insert_zone()
File:
1 edited

Legend:

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

    r5f0f29ce re49e234  
    5151
    5252uintptr_t last_frame = 0;
    53 uintptr_t end_frame = 0;
    5453
    5554static void init_e820_memory(pfn_t minconf)
    5655{
    5756        unsigned int i;
    58         pfn_t start, conf;
    59         size_t size;
    60        
    6157        for (i = 0; i < e820counter; i++) {
     58                uint64_t base = e820table[i].base_address;
     59                uint64_t size = e820table[i].size;
     60               
     61#ifdef __32_BITS__
     62               
     63                /* Ignore physical memory above 4 GB */
     64                if ((base >> 32) != 0)
     65                        continue;
     66               
     67                /* Clip regions above 4 GB */
     68                if (((base + size) >> 32) != 0)
     69                        size = 0xffffffff - base;
     70               
     71#endif
     72                pfn_t pfn;
     73                count_t count;
     74               
    6275                if (e820table[i].type == MEMMAP_MEMORY_AVAILABLE) {
    63                         start = ADDR2PFN(ALIGN_UP(e820table[i].base_address, FRAME_SIZE));
    64                         size = SIZE2FRAMES(ALIGN_DOWN(e820table[i].size, FRAME_SIZE));
     76                        /* To be safe, make available zone possibly smaller */
     77                        pfn = ADDR2PFN(ALIGN_UP(base, FRAME_SIZE));
     78                        count = SIZE2FRAMES(ALIGN_DOWN(size, FRAME_SIZE));
    6579                       
    66                         if ((minconf < start) || (minconf >= start + size))
    67                                 conf = start;
     80                        pfn_t conf;
     81                        if ((minconf < pfn) || (minconf >= pfn + count))
     82                                conf = pfn;
    6883                        else
    6984                                conf = minconf;
    7085                       
    71                         zone_create(start, size, conf, 0);
     86                        zone_create(pfn, count, conf, ZONE_AVAILABLE);
    7287                       
    73                         if (last_frame < ALIGN_UP(e820table[i].base_address +
    74                             e820table[i].size, FRAME_SIZE))
    75                                 last_frame =
    76                                     ALIGN_UP(e820table[i].base_address + e820table[i].size, FRAME_SIZE);
     88                        // XXX this has to be removed
     89                        if (last_frame < ALIGN_UP(base + size, FRAME_SIZE))
     90                                last_frame = ALIGN_UP(base + size, FRAME_SIZE);
     91                }
     92               
     93                if (e820table[i].type == MEMMAP_MEMORY_RESERVED) {
     94                        /* To be safe, make reserved zone possibly larger */
     95                        pfn = ADDR2PFN(ALIGN_DOWN(base, FRAME_SIZE));
     96                        count = SIZE2FRAMES(ALIGN_UP(size, FRAME_SIZE));
     97                       
     98                        zone_create(pfn, count, 0, ZONE_RESERVED);
     99                }
     100               
     101                if (e820table[i].type == MEMMAP_MEMORY_ACPI) {
     102                        /* To be safe, make firmware zone possibly larger */
     103                        pfn = ADDR2PFN(ALIGN_DOWN(base, (uintptr_t) FRAME_SIZE));
     104                        count = SIZE2FRAMES(ALIGN_UP(size, (uintptr_t) FRAME_SIZE));
     105                       
     106                        zone_create(pfn, count, 0, ZONE_FIRMWARE);
    77107                }
    78108        }
    79        
    80         end_frame = last_frame;
    81109}
    82110
Note: See TracChangeset for help on using the changeset viewer.