Changeset ad12b5ea in mainline


Ignore:
Timestamp:
2011-11-20T16:53:04Z (12 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
2686705
Parents:
a55ddc64
Message:

Factor out the amd64/ia32 code which calculates the bounds of
a zone after considering the low/hich memory split to a new
generic function frame_adjust_zone_bounds().

Location:
kernel
Files:
3 edited

Legend:

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

    ra55ddc64 rad12b5ea  
    5757       
    5858        for (i = 0; i < e820counter; i++) {
    59                 uint64_t base = e820table[i].base_address;
    60                 uint64_t size = e820table[i].size;
    61                 uintptr_t limit = config.identity_size;
     59                uintptr_t base = (uintptr_t) e820table[i].base_address;
     60                size_t size = (size_t) e820table[i].size;
    6261               
    63                 if (low) {
    64                         if (base > limit)
    65                                 continue;
    66                         if (base + size > limit)
    67                                 size = limit - base;
    68                 } else {
    69                         if (base + size <= limit)
    70                                 continue;
    71                         if (base <= limit) {
    72                                 size -= limit - base;
    73                                 base = limit;
    74                         }
    75                 }
     62                if (!frame_adjust_zone_bounds(low, &base, &size))
     63                        continue;
    7664               
    7765                if (e820table[i].type == MEMMAP_MEMORY_AVAILABLE) {
     
    9381                                    ZONE_AVAILABLE | ZONE_LOWMEM);
    9482                        } else {
    95                                 printf("count=%lld\n", (long long int) count);
    9683                                conf = zone_external_conf_alloc(count);
    9784                                zone_create(pfn, count, conf,
  • kernel/generic/include/mm/frame.h

    ra55ddc64 rad12b5ea  
    159159
    160160extern void frame_init(void);
     161extern bool frame_adjust_zone_bounds(bool, uintptr_t *, size_t *);
    161162extern void *frame_alloc_generic(uint8_t, frame_flags_t, size_t *);
    162163extern void *frame_alloc(uint8_t, frame_flags_t);
  • kernel/generic/src/mm/frame.c

    ra55ddc64 rad12b5ea  
    12641264}
    12651265
     1266/** Adjust bounds of physical memory region according to low/high memory split.
     1267 *
     1268 * @param low[in]       If true, the adujstment is performed to make the region
     1269 *                      fit in the low memory. Otherwise the adjustment is
     1270 *                      performed to make the region fit in the high memory.
     1271 * @param basep[inout]  Pointer to a variable which contains the region's base
     1272 *                      address and which may receive the adjusted base address.
     1273 * @param sizep[inout]  Pointer to a variable which contains the region's size
     1274 *                      and which may receive the adjusted size.
     1275 * @retun               True if the region still exists even after the
     1276 *                      adjustment, false otherwise.
     1277 */
     1278bool frame_adjust_zone_bounds(bool low, uintptr_t *basep, size_t *sizep)
     1279{
     1280        uintptr_t limit = config.identity_size;
     1281
     1282        if (low) {
     1283                if (*basep > limit)
     1284                        return false;
     1285                if (*basep + *sizep > limit)
     1286                        *sizep = limit - *basep;
     1287        } else {
     1288                if (*basep + *sizep <= limit)
     1289                        return false;
     1290                if (*basep <= limit) {
     1291                        *sizep -= limit - *basep;
     1292                        *basep = limit;
     1293                }
     1294        }
     1295        return true;
     1296}
     1297
    12661298/** Return total size of all zones.
    12671299 *
Note: See TracChangeset for help on using the changeset viewer.