rewrite kseg2map in terms of mmumap as prep for reboot code. Reference: /n/atom/patch/applied/mmumap Date: Sat Mar 22 01:55:06 CET 2014 Signed-off-by: quanstro@quanstro.net --- /sys/src/nix/k10/mmu.c Sat Mar 22 01:54:06 2014 +++ /sys/src/nix/k10/mmu.c Sat Mar 22 01:54:07 2014 @@ -540,17 +540,15 @@ return 0; } -uintptr -kseg2map(uintmem pa, uintmem len, uint basef) +void +mmumap(uintmem pa, uintptr va, u64int len, uint basef) { int i, l; - uintptr va; uintmem mem, nextmem; PTE *pte, *pml4; - DBG("kseg2map: %#P %#P size %P\n", pa, pa+len, len); + DBG("map: %#P %#P size %P\n", pa, pa+len, len); pml4 = UINT2PTR(m->pml4->va); - va = KSEG2+pa; for(mem = pa; mem < pa+len; mem = nextmem){ nextmem = (mem + PGLSZ(0)) & ~m->pgszmask[0]; for(i = m->npgsz - 1; i >= 0; i--){ @@ -559,13 +557,19 @@ if(mem + PGLSZ(i) > pa+len) continue; if((l = mmuwalk(pml4, va, i, &pte, walkalloc)) < 0) - panic("mmu: kseg2map"); + panic("mmu: map"); *pte = mem|memflagssz(basef, PGLSZ(l)); nextmem = mem + PGLSZ(i); va += PGLSZ(i); break; } } +} + +uintptr +kseg2map(uintmem pa, uintmem len, uint basef) +{ + mmumap(pa, KSEG2+pa, len, basef); return KSEG2+pa; } --- /sys/src/nix/k10/fns.h Sat Mar 22 01:54:09 2014 +++ /sys/src/nix/k10/fns.h Sat Mar 22 01:54:09 2014 @@ -77,6 +77,7 @@ void machinit(void); void meminit(void); void mfence(void); +void mmumap(uintmem, uintptr, u64int, uint); void mmuflushtlb(uintmem); void mmuinit(void); uintmem mmuphysaddr(uintptr);