home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 15 / AACD15.ISO / AACD / System / MorphOS / Developer / include / public / quark / mmu.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-11-02  |  4.9 KB  |  214 lines

  1. #ifndef    QUARK_MMU_H
  2. #define    QUARK_MMU_H
  3.  
  4. #include <public/quark/types.h>
  5. #include <public/quark/task.h>
  6.  
  7. #define    PAGE_SIZE    4096UL
  8. #define    PAGE_MASK    (PAGE_SIZE-1)
  9. #define    PAGE_SHIFT    12UL
  10. #define    PAGE_ILLEGAL    (0xffffffffUL)
  11.  
  12. /* in Grant mode
  13.  * PID is the target task
  14.  * SourcePage describes the current Task`s Page
  15.  * DestPage describes the target Task`s Page
  16.  *
  17.  * in Granted mode
  18.  * PID is the source task
  19.  * SourcePage describes the source Task`s Page
  20.  * DestPage describes the current Task`s Page
  21.  */
  22.  
  23. /* Protection Page Type
  24.  * If none is set USER/SUPER READ/WRITE is used
  25.  */
  26.  
  27. #define    MMUPAGEMODEF_SUPERVISOR        0x1UL
  28. #define    MMUPAGEMODEF_WRITEPROTECT    0x2UL
  29.  
  30. #define    MMUPAGEMODE_PROTECTIONMASK    0xffUL
  31.  
  32. /* Cache Page Types
  33.  * If none is set the default mode is used.
  34.  * Beware..the QMMUSetPageMode(..SETPAGEMODE_CHANGE);
  35.  * requires the COPYBACK pagemode flag to signal
  36.  * that you wanna change to copyback.
  37.  * Otherwise it wouldn`t change any cache related
  38.  * fields
  39.  */
  40. #define    MMUPAGEMODEF_WRITETHROUGH    0x100UL
  41. #define    MMUPAGEMODEF_INHIBITED        0x200UL
  42. #define    MMUPAGEMODEF_MEMORYCOHERENCE    0x400UL
  43. #define    MMUPAGEMODEF_GUARD        0x800UL
  44. #define    MMUPAGEMODEF_COPYBACK        0x1000UL
  45.  
  46. #define    MMUPAGEMODE_CACHEMASK        0xff00UL
  47.  
  48.  
  49. /* This can be used to optimize QMMUSetPageMode()
  50.  * if there`s no CacheFlush needed when you change
  51.  * from CopyBack to anything else because you have
  52.  * handled the cache issue yourself.
  53.  * Actually..it's only used internal but it may be
  54.  * useful.
  55.  * When you use this make sure you know
  56.  * exactly what you're doing.
  57.  */
  58. #define    MMUPAGEMODEF_NOCACHEFLUSH    0x10000UL
  59.  
  60.  
  61. /* Physical Pages
  62.  */
  63. #define    SETPAGEMODE_NORMAL    0x0UL    /* Internal..first physical=virt mapping */
  64. #define    SETPAGEMODE_GRANT    0x1UL
  65. #define    SETPAGEMODE_GATE    0x2UL
  66. #define    SETPAGEMODE_FLUSH    0x3UL
  67. #define    SETPAGEMODE_CHANGE    0x4UL
  68.  
  69. struct QMMUMapEntry
  70. {
  71.     void        *Address;    /* The Address is not necessarily page aligned */
  72.     u_int32_t    Size;
  73. };
  74.  
  75. struct QMMUTransEntry
  76. {
  77.     q_pid_t        PID;
  78.     void        *Address;
  79.     u_int32_t    PageCount;
  80.     u_int16_t    PageMode;
  81.     u_int16_t    Mode;
  82. };
  83.  
  84. /* o If the MMUTransEntry->Mode & MMUMODEF_GRANTED the
  85.  *   page is granted to a different addressspace and you
  86.  *   can determine its logical page then by using MMUTAG_LOGICAL.
  87.  *   If you ask for the physical page by MMUTAG_PHYSICAL you
  88.  *   get no legal address (MMUTRANS_ILLEGALADDRESS) because
  89.  *   the page doesn`t exist in your current addressspace
  90.  */
  91.  
  92.  
  93. /* This address is set if the page doesn`t exist in
  94.  * the current addresspace or it`s granted to another
  95.  * addressspace. It`s important to check the Mode to
  96.  * get an idea what`s the real issue.
  97.  */
  98. #define    QMMUTRANS_ILLEGALADDRESS    ((u_int32_t) -1)
  99.  
  100. struct QMMUTranslation
  101. {
  102.     /* Source area start
  103.          * (Logical Address)
  104.          */
  105.     void            *Address;
  106.  
  107.     /* Source area size
  108.          * (Logical Address)
  109.          */
  110.     u_int32_t        Size;
  111.  
  112.     /* The number of pages
  113.      * the address space covered
  114.      */
  115.     u_int32_t        Pages;
  116.  
  117.     /* The number of successful mapped
  118.      * pages.
  119.      */
  120.     u_int32_t        TranslatedPages;
  121.  
  122.     struct QMMUTransEntry    TransTable[0];
  123. };
  124.  
  125. #define QMMUTAG_DUMMY        (0x2000)
  126.  
  127. /* Get the real physical page addresses
  128.  * of an object
  129.  */
  130. #define    QMMUTAG_PHYSICAL    (QMMUTAG_DUMMY + 0x1)
  131.  
  132. /* Get the real physical page addresses
  133.  * of an object
  134.  */
  135. #define    QMMUTAG_LOGICAL        (QMMUTAG_DUMMY + 0x2)
  136.  
  137. /* Get the logical page addresses
  138.  * of an object in another space
  139.  */
  140. #define    QMMUTAG_SUPERSPACE    (QMMUTAG_DUMMY + 0x3)
  141.  
  142. /* 
  143.  * Only Get 1 translation for a
  144.  * linear page layout. So with
  145.  * this tag you can break a virtual
  146.  * area into linear logical/physical
  147.  * areas.
  148.  */
  149. #define    QMMUTAG_LINEAR        (QMMUTAG_DUMMY + 0x4)
  150.  
  151. /* Sequence: QMMUTAG_LOCK, bool_t
  152.  * Function: Lock all pages of the area
  153.  * to the current physical page. This way
  154.  * you make sure that the mapping isn't changed
  155.  * or a page is swapped out during a dma transfer.
  156.  */
  157. #define    QMMUTAG_LOCK        (QMMUTAG_DUMMY + 0x5)
  158.  
  159. /* Sequence: QMMUTAG_UNLOCK, bool_t
  160.  * Function: Unlock all pages of a previous locked
  161.  *           area.
  162.  */
  163. #define    QMMUTAG_UNLOCK        (QMMUTAG_DUMMY + 0x6)
  164.  
  165. /* Sequence: QMMUTAG_MARKBORDER, u_int32_t
  166.  * Function: Create a NoCache Border around an area.
  167.  * If you have no snoop cache hw this tag
  168.  * marks the beginning and the end of a transfer
  169.  * block as noncachable, so that accesses to 
  170.  * a cache line by the cpu and dma won`t cause
  171.  * dirty data problems.
  172.  */
  173. #define    QMMUTAG_MARKBORDER    (QMMUTAG_DUMMY + 0x7)
  174.  
  175.  
  176. /* Sequence: QMMUTAG_UNMARKBORDER, u_int32_t
  177.  * Function: Remove a NoCache Border around an area.
  178.  */
  179. #define    QMMUTAG_UNMARKBORDER    (QMMUTAG_DUMMY + 0x8)
  180.  
  181.  
  182. /* Sequence: QMMUTAG_DMAMODE, u_int32_t
  183.  * Function: For the markborder no snoop mode you
  184.  * can define the dma direction to give the kernel
  185.  * to optimize the mapping.
  186.  */
  187. #define    QMMUTAG_DMAMODE        (QMMUTAG_DUMMY + 0x9)
  188.  
  189. /* Write into memory
  190.  */
  191. #define    QMMUDMAMODE_WRITE    0x0
  192. /* Read from memory
  193.  */
  194. #define    QMMUDMAMODE_READ    0x1
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203. #define    QMMUGETPAGECOUNT(Address,Size)    (size_t) (((Address + Size + PAGE_MASK) >> PAGE_SHIFT) - (Address >> PAGE_SHIFT))
  204.  
  205.  
  206.  
  207.  
  208.  
  209.  
  210.  
  211.  
  212.  
  213. #endif
  214.