;*************************************************************************
;** 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.                  **
;**                                                                     **
;** This is an internal header file, do not depend on anything here.    **
;** Use the official include files.                                     **
;** Distributed only for the mmu.library development group for private  **
;** use.                                                                **
;**                                                                     **
;**---------------------------------------------------------------------**
;** Block: The context                                                  **
;** Definition of the "Context", the basic object of the mmu.lib        **
;*************************************************************************

;FOLD Context
;*************************************************
;** Context                                     **
;** This defines the Context structure.         **
;** It keeps informations about a MMU table     **
;*************************************************
        rsreset
ctx_succ:               rs.l 1
ctx_pred:               rs.l 1          ;doubly linked list
ctx_type:               rs.b 1          ;NT_CONTEXT
ctx_pri:                rs.b 1          ;unused
ctx_name:               rs.l 1          ;name of this context, if any

ctx_usecount:           rs.w 1          ;context use count
ctx_flags:              rs.l 1          ;flags, see below

ctx_Mapping:            rs.l 3          ;hardware independent mapping
ctx_RootPointer:        rs.l 2          ;hardware dependent root pointer
ctx_Root:               rs.l 1          ;CPU readable address of the MMU
                                        ;base table

ctx_Semaphore:          rs.b $2e        ;access to this structure
                                        ;the next onces are the switch
                                        ;and lauch entries for tasks
                                        ;added to this context.
                                        ;this works with a little magic
                                        ;a part of this structure is
                                        ;run as code (Urgh)
ctx_SwitchEntry:        rs.w 3          ;A JSR $xxxx
ctx_LaunchEntry:        rs.w 3          ;A JSR $xxxx
ctx_len:                rs.b 0
;ENDFOLD
;FOLD Flags
ctxf_dirty      =       31      ;this context needs rebuild
;ENDFOLD
;FOLD MapNode
;*************************************************
;** MapNode                                     **
;** this structure describes the properties of  **
;** the memory for the given context            **
;*************************************************
        rsreset
map_succ:               rs.l 1          ;doubly linked
map_pred:               rs.l 1          ;list
map_lower:              rs.l 1          ;lower address
map_higher:             rs.l 1          ;higher address, inclusive
map_Mask:               rs.l 0          ;if this is used to modify a context: Property mask here
map_MMUNode:            rs.l 1          ;pointer for the MMU node describing this
map_Flags:              rs.l 1          ;see below
map_Properties:         rs.l 1          ;properties of this block
map_Delta:              rs.l 0          ;alternatively: The difference (!) between the logical and the physical address
                                        ;added to the logical address to get the physical address
map_UserPtr:            rs.l 1          ;for user data if invalid, or for memory destination if indirect
map_len:                rs.b 0
;ENDFOLD
;FOLD MapNode properties
;*************************************************
;** MapNode properties                          **
;*************************************************
mapp_writeprotected     =       2       ;page is write protected
mapp_cacheinhibit       =       6       ;cache inhibit (if on, bit 5 is precise or imprecise exception)
mapp_supervisoronly     =       7       ;page is supervisor code only

mapp_userpage0          =       8       ;user page attributes 0
mapp_userpage1          =       9       ;user page attributes 1
mapp_shared             =       10      ;shares the table of the global NULL context
mapp_blank              =       11      ;there's no memory at this space. Must be tolerated.
mapp_copyback           =       13      ;copyback mode allowed (only if cachable, '040, '060)
mapp_invalid            =       14      ;access of this page causes a segmentation fault
mapp_indirect           =       15      ;the physical memory is elsewhere. Use the userptr
mapp_swapped            =       16      ;access of this page causes a swapper exception
mapp_rom                =       17      ;ROM. Write access quietly tolerated.
mapp_imprecise          =       21      ;imprecise exception mode (only if non-cacheable, '060)
mapp_nonserialized      =       29      ;nonserialized access allowed (only if noncacheable, '040)
;ENDFOLD
;FOLD MapNode flags
mapf_dirty              =       31      ;this map has not been translated to the MMU yet
;ENDFOLD


