home *** CD-ROM | disk | FTP | other *** search
- #ifndef QUARK_MMU_H
- #define QUARK_MMU_H
-
- #include <public/quark/types.h>
- #include <public/quark/task.h>
-
- #define PAGE_SIZE 4096UL
- #define PAGE_MASK (PAGE_SIZE-1)
- #define PAGE_SHIFT 12UL
- #define PAGE_ILLEGAL (0xffffffffUL)
-
- /* in Grant mode
- * PID is the target task
- * SourcePage describes the current Task`s Page
- * DestPage describes the target Task`s Page
- *
- * in Granted mode
- * PID is the source task
- * SourcePage describes the source Task`s Page
- * DestPage describes the current Task`s Page
- */
-
- /* Protection Page Type
- * If none is set USER/SUPER READ/WRITE is used
- */
-
- #define MMUPAGEMODEF_SUPERVISOR 0x1UL
- #define MMUPAGEMODEF_WRITEPROTECT 0x2UL
-
- #define MMUPAGEMODE_PROTECTIONMASK 0xffUL
-
- /* Cache Page Types
- * If none is set the default mode is used.
- * Beware..the QMMUSetPageMode(..SETPAGEMODE_CHANGE);
- * requires the COPYBACK pagemode flag to signal
- * that you wanna change to copyback.
- * Otherwise it wouldn`t change any cache related
- * fields
- */
- #define MMUPAGEMODEF_WRITETHROUGH 0x100UL
- #define MMUPAGEMODEF_INHIBITED 0x200UL
- #define MMUPAGEMODEF_MEMORYCOHERENCE 0x400UL
- #define MMUPAGEMODEF_GUARD 0x800UL
- #define MMUPAGEMODEF_COPYBACK 0x1000UL
-
- #define MMUPAGEMODE_CACHEMASK 0xff00UL
-
-
- /* This can be used to optimize QMMUSetPageMode()
- * if there`s no CacheFlush needed when you change
- * from CopyBack to anything else because you have
- * handled the cache issue yourself.
- * Actually..it's only used internal but it may be
- * useful.
- * When you use this make sure you know
- * exactly what you're doing.
- */
- #define MMUPAGEMODEF_NOCACHEFLUSH 0x10000UL
-
-
- /* Physical Pages
- */
- #define SETPAGEMODE_NORMAL 0x0UL /* Internal..first physical=virt mapping */
- #define SETPAGEMODE_GRANT 0x1UL
- #define SETPAGEMODE_GATE 0x2UL
- #define SETPAGEMODE_FLUSH 0x3UL
- #define SETPAGEMODE_CHANGE 0x4UL
-
- struct QMMUMapEntry
- {
- void *Address; /* The Address is not necessarily page aligned */
- u_int32_t Size;
- };
-
- struct QMMUTransEntry
- {
- q_pid_t PID;
- void *Address;
- u_int32_t PageCount;
- u_int16_t PageMode;
- u_int16_t Mode;
- };
-
- /* o If the MMUTransEntry->Mode & MMUMODEF_GRANTED the
- * page is granted to a different addressspace and you
- * can determine its logical page then by using MMUTAG_LOGICAL.
- * If you ask for the physical page by MMUTAG_PHYSICAL you
- * get no legal address (MMUTRANS_ILLEGALADDRESS) because
- * the page doesn`t exist in your current addressspace
- */
-
-
- /* This address is set if the page doesn`t exist in
- * the current addresspace or it`s granted to another
- * addressspace. It`s important to check the Mode to
- * get an idea what`s the real issue.
- */
- #define QMMUTRANS_ILLEGALADDRESS ((u_int32_t) -1)
-
- struct QMMUTranslation
- {
- /* Source area start
- * (Logical Address)
- */
- void *Address;
-
- /* Source area size
- * (Logical Address)
- */
- u_int32_t Size;
-
- /* The number of pages
- * the address space covered
- */
- u_int32_t Pages;
-
- /* The number of successful mapped
- * pages.
- */
- u_int32_t TranslatedPages;
-
- struct QMMUTransEntry TransTable[0];
- };
-
- #define QMMUTAG_DUMMY (0x2000)
-
- /* Get the real physical page addresses
- * of an object
- */
- #define QMMUTAG_PHYSICAL (QMMUTAG_DUMMY + 0x1)
-
- /* Get the real physical page addresses
- * of an object
- */
- #define QMMUTAG_LOGICAL (QMMUTAG_DUMMY + 0x2)
-
- /* Get the logical page addresses
- * of an object in another space
- */
- #define QMMUTAG_SUPERSPACE (QMMUTAG_DUMMY + 0x3)
-
- /*
- * Only Get 1 translation for a
- * linear page layout. So with
- * this tag you can break a virtual
- * area into linear logical/physical
- * areas.
- */
- #define QMMUTAG_LINEAR (QMMUTAG_DUMMY + 0x4)
-
- /* Sequence: QMMUTAG_LOCK, bool_t
- * Function: Lock all pages of the area
- * to the current physical page. This way
- * you make sure that the mapping isn't changed
- * or a page is swapped out during a dma transfer.
- */
- #define QMMUTAG_LOCK (QMMUTAG_DUMMY + 0x5)
-
- /* Sequence: QMMUTAG_UNLOCK, bool_t
- * Function: Unlock all pages of a previous locked
- * area.
- */
- #define QMMUTAG_UNLOCK (QMMUTAG_DUMMY + 0x6)
-
- /* Sequence: QMMUTAG_MARKBORDER, u_int32_t
- * Function: Create a NoCache Border around an area.
- * If you have no snoop cache hw this tag
- * marks the beginning and the end of a transfer
- * block as noncachable, so that accesses to
- * a cache line by the cpu and dma won`t cause
- * dirty data problems.
- */
- #define QMMUTAG_MARKBORDER (QMMUTAG_DUMMY + 0x7)
-
-
- /* Sequence: QMMUTAG_UNMARKBORDER, u_int32_t
- * Function: Remove a NoCache Border around an area.
- */
- #define QMMUTAG_UNMARKBORDER (QMMUTAG_DUMMY + 0x8)
-
-
- /* Sequence: QMMUTAG_DMAMODE, u_int32_t
- * Function: For the markborder no snoop mode you
- * can define the dma direction to give the kernel
- * to optimize the mapping.
- */
- #define QMMUTAG_DMAMODE (QMMUTAG_DUMMY + 0x9)
-
- /* Write into memory
- */
- #define QMMUDMAMODE_WRITE 0x0
- /* Read from memory
- */
- #define QMMUDMAMODE_READ 0x1
-
-
-
-
-
-
-
-
- #define QMMUGETPAGECOUNT(Address,Size) (size_t) (((Address + Size + PAGE_MASK) >> PAGE_SHIFT) - (Address >> PAGE_SHIFT))
-
-
-
-
-
-
-
-
-
- #endif
-