Add a "count" field to struct memory_map.

pull/1/head
Michael Brown 2006-05-25 00:00:30 +00:00
parent 986f6ffff1
commit e4f8d6eed7
2 changed files with 11 additions and 6 deletions

View File

@ -138,7 +138,7 @@ static unsigned int extmemsize ( void ) {
* @ret rc Return status code * @ret rc Return status code
*/ */
static int meme820 ( struct memory_map *memmap ) { static int meme820 ( struct memory_map *memmap ) {
unsigned int index = 0; struct memory_region *region = memmap->regions;
uint32_t next = 0; uint32_t next = 0;
uint32_t smap; uint32_t smap;
unsigned int flags; unsigned int flags;
@ -169,11 +169,12 @@ static int meme820 ( struct memory_map *memmap ) {
if ( e820buf.type != E820_TYPE_RAM ) if ( e820buf.type != E820_TYPE_RAM )
continue; continue;
memmap->regions[index].start = e820buf.start; region->start = e820buf.start;
memmap->regions[index].end = e820buf.start + e820buf.len; region->end = e820buf.start + e820buf.len;
index++; region++;
memmap->count++;
} while ( ( next != 0 ) && } while ( ( next != 0 ) &&
( index < ( sizeof ( memmap->regions ) / ( memmap->count < ( sizeof ( memmap->regions ) /
sizeof ( memmap->regions[0] ) ) ) ); sizeof ( memmap->regions[0] ) ) ) );
return 0; return 0;
} }
@ -202,4 +203,5 @@ void get_memmap ( struct memory_map *memmap ) {
memmap->regions[0].end = ( basemem * 1024 ); memmap->regions[0].end = ( basemem * 1024 );
memmap->regions[1].start = 0x100000; memmap->regions[1].start = 0x100000;
memmap->regions[1].end = 0x100000 + ( extmem * 1024 ); memmap->regions[1].end = 0x100000 + ( extmem * 1024 );
memmap->count = 2;
} }

View File

@ -23,7 +23,10 @@ struct memory_region {
/** A memory map */ /** A memory map */
struct memory_map { struct memory_map {
/** Memory regions */
struct memory_region regions[MAX_MEMORY_REGIONS]; struct memory_region regions[MAX_MEMORY_REGIONS];
/** Number of used regions */
unsigned int count;
}; };
extern void get_memmap ( struct memory_map *memmap ); extern void get_memmap ( struct memory_map *memmap );