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


Ignore:
Timestamp:
2010-07-02T14:19:30Z (14 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
89c57b6
Parents:
fe7abd0 (diff), e3ee9b9 (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

    rfe7abd0 rcefb126  
    4747#include <print.h>
    4848
     49#define PHYSMEM_LIMIT32  0x07c000000ull
     50#define PHYSMEM_LIMIT64  0x200000000ull
     51
    4952size_t hardcoded_unmapped_ktext_size = 0;
    5053size_t hardcoded_unmapped_kdata_size = 0;
     
    5558{
    5659        unsigned int i;
    57 
     60       
    5861        for (i = 0; i < e820counter; i++) {
    5962                uint64_t base = e820table[i].base_address;
     
    6164               
    6265#ifdef __32_BITS__
    63                 /* Ignore physical memory above 4 GB */
    64                 if ((base >> 32) != 0)
     66                /*
     67                 * XXX FIXME:
     68                 *
     69                 * Ignore zones which start above PHYSMEM_LIMIT32
     70                 * or clip zones which go beyond PHYSMEM_LIMIT32.
     71                 *
     72                 * The PHYSMEM_LIMIT32 (2 GB - 64 MB) is a rather
     73                 * arbitrary constant which allows to have at
     74                 * least 64 MB in the kernel address space to
     75                 * map hardware resources.
     76                 *
     77                 * The kernel uses fixed 1:1 identity mapping
     78                 * of the physical memory with 2:2 GB split.
     79                 * This is a severe limitation of the current
     80                 * kernel memory management.
     81                 *
     82                 */
     83               
     84                if (base > PHYSMEM_LIMIT32)
    6585                        continue;
    6686               
    67                 /* Clip regions above 4 GB */
    68                 if (((base + size) >> 32) != 0)
    69                         size = 0xffffffff - base;
    70 #endif
    71 
    72                 pfn_t pfn;
    73                 size_t count;
     87                if (base + size > PHYSMEM_LIMIT32)
     88                        size = PHYSMEM_LIMIT32 - base;
     89#endif
     90               
     91#ifdef __64_BITS__
     92                /*
     93                 * XXX FIXME:
     94                 *
     95                 * Ignore zones which start above PHYSMEM_LIMIT64
     96                 * or clip zones which go beyond PHYSMEM_LIMIT64.
     97                 *
     98                 * The PHYSMEM_LIMIT64 (8 GB) is the size of the
     99                 * fixed 1:1 identically mapped physical memory
     100                 * accessible during the bootstrap process.
     101                 * This is a severe limitation of the current
     102                 * kernel memory management.
     103                 *
     104                 */
     105               
     106                if (base > PHYSMEM_LIMIT64)
     107                        continue;
     108               
     109                if (base + size > PHYSMEM_LIMIT64)
     110                        size = PHYSMEM_LIMIT64 - base;
     111#endif
    74112               
    75113                if (e820table[i].type == MEMMAP_MEMORY_AVAILABLE) {
    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));
     114                        /* To be safe, make the available zone possibly smaller */
     115                        uint64_t new_base = ALIGN_UP(base, FRAME_SIZE);
     116                        uint64_t new_size = ALIGN_DOWN(size - (new_base - base),
     117                            FRAME_SIZE);
     118                       
     119                        pfn_t pfn = ADDR2PFN(new_base);
     120                        size_t count = SIZE2FRAMES(new_size);
    79121                       
    80122                        pfn_t conf;
     
    87129                       
    88130                        // 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);
     131                        if (last_frame < ALIGN_UP(new_base + new_size, FRAME_SIZE))
     132                                last_frame = ALIGN_UP(new_base + new_size, FRAME_SIZE);
    91133                }
    92134               
    93135                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);
     136                        /* To be safe, make the reserved zone possibly larger */
     137                        uint64_t new_base = ALIGN_DOWN(base, FRAME_SIZE);
     138                        uint64_t new_size = ALIGN_UP(size + (base - new_base),
     139                            FRAME_SIZE);
     140                       
     141                        zone_create(ADDR2PFN(new_base), SIZE2FRAMES(new_size), 0,
     142                            ZONE_RESERVED);
    99143                }
    100144               
    101145                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);
     146                        /* To be safe, make the firmware zone possibly larger */
     147                        uint64_t new_base = ALIGN_DOWN(base, FRAME_SIZE);
     148                        uint64_t new_size = ALIGN_UP(size + (base - new_base),
     149                            FRAME_SIZE);
     150                       
     151                        zone_create(ADDR2PFN(new_base), SIZE2FRAMES(new_size), 0,
     152                            ZONE_FIRMWARE);
    107153                }
    108154        }
     
    121167{
    122168        unsigned int i;
    123         const char *name;
     169        printf("[base            ] [size            ] [name   ]\n");
    124170       
    125         printf("Base               Size               Name\n");
    126         printf("------------------ ------------------ ---------\n");
    127                
    128171        for (i = 0; i < e820counter; i++) {
     172                const char *name;
     173               
    129174                if (e820table[i].type <= MEMMAP_MEMORY_UNUSABLE)
    130175                        name = e820names[e820table[i].type];
     
    132177                        name = "invalid";
    133178               
    134                 printf("%#18llx %#18llx %s\n", e820table[i].base_address,
     179                printf("%#018" PRIx64 " %#018" PRIx64" %s\n", e820table[i].base_address,
    135180                    e820table[i].size, name);
    136181        }
     
    150195                    hardcoded_unmapped_kdata_size));
    151196#endif
    152 
     197               
    153198                init_e820_memory(minconf);
    154199               
Note: See TracChangeset for help on using the changeset viewer.