Changeset 49ec568 in mainline


Ignore:
Timestamp:
2012-01-23T12:00:05Z (12 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
08cc26b, 9d09d7f
Parents:
10a5479d
Message:

improve the code a little bit (common constant, avoid any chance of integer overflow)

File:
1 edited

Legend:

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

    r10a5479d r49ec568  
    4646#include <print.h>
    4747
     48#define PHYSMEM_LIMIT32  UINT64_C(0x100000000)
     49
    4850size_t hardcoded_unmapped_ktext_size = 0;
    4951size_t hardcoded_unmapped_kdata_size = 0;
     
    5658                uint64_t base64 = e820table[i].base_address;
    5759                uint64_t size64 = e820table[i].size;
    58 
     60               
    5961#ifdef KARCH_ia32
    6062                /*
    6163                 * Restrict the e820 table entries to 32-bits.
    6264                 */
    63                 if (base64 >= 0x100000000ULL)
     65                if (base64 >= PHYSMEM_LIMIT32)
    6466                        continue;
    65                 if (base64 + size64 > 0x100000000ULL)
    66                         size64 -= base64 + size64 - 0x100000000ULL;
     67               
     68                if (base64 + size64 > PHYSMEM_LIMIT32)
     69                        size64 = PHYSMEM_LIMIT32 - base64;
    6770#endif
    68 
     71               
    6972                uintptr_t base = (uintptr_t) base64;
    7073                size_t size = (size_t) size64;
Note: See TracChangeset for help on using the changeset viewer.