[GSoC2012] Problem with understanding low-level mmu

Gedare Bloom gedare at rtems.org
Mon Jun 18 15:39:40 UTC 2012


On Sun, Jun 17, 2012 at 6:06 PM, Hesham Moustafa
<heshamelmatary at gmail.com> wrote:
> hi,
>
> I have created initial implementation for two interfaces of Arena manager
> that make use of mmu, my project will depend on ARM architecture, but
> currently i am working on high-level stage only and wanna test my high-level
> code. A previous MMU project implemented low-level code for MMU support for
> powerpc but i have no experience with powerpc and i need a little help.
>
> i wanna understand this piece of code which reside at
> libcpu/powerpc/mpc6xx/mmu/pagetable_.c
>
>
>  83 static int translate_access_attr(uint32_t attr, int * wimg, int * pp){
>  84   int temp;
>  85   temp = attr&0x0f;
>  86   if(  temp  == 0x05 )
>  87     *pp= _PPC_MMU_ACCESS_READ_ONLY;
>  88   else if( temp == 0x0c )
>  89     *pp= _PPC_MMU_ACCESS_SUPERVISOR_ONLY;
>  90   else if( temp == 0x0d )
>  91     *pp= _PPC_MMU_ACCESS_SUPERVISOR_WRITE_ONLY;
>  92   else if( temp == 0x0f )
>  93     *pp= _PPC_MMU_ACCESS_NO_PROT;
>  94
>  95   temp = (attr&0xff00)>8;
Apparently the wimg attributes are being stored in bits 8-15 of attr,
and this function translates them to something usable by powerpc. You
can see that the low order 8 bits (actually just four bits: 0-3) are
storing some additional attributes e.g. ro, supervisor,
supervisor_write, and no_protect). After the shift, the low-order bits
now will store the wimg bits.

>  96   *wimg = ((temp&1)<2) | ((temp&2)<2) | ((temp&4)>1) |((temp&8)>3) ;
This shows the wimg bits (which Sebastian explained briefly) are being
set... The bits are being shuffled around in order to match the ppc's
mmu requirements. This shows the bits being shifted as follows from
the attribute bits to the wimg bits:
bit 0 -> bit 3
bit 1 -> bit 4
bit 2 -> bit 1
bit 3 -> bit 0

>  97
>  98   return 0;
>  99 }
>
>
>
> I think the low-byte of attr is only have value and the rest are zeros (
> because permissions are uint8_t )
>
> so that like is confusing me
> temp = (attr&0xff00)>8;
>
> how attr bits are represented and wimg ??
> thanks,
> Hesham
>
>
> _______________________________________________
> rtems-devel mailing list
> rtems-devel at rtems.org
> http://www.rtems.org/mailman/listinfo/rtems-devel
>




More information about the devel mailing list