/*************************************************************************
 ** 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                                         **
 *************************************************************************/

#ifndef MMU_CONTEXT_H
#define MMU_CONTEXT_H

#ifndef EXEC_LISTS_H
#include <exec/lists.h>
#endif

/* 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. */

struct Context {
        struct Context  *ctx_succ;      /* A doubly linked list */
        struct Context  *ctx_pred;
        /* private data here. Do not touch, modify, .... */     
};


/* A mapping node, used to define the address space. 
   This structure is stricly READ ONLY */
struct MappingNode {
        struct MappingNode     *map_succ;
        struct MappingNode     *map_pred;
        
        void            *map_Lower;     /* lower address this node covers. */
        void            *map_Higher;    /* higher address, inclusive */
        void            *map_internal;  /* like it says. */
        ULONG            map_Flags;     /* internal use only. */
        ULONG            map_Properties;        /* see below for definitions */
        union {
                void    *map_UserData;  /* your data if this is invalid or swapped */
                ULONG    map_Delta;     /* added to the logical address if indirect */
        }                map_un;
};

/* Property types */

#define MAPP_WRITEPROTECTED     (1<<2L)
/* region is write protected */

#define MAPP_CACHEINHIBIT       (1<<6L)
/* region is inhibited */

#define MAPP_SUPERVISORONLY     (1<<7L)
/* supervisor access only */

#define MAPP_USERPAGE0		(1<<8L)
/* user page attribute 0, used only by 68040, 68060.
   These bits are available at special pins of the CPU,
   special hardware might require this. */

#define MAPP_USERPAGE1		(1<<9L)
/* user page attribute 1 */

#define MAPP_SHARED             (1<<10L)
/* this memory region has the same properties as the default context */

#define MAPP_BLANK              (1<<11L)
/* there's no memory here. If accessed, either an enforcer hit is 
   generated or the access is quietly tolerated, even though
   nothing useful should be expected. */

#define MAPP_COPYBACK           (1<<13L)
/* MC68040 or MC68060 advanced copyback mode enabled. */

#define MAPP_INVALID            (1<<14L)
/* page is invalid. Accessing it results in a bus error. 
   UserData is available for private data. */

#define MAPP_INDIRECT           (1<<15L)
/* page is redirected to a different memory region */

#define MAPP_SWAPPED            (1<<16L)
/* this page is currently swapped out. If a program accesses this, a 
   segmentation fault is generated. UserData is available for a swapper 
   daemon, usually the memory.library. */

#define MAPP_ROM		(1<<17L)
/* this is read-only memory, but we tolerate write accesses quietly. */

#define MAPP_TRANSLATED		(1<<18L)
/* this memory region is - probably partially - under control of the 
   transparent translation registers and should not be touched. */

#define MAPP_IMPRECISE          (1<<21L)
/* if non-cacheable, allow imprecise exception mode */

#define MAPP_NONSERIALIZED      (1<<29L)
/* if non-cacheable, allow non-serialized access */

#endif
