<div dir="ltr">Hey,<div><br></div><div>I have implemented a solution to avoid attributes translation from high-level API (libmm) to BSP code.</div><div>It's just a table maps high-level attributes with CPU attributes. Every CPU that supports MMU/MPU should define this table on its own way. Universal attributes are defined at high-level API, if one CPU does not support any given attributes, that will return/print error.</div>
<div>The following is how i implemented it.</div><div><br></div><div>-High-level API ( ..../rtems/cpukit/libmm/libmmu.h) </div><div><br></div><div><div>#define RTEMS_MPROT_LOCKED 0x0</div><div>
#define RTEMS_MPROT_READ_ONLY 0x1</div><div>#define RTEMS_MPROT_WRITE_ENABLE 0x2</div><div>#define RTEMS_MPROT_EXE_ENABLE 0x3</div></div><div>.</div><div>.</div>
<div>.</div><div>.</div><div>.</div><div><div>rtems_status_code rtems_memory_management_set_write</div><div>(</div><div> rtems_memory_management_entry* const mpe;</div><div>);</div><div><br></div><div>rtems_status_code rtems_memory_management_set_read_only</div>
<div>(</div><div> rtems_memory_management_entry* const mpe;</div><div>);</div></div><div><br></div><div>- CPU code ( .../lib/libcpu/powerpc/mpc6xx/mmu/mmu_support.h )</div><div><br></div><div><div>/* Access definition macros below (from powerpc manual ) */</div>
<div>#define _PPC_MMU_ACCESS_SUPERVISOR_ONLY 0</div><div>#define _PPC_MMU_ACCESS_SUPERVISOR_WRITE_ONLY 1</div><div>#define _PPC_MMU_ACCESS_NO_PROT 2 //no protection</div><div>#define _PPC_MMU_ACCESS_READ_ONLY 3</div>
</div><div><br></div><div><br></div><div>- CPU code ( .../lib/libcpu/powerpc/mpc6xx/mmu/pagetabel_.c )</div><div><br></div><div><div>uint32_t attr_translation[3] = { </div><div> _PPC_MMU_ACCESS_SUPERVISOR_ONLY,</div>
<div> _PPC_MMU_ACCESS_READ_ONLY,</div><div> _PPC_MMU_ACCESS_NO_PROT</div><div> }; </div></div><div>.</div><div>.</div><div>.</div><div>.</div><div>.</div><div><div>int translate_access_attr(uint32_t attr, int * wimg, int * pp){</div>
<div> int temp;</div><div> temp = attr&0xff;</div><div> *pp = attr_translation[temp];</div><div> if (*pp != 0 || *pp != 2 || *pp != 3) { </div><div> printf("This feature is not supported by CPU");</div>
<div> } </div><div> .</div><div> .</div><div> . </div><div> .</div><div>}</div><div><br></div><div>Hope to get some feed backs.</div><div><br></div><div>regards,</div><div>Hesham</div><div id="WISESTAMP_SIG_2390"><div style="font-size:13.3px;font-family:Verdana,Arial,Helvetica,sans-serif">
<img src="https://wisestamp.appspot.com/pixel.png?p=chrome&v=3.11.16.100&t=1342981937319&u=e11f5d100c4ca423" width="1" height="1"></div></div></div></div>