Lab 17, mmu init

What is fun about Inferno OS that our CPU may not have MMU support and still we are able to port Inferno to such architecture. That’s because Inferno OS implements Dis virtual machine and all users processes are actually Dis byte-codes interpreters on JIT compiled. So address space is virtual by software layer and it is very good for portability of the system.

Anyway, still it is good to have the MMU initialized (may be needed later to work with framebuffer) and it looks simple enough to do.

So idea that we map 1:1 all memory that we have SDRAM banks, then we also map IO address space and also low-high interrupt vectors. Also some adjustments to load.s to have mmuinit() to called before main():

void mmuinit(void)
{
    PTE *l1, *l2;
    uintptr pa, va;

    l1 = (PTE*)PADDR(L1);
    l2 = (PTE*)PADDR(L2);

    /* map all of ram at KZERO */
    va = KZERO;
    for(pa = PHYSDRAM; pa < PHYSDRAM+DRAMSIZE; pa += MiB){
        l1[L1X(va)] = pa|Dom0|L1AP(Krw)|Section|Cached|Buffered;
        va += MiB;
    }

    /* identity map first MB of ram so mmu can be enabled */
    l1[L1X(PHYSDRAM)] = PHYSDRAM|Dom0|L1AP(Krw)|Section|Cached|Buffered;

    /* map i/o registers */
    va = VIRTIO;
    for(pa = PHYSIO; pa < PHYSIO+IOSIZE; pa += MiB){
        l1[L1X(va)] = pa|Dom0|L1AP(Krw)|Section;
        va += MiB;
    }

    /* double map exception vectors at top of virtual memory */
    va = HVECTORS;
    l1[L1X(va)] = (uintptr)l2|Dom0|Coarse;
    l2[L2X(va)] = PHYSDRAM|L2AP(Krw)|Small;
}

There are also minor changes to dat.h, mem.h, etc

FILES:
rpi-lab17.zip

This entry was posted in Blog, Inferno OS, Raspberry Pi, Research. Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>