Ignore:
File:
1 edited

Legend:

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

    r7e752b2 r98000fb  
    2727 */
    2828
    29 /** @addtogroup ppc32mm
     29/** @addtogroup ppc32mm 
    3030 * @{
    3131 */
     
    4141
    4242uintptr_t last_frame = 0;
    43 memmap_t memmap;
    4443
    4544void physmem_print(void)
    4645{
    47         printf("[base    ] [size    ]\n");
     46        unsigned int i;
    4847       
    49         size_t i;
    50         for (i = 0; i < memmap.cnt; i++) {
    51                 printf("%p %#0zx\n", memmap.zones[i].start,
    52                     memmap.zones[i].size);
     48        printf("Base       Size\n");
     49        printf("---------- ----------\n");
     50               
     51        for (i = 0; i < bootinfo.memmap.count; i++) {
     52                printf("%#10x %#10x\n", bootinfo.memmap.zones[i].start,
     53                        bootinfo.memmap.zones[i].size);
    5354        }
    5455}
     
    5859        pfn_t minconf = 2;
    5960        size_t i;
     61        pfn_t start, conf;
     62        size_t size;
    6063       
    61         for (i = 0; i < memmap.cnt; i++) {
    62                 /* To be safe, make the available zone possibly smaller */
    63                 uintptr_t new_start = ALIGN_UP((uintptr_t) memmap.zones[i].start,
    64                     FRAME_SIZE);
    65                 size_t new_size = ALIGN_DOWN(memmap.zones[i].size -
    66                     (new_start - ((uintptr_t) memmap.zones[i].start)), FRAME_SIZE);
     64        for (i = 0; i < bootinfo.memmap.count; i++) {
     65                start = ADDR2PFN(ALIGN_UP(bootinfo.memmap.zones[i].start, FRAME_SIZE));
     66                size = SIZE2FRAMES(ALIGN_DOWN(bootinfo.memmap.zones[i].size, FRAME_SIZE));
    6767               
    68                 pfn_t pfn = ADDR2PFN(new_start);
    69                 size_t count = SIZE2FRAMES(new_size);
    70                
    71                 pfn_t conf;
    72                 if ((minconf < pfn) || (minconf >= pfn + count))
    73                         conf = pfn;
     68                if ((minconf < start) || (minconf >= start + size))
     69                        conf = start;
    7470                else
    7571                        conf = minconf;
    7672               
    77                 zone_create(pfn, count, conf, 0);
    78                
    79                 if (last_frame < ALIGN_UP(new_start + new_size, FRAME_SIZE))
    80                         last_frame = ALIGN_UP(new_start + new_size, FRAME_SIZE);
     73                zone_create(start, size, conf, 0);
     74                if (last_frame < ALIGN_UP(bootinfo.memmap.zones[i].start + bootinfo.memmap.zones[i].size, FRAME_SIZE))
     75                        last_frame = ALIGN_UP(bootinfo.memmap.zones[i].start + bootinfo.memmap.zones[i].size, FRAME_SIZE);
    8176        }
    8277       
     
    8681       
    8782        /* Mark the Page Hash Table frames as unavailable */
    88         uint32_t sdr1 = sdr1_get();
    89        
    90         // FIXME: compute size of PHT exactly
    91         frame_mark_unavailable(ADDR2PFN(sdr1 & 0xffff000), 16);
     83        uint32_t sdr1;
     84        asm volatile (
     85                "mfsdr1 %0\n"
     86                : "=r" (sdr1)
     87        );
     88        frame_mark_unavailable(ADDR2PFN(sdr1 & 0xffff000), 16); // FIXME
    9289}
    9390
Note: See TracChangeset for help on using the changeset viewer.