281,10 → 281,13 |
*/ |
int ofw_memmap(memmap_t *map) |
{ |
unsigned int ac = ofw_get_address_cells(ofw_memory); |
unsigned int sc = ofw_get_size_cells(ofw_memory); |
unsigned int ac = ofw_get_address_cells(ofw_memory) / |
(sizeof(uintptr_t) / sizeof(uint32_t)); |
unsigned int sc = ofw_get_size_cells(ofw_memory) / |
(sizeof(uintptr_t) / sizeof(uint32_t)); |
printf("address cells: %d, size cells: %d. ", ac, sc); |
|
uint32_t buf[((ac + sc) * MEMMAP_MAX_RECORDS)]; |
uintptr_t buf[((ac + sc) * MEMMAP_MAX_RECORDS)]; |
int ret = ofw_get_property(ofw_memory, "reg", buf, sizeof(buf)); |
if (ret <= 0) /* ret is the number of written bytes */ |
return false; |
292,11 → 295,22 |
int pos; |
map->total = 0; |
map->count = 0; |
for (pos = 0; (pos < ret / sizeof(uint32_t)) && |
for (pos = 0; (pos < ret / sizeof(uintptr_t)) && |
(map->count < MEMMAP_MAX_RECORDS); pos += ac + sc) { |
void * start = (void *) ((uintptr_t) buf[pos + ac - 1]); |
void *start = (void *) (buf[pos + ac - 1]); |
unsigned int size = buf[pos + ac + sc - 1]; |
|
|
/* |
* This is a hot fix of the issue which occurs on machines where there are |
* holes in the physical memory (such as SunBlade 1500). Should we detect a |
* hole in the physical memory, we will ignore any memory detected behind |
* the hole and pretend the hole does not exist. |
*/ |
if ((map->count > 0) && |
(map->zones[map->count - 1].start + map->zones[map->count - 1].size |
< start)) |
break; |
|
if (size > 0) { |
map->zones[map->count].start = start; |
map->zones[map->count].size = size; |
308,7 → 322,6 |
return true; |
} |
|
|
int ofw_screen(screen_t *screen) |
{ |
char device_name[BUF_SIZE]; |