[MMU project] Avoiding Attributes translations

Hesham Moustafa heshamelmatary at gmail.com
Sun Jul 22 18:47:25 UTC 2012


Hey,

I have implemented a solution to avoid attributes translation from
high-level API (libmm) to BSP code.
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.
The following is how i implemented it.

-High-level API ( ..../rtems/cpukit/libmm/libmmu.h)

#define RTEMS_MPROT_LOCKED                              0x0
#define RTEMS_MPROT_READ_ONLY                        0x1
#define RTEMS_MPROT_WRITE_ENABLE                  0x2
#define RTEMS_MPROT_EXE_ENABLE                      0x3
.
.
.
.
.
rtems_status_code rtems_memory_management_set_write
(
  rtems_memory_management_entry* const mpe;
);

rtems_status_code rtems_memory_management_set_read_only
(
  rtems_memory_management_entry* const mpe;
);

- CPU code ( .../lib/libcpu/powerpc/mpc6xx/mmu/mmu_support.h )

/* Access definition macros below (from powerpc manual ) */
#define _PPC_MMU_ACCESS_SUPERVISOR_ONLY     0
#define _PPC_MMU_ACCESS_SUPERVISOR_WRITE_ONLY   1
#define _PPC_MMU_ACCESS_NO_PROT        2  //no protection
#define _PPC_MMU_ACCESS_READ_ONLY      3


- CPU code ( .../lib/libcpu/powerpc/mpc6xx/mmu/pagetabel_.c )

uint32_t attr_translation[3] = {
        _PPC_MMU_ACCESS_SUPERVISOR_ONLY,
        _PPC_MMU_ACCESS_READ_ONLY,
        _PPC_MMU_ACCESS_NO_PROT
       };
.
.
.
.
.
int translate_access_attr(uint32_t attr, int * wimg, int * pp){
  int temp;
  temp = attr&0xff;
  *pp = attr_translation[temp];
  if (*pp != 0 || *pp != 2 ||  *pp != 3) {
    printf("This feature is not supported by CPU");
  }
  .
  .
  .
  .
}

Hope to get some feed backs.

regards,
Hesham
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/devel/attachments/20120722/f57f047d/attachment.html>


More information about the devel mailing list