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


Ignore:
Timestamp:
2012-02-09T20:35:12Z (12 years ago)
Author:
Maurizio Lombardi <m.lombardi85@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
591762c6
Parents:
7cede12c (diff), 3d4750f (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge mainline changes

File:
1 edited

Legend:

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

    r7cede12c rb7068da  
    4646#include <print.h>
    4747
    48 #define PHYSMEM_LIMIT32  UINT64_C(0x07c000000)
    49 #define PHYSMEM_LIMIT64  UINT64_C(0x200000000)
     48#define PHYSMEM_LIMIT32  UINT64_C(0x100000000)
    5049
    5150size_t hardcoded_unmapped_ktext_size = 0;
    5251size_t hardcoded_unmapped_kdata_size = 0;
    5352
    54 uintptr_t last_frame = 0;
    55 
    56 static void init_e820_memory(pfn_t minconf)
     53static void init_e820_memory(pfn_t minconf, bool low)
    5754{
    5855        unsigned int i;
    5956       
    6057        for (i = 0; i < e820counter; i++) {
    61                 uint64_t base = e820table[i].base_address;
    62                 uint64_t size = e820table[i].size;
     58                uint64_t base64 = e820table[i].base_address;
     59                uint64_t size64 = e820table[i].size;
    6360               
    64 #ifdef __32_BITS__
     61#ifdef KARCH_ia32
    6562                /*
    66                  * XXX FIXME:
    67                  *
    68                  * Ignore zones which start above PHYSMEM_LIMIT32
    69                  * or clip zones which go beyond PHYSMEM_LIMIT32.
    70                  *
    71                  * The PHYSMEM_LIMIT32 (2 GB - 64 MB) is a rather
    72                  * arbitrary constant which allows to have at
    73                  * least 64 MB in the kernel address space to
    74                  * map hardware resources.
    75                  *
    76                  * The kernel uses fixed 1:1 identity mapping
    77                  * of the physical memory with 2:2 GB split.
    78                  * This is a severe limitation of the current
    79                  * kernel memory management.
    80                  *
     63                 * Restrict the e820 table entries to 32-bits.
    8164                 */
    82                
    83                 if (base > PHYSMEM_LIMIT32)
     65                if (base64 >= PHYSMEM_LIMIT32)
    8466                        continue;
    8567               
    86                 if (base + size > PHYSMEM_LIMIT32)
    87                         size = PHYSMEM_LIMIT32 - base;
     68                if (base64 + size64 > PHYSMEM_LIMIT32)
     69                        size64 = PHYSMEM_LIMIT32 - base64;
    8870#endif
    8971               
    90 #ifdef __64_BITS__
    91                 /*
    92                  * XXX FIXME:
    93                  *
    94                  * Ignore zones which start above PHYSMEM_LIMIT64
    95                  * or clip zones which go beyond PHYSMEM_LIMIT64.
    96                  *
    97                  * The PHYSMEM_LIMIT64 (8 GB) is the size of the
    98                  * fixed 1:1 identically mapped physical memory
    99                  * accessible during the bootstrap process.
    100                  * This is a severe limitation of the current
    101                  * kernel memory management.
    102                  *
    103                  */
     72                uintptr_t base = (uintptr_t) base64;
     73                size_t size = (size_t) size64;
    10474               
    105                 if (base > PHYSMEM_LIMIT64)
     75                if (!frame_adjust_zone_bounds(low, &base, &size))
    10676                        continue;
    107                
    108                 if (base + size > PHYSMEM_LIMIT64)
    109                         size = PHYSMEM_LIMIT64 - base;
    110 #endif
    11177               
    11278                if (e820table[i].type == MEMMAP_MEMORY_AVAILABLE) {
     
    11682                            FRAME_SIZE);
    11783                       
     84                        size_t count = SIZE2FRAMES(new_size);
    11885                        pfn_t pfn = ADDR2PFN(new_base);
    119                         size_t count = SIZE2FRAMES(new_size);
     86                        pfn_t conf;
    12087                       
    121                         pfn_t conf;
    122                         if ((minconf < pfn) || (minconf >= pfn + count))
    123                                 conf = pfn;
    124                         else
    125                                 conf = minconf;
    126                        
    127                         zone_create(pfn, count, conf, ZONE_AVAILABLE);
    128                        
    129                         // XXX this has to be removed
    130                         if (last_frame < ALIGN_UP(new_base + new_size, FRAME_SIZE))
    131                                 last_frame = ALIGN_UP(new_base + new_size, FRAME_SIZE);
     88                        if (low) {
     89                                if ((minconf < pfn) || (minconf >= pfn + count))
     90                                        conf = pfn;
     91                                else
     92                                        conf = minconf;
     93                                zone_create(pfn, count, conf,
     94                                    ZONE_AVAILABLE | ZONE_LOWMEM);
     95                        } else {
     96                                conf = zone_external_conf_alloc(count);
     97                                if (conf != 0)
     98                                        zone_create(pfn, count, conf,
     99                                            ZONE_AVAILABLE | ZONE_HIGHMEM);
     100                        }
    132101                } else if ((e820table[i].type == MEMMAP_MEMORY_ACPI) ||
    133102                    (e820table[i].type == MEMMAP_MEMORY_NVS)) {
     
    179148
    180149
    181 void frame_arch_init(void)
     150void frame_low_arch_init(void)
    182151{
    183152        pfn_t minconf;
     
    192161#endif
    193162               
    194                 init_e820_memory(minconf);
     163                init_e820_memory(minconf, true);
    195164               
    196165                /* Reserve frame 0 (BIOS data) */
     
    206175}
    207176
     177void frame_high_arch_init(void)
     178{
     179        if (config.cpu_active == 1)
     180                init_e820_memory(0, false);
     181}
     182
    208183/** @}
    209184 */
Note: See TracChangeset for help on using the changeset viewer.