kern

diff src/mem.c @ 21:3ba93d8f586c

now ignoring parts of the memory map beyond 4gb instead of silently wrapping around and marking all holes as usable :)
author John Tsiombikas <nuclear@member.fsf.org>
date Sun, 03 Apr 2011 08:23:07 +0300
parents 369adbbd4bdd
children 5454cee245a3
line diff
     1.1 --- a/src/mem.c	Wed Mar 30 23:14:29 2011 +0300
     1.2 +++ b/src/mem.c	Sun Apr 03 08:23:07 2011 +0300
     1.3 @@ -59,22 +59,31 @@
     1.4  
     1.5  		printf("memory map:\n");
     1.6  		while(mem < mmap_end) {
     1.7 -			char *type;
     1.8 -			unsigned int end = mem->base_low + mem->length_low;
     1.9 +			/* ignore memory ranges that start beyond the 4gb mark */
    1.10 +			if(mem->base_high == 0 && mem->base_low != 0xffffffff) {
    1.11 +				char *type;
    1.12 +				unsigned int end, rest = 0xffffffff - mem->base_low;
    1.13  
    1.14 -			if(mem->type == MB_MEM_VALID) {
    1.15 -				type = "free:";
    1.16 -				add_memory(mem->base_low, mem->length_low);
    1.17 +				/* make sure the length does not extend beyond 4gb */
    1.18 +				if(mem->length_high || mem->length_low > rest) {
    1.19 +					mem->length_low = rest;
    1.20 +				}
    1.21 +				end	= mem->base_low + mem->length_low;
    1.22  
    1.23 -				num_pages = ADDR_TO_PAGE(mem->base_low + mem->length_low);
    1.24 -				if(max_pg < num_pages) {
    1.25 -					max_pg = num_pages;
    1.26 +				if(mem->type == MB_MEM_VALID) {
    1.27 +					type = "free:";
    1.28 +					add_memory(mem->base_low, mem->length_low);
    1.29 +
    1.30 +					num_pages = ADDR_TO_PAGE(mem->base_low + mem->length_low);
    1.31 +					if(max_pg < num_pages) {
    1.32 +						max_pg = num_pages;
    1.33 +					}
    1.34 +				} else {
    1.35 +					type = "hole:";
    1.36  				}
    1.37 -			} else {
    1.38 -				type = "hole:";
    1.39 +
    1.40 +				printf("  %s %x - %x (%u bytes)\n", type, mem->base_low, end, mem->length_low);
    1.41  			}
    1.42 -
    1.43 -			printf("  %s %x - %x (%u bytes)\n", type, mem->base_low, end, mem->length_low);
    1.44  			mem = (struct mboot_mmap*)((char*)mem + mem->skip + sizeof mem->skip);
    1.45  		}
    1.46  	} else if(mb->flags & MB_MEM) {