        IFND MMU_CONTEXT_I
MMU_CONTEXT_I   SET     1
;*************************************************************************
;** mmu.library                                                         **
;**                                                                     **
;** a system library for arbitration and control of the MC68K MMUs      **
;**                                                                     **
;** © 1998 THOR-Software, Thomas Richter                                **
;** No commercial use, reassembly, modification without prior, written  **
;** permission of the authors.                                          **
;** Including this library in any commercial software REQUIRES a        **
;** written permission and the payment of a small fee.                  **
;**                                                                     **
;**---------------------------------------------------------------------**
;** context related definitions                                         **
;*************************************************************************

        IFND EXEC_TYPES_I
        INCLUDE "exec/types.i"
        ENDC

;* A context keeps roughly speaking an MMU table. Lovers of unix might
;* want to use the name "process" instead, whereas an exec task or
;* a dos.library process might be called "a thread".
;* All tasks sharing one context share one logical addressing space. *

;* The definition of the context structure: This is something you do
;* not care about. *

        STRUCTURE MMUContext,0
        APTR    ctx_succ                ;struct MMUContext *
        APTR    ctx_pred                ;struct MMUContext *
        ;* private data here. Do not touch, modify, .... *
        LABEL ctx_SIZE


;* A mapping node, used to define the address space. This is what you find
;* in the list arbitrated by GetMapping().

;* This structure is stricly READ ONLY *

        STRUCT MappingNode,0
        APTR    map_succ                ;struct MappingNode *
        APTR    map_pred                ;struct MappingNode *
        
        ULONG   map_Lower               ;* lower address this node covers. *
        ULONG   map_Higher              ;* higher address, inclusive *
        ULONG   map_Flags               ;* internal use only. *
        ULONG   map_Properties          ;* see below for definitions *

        ;* the next one is a big union. All entries share the same location
        LABEL   map_UserData            ;* your data if this is invalid or swapped *
        LABEL   map_Page;               ;* destination page if bundled *
        LABEL   map_Descriptor          ;* pointer to a descriptor, alternatively *
        LONG    map_Delta               ;* added to the logical address if remapped *

        LABEL   map_SIZE



;* Property types:
;* These define the "property flags" you may assign to memory with
;* SetProperties() and SetPageProperties(). *

MAPP_WRITEPROTECTED     equ     (1<<2)
;* The region is write protected and the segmentation fault exception hooks
;* will be called on a write access. *

MAPP_USED               equ     (1<<3)
;* Set by the MMU on access, querried by GetPageProperties(). *

MAPP_MODIFIED           equ     (1<<4)
;* Set by the MMU on write accesses, querried by GetPageProperties(). *

MAPP_CACHEINHIBIT       equ     (1<<6)
;* Region is cache-inhibited, by default serialized access, precise
;* exception mode *

MAPP_SUPERVISORONLY     equ     (1<<7)
;* Supervisor access only. Note that this is currently implemented by
;* marking the pages as invalid in the user MMU tables, not by setting
;* the supervisor bit. *

MAPP_USERPAGE0          equ     (1<<8)
;* User page attribute 0, used only by 68040, 68060.
;* These bits are available at special pins of the CPU,
;* special hardware might require this. *

MAPP_USERPAGE1          equ     (1<<9)
;* User page attribute 1 *

MAPP_GLOBAL             equ     (1<<10)
;* This memory region is global. The MMU library makes currently no
;* effective use of this flag, and it makes only a difference for the
;* 040 and 060 anyhow. *

MAPP_BLANK              equ     (1<<11)
;* There's no memory here. If accessed, the access is quietly tolerated,
;* even though nothing useful should be expected. This is mainly to work
;* around bad software if no enforcer is available. *

MAPP_SINGLEPAGE         equ     (1<<12)
;* Give this page a private page descriptor. This flag IS A MUST
;* if you want to use GetPagePropertiesA/SetPagePropertiesA on
;* that page.  *

MAPP_COPYBACK           equ     (1<<13)
;* MC68040 or MC68060 advanced copyback mode enabled. The library sets this
;* by default for all non-chip memory. *

MAPP_INVALID            equ     (1<<14)
;* The page is invalid. Accessing it results in a segmentation fault, i.e.
;* the library will call the appropriate exception hooks. *

MAPP_REMAPPED           equ     (1<<15)
;* Page is redirected to a different memory region. Note that you MUST NOT
;* add this memory to the exec library free memory list because some DMA
;* devices don't support I/O from this region and the MMU library will
;* guru as soon as you try to place MMU tables in remapped memory.
;* This might change in the future. *

MAPP_SWAPPED            equ     (1<<16)
;* This page is currently swapped out. If a program accesses this, a
;* swapped-out fault is generated. UserData is available for a swapper
;* daemon, usually the memory.library. *

MAPP_ROM                equ     (1<<17)
;* This is read-only memory, but the library tolerates write accesses
;* quietly and no hook is called on writes. Hence, this turns the memory
;* region effectively into a "ROM". *

MAPP_SHARED             equ     (1<<18)
;* Shares the table of the global NULL context. This is currently not
;* implemented and should not be set. *

MAPP_TRANSLATED         equ     (1<<19)
;* This memory region is - probably partially - under control of the
;* transparent translation registers and should not be touched.
;* The mmu library does not handle the transparent translation very well
;* and tries to get rid of them on startup. *

MAPP_REPAIRABLE         equ     (1<<20)
;* This flag allows invalid or write protected pages to get repaired on
;* a fault by software rather than by swapping in a page.
;* The mmu.library will try to make the written data available to the
;* exception hook, and will try to provide readback data for the input
;* pipeline of the CPU. Note that this is very useful for debugging tools
;* and the like, but causes quite a lot of overhead.
;* Furthermore, MAPP_REPAIRABLE pages do not get user data. *

MAPP_IMPRECISE          equ     (1<<21)
;* If non-cacheable, allow imprecise exception mode *

MAPP_INDIRECT           equ     (1<<22)
;* Indirect table pointer to a user-provided table. Note that the mmu library
;* exception handler returns always a pointer to the descriptor pointing to
;* your descriptor, not to your descriptor directly. *

MAPP_BUNDLED            equ     (1<<23)
;* Several pages bundled to one physical page in memory, usually done to
;* map out memory. *

MAPP_USER0              equ     (1<<24)
MAPP_USER1              equ     (1<<25)
MAPP_USER2              equ     (1<<26)
MAPP_USER3              equ     (1<<27)
;* Strictly for you. Not touched by the library. *

MAPP_NONSERIALIZED      equ     (1<<29)
;* If non-cacheable, allow non-serialized access *

MAPP_TEMPORARY          equ     (1<<30)
;* This is internal use only, do not set this flag. *

        ENDC    ;       MMU_CONTEXT_I


