Subversion Repositories HelenOS

Rev

Rev 3343 | Rev 3618 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3343 Rev 3607
Line 279... Line 279...
279
 *
279
 *
280
 * @return Zero on failure, non-zero on success.
280
 * @return Zero on failure, non-zero on success.
281
 */
281
 */
282
int ofw_memmap(memmap_t *map)
282
int ofw_memmap(memmap_t *map)
283
{
283
{
284
    unsigned int ac = ofw_get_address_cells(ofw_memory);
284
    unsigned int ac = ofw_get_address_cells(ofw_memory) /
-
 
285
        (sizeof(uintptr_t) / sizeof(uint32_t));
285
    unsigned int sc = ofw_get_size_cells(ofw_memory);
286
    unsigned int sc = ofw_get_size_cells(ofw_memory) /
-
 
287
        (sizeof(uintptr_t) / sizeof(uint32_t));
-
 
288
    printf("address cells: %d, size cells: %d. ", ac, sc);
286
 
289
 
287
    uint32_t buf[((ac + sc) * MEMMAP_MAX_RECORDS)];
290
    uintptr_t buf[((ac + sc) * MEMMAP_MAX_RECORDS)];
288
    int ret = ofw_get_property(ofw_memory, "reg", buf, sizeof(buf));
291
    int ret = ofw_get_property(ofw_memory, "reg", buf, sizeof(buf));
289
    if (ret <= 0)       /* ret is the number of written bytes */
292
    if (ret <= 0)       /* ret is the number of written bytes */
290
        return false;
293
        return false;
291
 
294
 
292
    int pos;
295
    int pos;
293
    map->total = 0;
296
    map->total = 0;
294
    map->count = 0;
297
    map->count = 0;
295
    for (pos = 0; (pos < ret / sizeof(uint32_t)) &&
298
    for (pos = 0; (pos < ret / sizeof(uintptr_t)) &&
296
        (map->count < MEMMAP_MAX_RECORDS); pos += ac + sc) {
299
        (map->count < MEMMAP_MAX_RECORDS); pos += ac + sc) {
297
        void * start = (void *) ((uintptr_t) buf[pos + ac - 1]);
300
        void *start = (void *) (buf[pos + ac - 1]);
298
        unsigned int size = buf[pos + ac + sc - 1];
301
        unsigned int size = buf[pos + ac + sc - 1];
-
 
302
 
299
       
303
        /*
-
 
304
         * This is a hot fix of the issue which occurs on machines where there are
-
 
305
         * holes in the physical memory (such as SunBlade 1500). Should we detect a
-
 
306
         * hole in the physical memory, we will ignore any memory detected behind
-
 
307
         * the hole and pretend the hole does not exist.
-
 
308
         */
-
 
309
        if ((map->count > 0) &&
-
 
310
            (map->zones[map->count - 1].start + map->zones[map->count - 1].size
-
 
311
                < start))
-
 
312
            break;
-
 
313
 
300
        if (size > 0) {
314
        if (size > 0) {
301
            map->zones[map->count].start = start;
315
            map->zones[map->count].start = start;
302
            map->zones[map->count].size = size;
316
            map->zones[map->count].size = size;
303
            map->count++;
317
            map->count++;
304
            map->total += size;
318
            map->total += size;
Line 306... Line 320...
306
    }
320
    }
307
   
321
   
308
    return true;
322
    return true;
309
}
323
}
310
 
324
 
311
 
-
 
312
int ofw_screen(screen_t *screen)
325
int ofw_screen(screen_t *screen)
313
{
326
{
314
    char device_name[BUF_SIZE];
327
    char device_name[BUF_SIZE];
315
    uint32_t virtaddr;
328
    uint32_t virtaddr;
316
   
329