home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 4 / AACD04.ISO / AACD / Programming / MMULib / Autodocs / mmu.doc < prev   
Encoding:
Text File  |  1999-08-28  |  112.2 KB  |  3,441 lines

  1. TABLE OF CONTENTS
  2.  
  3. mmu.library/--Background--
  4. mmu.library/--Patches--
  5. mmu.library/CreateMMUContext
  6. mmu.library/DeleteMMUContext
  7. mmu.library/EnterMMUContext
  8. mmu.library/LeaveMMUContext
  9. mmu.library/CurrentContext
  10. mmu.library/AddContextHook
  11. mmu.library/RemContextHook
  12. mmu.library/AddMessageHook
  13. mmu.library/RemMessageHook
  14. mmu.library/ActivateException
  15. mmu.library/DeactivateException
  16. mmu.library/GetPageSize    
  17. mmu.library/RemapSize
  18. mmu.library/SetPropertiesA
  19. mmu.library/SetPagePropertiesA
  20. mmu.library/RebuildTree
  21. mmu.library/GetPropertiesA
  22. mmu.library/GetPagePropertiesA
  23. mmu.library/AllocAligned
  24. mmu.library/LockMMUContext
  25. mmu.library/UnlockMMUContext
  26. mmu.library/AttemptLockMMUContext
  27. mmu.library/LockContextList
  28. mmu.library/UnlockContextList
  29. mmu.library/AttemptLockContextList
  30. mmu.library/AllocLineVec
  31. mmu.library/PhysicalPageLocation
  32. mmu.library/PhysicalLocation
  33. mmu.library/DMAInitiate
  34. mmu.library/DMATerminate
  35. mmu.library/GetMapping
  36. mmu.library/ReleaseMapping
  37. mmu.library/NewMapping
  38. mmu.library/CopyMapping
  39. mmu.library/DupMapping
  40. mmu.library/CopyContextRegion
  41. mmu.library/SetPropertiesMapping
  42. mmu.library/SetMappingPropertiesA
  43. mmu.library/GetMappingPropertiesA
  44. mmu.library/SetPropertyList
  45. mmu.library/GetMMUType
  46. mmu.library/SuperContext
  47. mmu.library/DefaultContext
  48. mmu.library/WithoutMMU
  49. mmu.library/SetBusError
  50. mmu.library/GetMMUContextData
  51. mmu.library/SetMMUContextDataA
  52. mmu.library/BuildIndirect
  53. mmu.library/SetIndirect
  54. mmu.library/GetIndirect
  55.  
  56. mmu.library/--Background--                            mmu.library/--Background--
  57.  
  58.     PURPOSE
  59.         The mmu.library provides functions for MMU related operations
  60.         as write- or read-protecting certain areas of memory for a
  61.         given set of tasks, or marking memory regions as "swapped"
  62.         virtual memory support. It offers an abstraction level on top
  63.         of the actual MMU and a unified interface for MMU purposes.
  64.  
  65.         The MMU lib does NOT implement virtual memory, that's the purpose
  66.         of another library - the memory.library. There's no much reason why
  67.         any application except the memory.library and probably some debugging
  68.         tools should call this library directly. The memory.library functions
  69.         on top of this library should suffer for "all day purposes".
  70.  
  71.         The basic object administrated by this library is the "context". A
  72.         "context" is the software abstraction of a MMU translation tree, it
  73.         keeps the information of the status of memory. The mmu.library 
  74.         provides a "global" context that represents the MMU translation tree
  75.         for all tasks. It is build by the init code of the library either by
  76.         snooping the already existing MMU translation tree or by building an
  77.         own tree by looking at the available memory and expansion devices.
  78.  
  79.         Programs can build own contexts by using the MMU library functions and
  80.         may enter or leave the contexts generated in this way. Several tasks
  81.         may share one context, as they represent, for example, multiple 
  82.         "threads" of one single program. Thus, the notation used here is some-
  83.         how turned around: A "context" in the amiga world is called "process"
  84.         in unix, and a "task" or "process" in the amiga world is called a
  85.         "thread" usually.
  86.  
  87.         Tasks that do not enter an own context explicitly share the common
  88.         global context. Even though it is possible to change the global 
  89.         context, this technique should be used only by debugging tools as the
  90.         enforcer. It could, for example, mark unused areas of the memory as
  91.         well as the first 4K as "invalid".
  92.  
  93.         The MMU library provides two "hooks" for each context, the 
  94.         "bus error hook" and the "segmentation fault" hook. The first hook
  95.         is called if an access to an invalid memory location is detected, or
  96.         a write to a read-only memory area. The second is called if an access
  97.         to a memory page marked as "swapped out" is detected. It's part of
  98.         the service of the MMU library to keep these two access violations
  99.         apart.
  100.  
  101.         The default hooks call simply the exception handler of the running
  102.         task, which generates by default the well known "guru". It's up to
  103.         programs on top of the MMU library to setup useful hooks. An enforcer
  104.         like tool might set "bus error hook" to print some useful information
  105.         about the access violation, the memory.library will set the 
  106.         "segmentation fault" hook to swap in the memory in question.
  107.  
  108.         The hooks are really "low-level" routines and are executed in super-
  109.         visor mode, and therefore very limited in power.
  110.  
  111.         The library provides itself a ready-for-use hook function which
  112.         sends a message to a task to be specified and suspends the task
  113.         that caused the bus error until the message is replied.
  114.  
  115.         MMU trees are managed on two levels, a "software abstraction level"
  116.         which is comfortable and easy to use. Memory "properties" of large
  117.         regions of memory can be redefined quite easely with one single
  118.         call, but rebuilding the MMU table tree from this abstraction layer
  119.         is a lengthly operation and requires quite a lot of CPU power
  120.         not available in critical applications.
  121.         Therefore, a more "hardware based" approach is available which
  122.         modifies the existing MMU table "on the fly" and is therefore
  123.         rather fast. However, memory pages to be handled like this must
  124.         be marked with the MAPP_SINGLE property to tell the library to
  125.         build the MMU table in a special way to allow fast modification
  126.         and to bypass some possible optimizations (e.g. "early page
  127.         terminators" and "invalid descriptors not at page level").
  128.         Modifications on this level are never seen by the abstraction
  129.         level above and should be used only once the MMU tree is complete.
  130.  
  131.         If that is, too, not fast enough, the MMU library allows building
  132.         pages using "indirect descriptors". That is, the page property
  133.         flags are given by a true hardware descriptor you provide. This
  134.         makes code CPU specific, obviously, but has the advantage that
  135.         page properties can be modified by a single long word "poke" in
  136.         your program, and the proper ATC flush. This is almost "hardware
  137.         banging", with some support.
  138.  
  139.         This method has one important drawback, namely that the library
  140.         is no longer able to disable caching for DMA transfer to and from
  141.         this page. Hence, NEVER EVER access an indirect page by DMA.
  142.  
  143. mmu.library/--Patches--                                mmu.library/--Patches--
  144.  
  145.         To perform its job, the mmu.library has to install a number of 
  146.         system patches. I tried avoid this as best as possible, but some
  147.         installations have to be done.
  148.  
  149.         The following patches are installed:
  150.  
  151.  
  152. exec/CacheControl:        Replaced partially by a function that guarantees
  153.                         that the data cache remains off when the mmu.library
  154.                         builds descriptors.
  155.  
  156. exec/ColdReboot:        Replaced partially by a function that removes the
  157.                         mmu.library installed MMU trees. This is done to
  158.                         restart the processor with a clean MMU setup.
  159.  
  160. exec/Alert:                Replaced partially. The Alert() replacement routine
  161.                         will check whether the alert caused is fatal or not,
  162.                         and will Disable() and unload the mmu.library 
  163.                         installed MMU tree if this is the case. Since a
  164.                         deadend alert will go over into a reset without
  165.                         calling ColdReboot(), this must be done here 
  166.                         separately to ensure that the machine restarts
  167.                         properly.
  168.  
  169. exec/AddMem:            Adding memory with a MMU setup active would or would
  170.                         not mean that the MMU table must be adjusted to
  171.                         reflect the changes. This function should not be
  172.                         called once the system is setup and running.
  173.                         It is here patched to an Alert(). 
  174.                         The original routine is not called because some
  175.                         68040/68060 libraries modify the MMU table on their 
  176.                         own in case this happens.
  177.                         I don't think this routine is really required unless
  178.                         on startup, but in case it is I will replace it
  179.                         completely on demand.
  180.  
  181. exec/AddConfigDev:        Patched to an Alert() for just the same reason than
  182.                         above.
  183.  
  184. exec/CachePreDMA:        Replaced completely by a MMU library routine that
  185.                         disables copyback mode for non-aligned pages and
  186.                         translates the logical address passed in to the
  187.                         physical address, by means of the mmu.library 
  188.                         public context.
  189.  
  190. exec/CachePostDMA:        Ditto. Replaced completely by the MMU.library.
  191.  
  192.         
  193.  
  194. mmu.library/CreateMMUContext                        mmu.library/CreateContext                        mmu.library/CreateMMUContext
  195.  
  196.     NAME
  197.         CreateMMUContext - Build a new MMU context.
  198.  
  199.     SYNOPSIS
  200.         context = CreateMMUContextA ( tags );
  201.         d0                              a0
  202.  
  203.         context = CreateMMUContext ( tag1, ... ); 
  204.  
  205.  
  206.         struct MMUContext * CreateMMUContextA ( struct TagItem *);
  207.  
  208.         struct MMUContext * CreateMMUContext ( Tag tag1, ... );
  209.         
  210.     FUNCTION
  211.         This function builds a new MMU context.
  212.  
  213.         The context created will be a copy of the global context, with
  214.         all memory regions marked in the same way and the same hooks
  215.         installed.
  216.  
  217.     INPUTS
  218.         tags    -    Tag items for the context to be created. 
  219.  
  220.         Currently defined tags are:
  221.  
  222.  
  223.         MCXTAG_COPY        -    build a copy of the context * passed in,
  224.                             if the pointer is NULL, build a copy of
  225.                             the global default context.
  226.  
  227.                             If this tag item is not given, all context
  228.                             addresses will be marked as MAPP_BLANK. Most
  229.                             likely not what you want.
  230.  
  231.                             If you specify a different table size than that
  232.                             of the context you want to clone you should
  233.                             specify the MCXTAG_ERRORCODE as well and study
  234.                             the return code carefully. The mmu library might
  235.                             have performed some rounding to fit the old
  236.                             table specifications into the new table layout.
  237.                             In worst case, this will make your new table
  238.                             unusable. It is therefore in general not a good
  239.                             idea to specify a page size larger than that of
  240.                             the cloned context. Even though the library 
  241.                             itself allocates all its internal structures
  242.                             aligned to "worst case" page sizes, this might
  243.                             not be true for external user programs.
  244.                             
  245.         MCXTAG_EXECBASE    -    allow accesses of AbsExecBase and all accesses
  246.                             except for the first KByte, even if the first
  247.                             page in the MMU tree - the "zeropage" - is
  248.                             marked as invalid. This is an important feature
  249.                             if the mmu.library is used to implement an
  250.                             Enforcer type program. 
  251.                             Accesses will be emulated in software and are
  252.                             hence *slow*. They should be avoided.
  253.                             AbsExecBase accesses are handled with highest
  254.                             priority first and might be faster, even though
  255.                             they're still slower than "the real thing".
  256.                             It is not guaranteed that the library will really
  257.                             read AbsExecBase from location four, dependent on
  258.                             some internals, it might give you a cached copy
  259.                             instead. This means usually no problem since
  260.                             AbsExecBase must not change while the machine is
  261.                             up and running. 
  262.  
  263.                             This option defaults to TRUE.
  264.  
  265.                             For more quirks about the zeropage, read the
  266.                             MCXTAG_ZEROBASE tag documentation below.
  267.  
  268.         MCXTAG_BLANKFILL -    defines a ULONG word fill value for blank
  269.                             memory regions.
  270.                     
  271.                             This ULONG is read by the CPU in case a program
  272.                             tries an access to "empty" memory regions. It
  273.                             defaults to 0L, but other values might be use-
  274.                             ful for debugging.
  275.  
  276.         MCXTAG_MEMORYATTRS-    An exec memory attributes specifier to be used
  277.                             for allocating memory for the (hardware) MMU
  278.                             tables. Defaults to MEMF_PUBLIC, check 
  279.                             exec/memory.h for other possibilities.
  280.  
  281.         MCXTAG_PRIVATESUPER    A boolean value, either TRUE or FALSE. If TRUE,
  282.                             build a private MMU supervisor table for this
  283.                             context, independent of the global supervisor
  284.                             table. BE WARNED! This means specifically that
  285.                             possible modifications of the global supervisor
  286.                             context will not be carried on your private
  287.                             supervisor table.
  288.                             Even if you pass in FALSE here, the library might
  289.                             still ignore your choice and build a private
  290.                             supervisor table anyways. This happens if the
  291.                             table layout you've chosen is different to the
  292.                             default table layout, making the user tree in-
  293.                             compatible to the default supervisor tree.
  294.                             
  295.         MCXTAG_ZEROBASE        This option takes only effect if MCXTAG_EXECBASE
  296.                             is TRUE and the first page of the MMU table build
  297.                             by you is invalid. This means that the MMU
  298.                             library will emulate accesses to all addresses
  299.                             in the first page up to the first KByte which
  300.                             remains unavailable to implement an "Enforcer"
  301.                             function. This tag provides a base address to
  302.                             which page these accesses have to be redirected.
  303.                             This tag defaults to NULL meaning that the 
  304.                             library will redirect accesses to the true 
  305.                             zeropage, making it available temporarely, but
  306.                             any other memory location - provided it is page 
  307.                             aligned - can be specified here as well. This
  308.                             is important if the zero page gets remapped to
  309.                             a different location, and an Enforcer type 
  310.                             program is run later on. The zero page remapper
  311.                             should specify this tag to redirect accesses 
  312.                             transparently, even if an Enforcer type 
  313.                             application invalidates the zero page. Failing
  314.                             to do so would make the MMU library emulating
  315.                             the access to the incorrect, non-remapped memory 
  316.                             location. Since other programs might want to
  317.                             build a private MMU table with a different
  318.                             table size, it is *NOT* enough to align the
  319.                             remap destination of the zeropage to GetPageSize()
  320.                             boundaries, RemapSize() alignment is required!
  321.                             THIS IS AN ADVANCED FEATURE.
  322.  
  323.         The next tag items define the MMU table layout. A logical address,
  324.         used as input for the MMU, consists of exactly 32 bits. These
  325.         bits are now split from the left to the right into groups to define
  326.         a "path" in the MMU tree. Each "level" of the MMU tree should be
  327.         considered as an array of pointers, pointing to the next lower
  328.         level of the tree. The nodes of the tree are contain the descriptors
  329.         that define how the address belonging to the path from the root to
  330.         this descriptor should be handled. For example, consider a three-
  331.         level tree with 7 bits for level A and B, 6 bits for level C and
  332.         12 bits for the page. The address 0x01feabcd would be used like this
  333.         to find an descriptor:
  334.  
  335.         hex 0x01feabcd is binary
  336.     
  337.         ----7--- ----7---- ---6--- ------12-------  bits 
  338.         0000 000|1 1111 11|10 1010| 1011 1100 1101
  339.         \_______/\________/\______/\_____________/
  340.             |         |          |              |
  341.             |         |          |              |
  342.             V         |          |              |
  343.         Index into level A of the MMU tree is 0, hence the first pointer
  344.         is read. The MMU obtains now another array of pointers, called
  345.         the level B. |          |              |
  346.                      |          |              |
  347.                      V          |              |
  348.                 Index into level B of the MMU tree is 127. The MMU uses
  349.                 the last pointer from the table obtained in the previous
  350.                 step.          |              |
  351.                               |              |
  352.                               V              |
  353.                         Index into level C of the MMU tree is 42. The MMU
  354.                         uses, hence, the 42nd pointer of the array pointed
  355.                         to by the 127th pointer of the level B array. This
  356.                         is now the "page descriptor", defining the base
  357.                         address for the next step.
  358.                                           |
  359.                                           |
  360.                                           V
  361.         This is now finally the page offset, 0xbcd in this example. It
  362.         is added to the base address from the page descriptor in level C.
  363.         If the address is not "remapped", the base address would be
  364.         identically to the first 32-12 = 20 bits of the physically address.
  365.         
  366.  
  367.         MCXTAG_DEPTH    -    Depth of the MMU tree to build. Defaults to
  368.                             the depth of the global public context.
  369.  
  370.                             Legal values are 1..4 for the 68020/68851 and
  371.                             the 68030, but the 68040/68060 supports only
  372.                             trees of depth 3.
  373.  
  374.         MCXTAG_LEVELABITS -    Number of bits of the logical address that make
  375.                             up the level A of the MMU tree. 2^bits is the
  376.                             number of entries on this level of the tree.
  377.  
  378.                             The 68020/68851 and the 68030 support here
  379.                             values from 1..15, the only legal value for
  380.                             the 68040 and 68060 is 7. 
  381.  
  382.                             The MMU library will pick a reasonable and
  383.                             system dependent default for you if you don't
  384.                             specify this tag item.
  385.  
  386.         MCXTAG_LEVELBBITS -    Number of bits for the level B of the MMU tree,
  387.                             unused if the depth is smaller than two.
  388.  
  389.                             Legal values are 1..15 for the 851 and 030, and
  390.                             7 as only possible value for the 040 and 060.
  391.  
  392.         MCXTAG_LEVELCBITS - Number of bits of the level C of the MMU tree,
  393.                             unused if the depth is smaller than three.
  394.  
  395.                             Arguments may range from 1..15 for the 851 and
  396.                             030, and must be either 5 or 6 for the 040 and
  397.                             060.
  398.  
  399.         MCXTAG_LEVELDBITS -    Number of bits in the level D of the MMU tree,
  400.                             only used if the depth is four and therefore
  401.                             unused on the 040 and 060. 
  402.  
  403.                             Must range from 1..15.
  404.  
  405.         MCXTAG_PAGEBITS -    Number of bits to be used from the logical
  406.                             address as the page offset. 2^bits is the
  407.                             page size. 
  408.  
  409.                             Legal values are 8..15, giving 256 bytes up
  410.                             to 32K pages for the 68020/68851 and 68030, or
  411.                             12..13 defining 4K resp. 8K pages for the
  412.                             68040 and 68060. 
  413.  
  414.                             The default is the page size of the global 
  415.                             context.
  416.  
  417.         All the "..."BITS specifications MUST sum up to 32 since a logical
  418.         address consists of exactly 32 bits. You may leave out some or all 
  419.         of these tags, the MMU library will keep care of the rest and will
  420.         chose reasonable defaults for you.
  421.  
  422.  
  423.         MCXTAG_ERRORCODE -    pointer to a ULONG the MMU library will fill
  424.                             in with an error code in case building the
  425.                             MMU tree failed. It will be set to 0L if the
  426.                             function succeeds. The following error codes
  427.                             have been defined:
  428.  
  429.             CCERR_NO_FREE_STORE -        the library went out of memory.
  430.             CCERR_INVALID_PARAMETERS -    the parameters specified by the 
  431.                                         tags are invalid.
  432.             CCERR_UNSUPPORTED -         the parameters are valid, but 
  433.                                         not supported by the hardware.
  434.             CCERR_TRIMMED      -            the library performed some minor
  435.                                         adjustments on the MMU table passed
  436.                                         in for cloning. The cache modes
  437.                                         might not be optimal due to some
  438.                                         roudings that have to be performed,
  439.                                         but the MMU table should work in
  440.                                         general.
  441.  
  442.                                         THIS IS NOT AN ERROR, you will get
  443.                                         your new context.
  444.  
  445.             CCERR_UNALIGNED      -            the library had to perform heavy
  446.                                         rouding in the MMU table passed
  447.                                         in, it might be unusable. For 
  448.                                         example, remapped pages were mis-
  449.                                         aligned and due to the rounding
  450.                                         accesses might go to wrong 
  451.                                         locations. If you get this return
  452.                                         code, you should possibly deallocate
  453.                                         the new context and inform the user
  454.                                         that the request could not be satis-
  455.                                         fied.
  456.  
  457.                                         Still, THIS IS NOT AN ERROR. You
  458.                                         get a new context, but possibly an
  459.                                         usuable one.
  460.  
  461.     RETURNS
  462.         NULL if the new context couldn't be created or a handle to the
  463.         new context, as parameter to all MMU library functions.
  464.  
  465.     NOTES
  466.         This call makes NOT the current task entering the new context,
  467.         you've to call EnterMMUContext() explicitly for that purpose.
  468.  
  469.         The context structure is not documented intentionally. It depends
  470.         on the implementation.
  471.  
  472.     BUGS
  473.  
  474.     SEE ALSO
  475.         DeleteMMUContext()
  476.  
  477.     BUGS
  478.  
  479. mmu.library/DeleteMMUContext                    mmu.library/DeleteMMUContext
  480.     
  481.     NAME
  482.         DeleteMMUContext - delete an MMU context build with CreateMMUContext.
  483.  
  484.     SYNOPSIS
  485.         DeleteMMUContext ( context );
  486.                             a0
  487.  
  488.         void DeleteMMUContext ( struct MMUContext * );
  489.  
  490.     FUNCTION
  491.         This function deletes a context build with CreateMMUContext().
  492.  
  493.  
  494.     INPUTS     
  495.         A handle to the context to be deleted.
  496.  
  497.     RETURNS
  498.         nothing.
  499.  
  500.     NOTES
  501.         This call doesn't remove any task from the context, especially the
  502.         current task is NOT removed from the context. You've to call
  503.         LeaveMMUContext() before.
  504.  
  505.         Deleting a context with some tasks still in this context will
  506.         cause this function to guru.
  507.  
  508.         If your context was created with a private supervisor context
  509.         included, you must call this function only *once*, with the
  510.         user context created. It will automatically deallocate the
  511.         attached supervisor context as well.
  512.  
  513.     BUGS
  514.  
  515.     SEE ALSO
  516.         CreateMMUContext()
  517.  
  518. mmu.library/EnterMMUContext                        mmu.library/EnterMMUContext
  519.  
  520.     NAME
  521.         EnterMMUContext - let a task enter a specific context.
  522.  
  523.     SYNOPSIS
  524.         context = EnterMMUContext( context , task );
  525.         d0                               a0         a1
  526.  
  527.         struct MMUContext * EnterMMUContext( struct MMUContext * , 
  528.                     
  529.                                     struct Task * );
  530.  
  531.     FUNCTION
  532.         Add a given task to a context. This makes the MMU settings defined
  533.         by the context available for the task in question.
  534.  
  535.     INPUTS
  536.         context - the context to enter or NULL for the global context.
  537.         task    - a pointer to the task structure that should enter the
  538.                   context.
  539.  
  540.     RETURNS
  541.         a handle to the context the task participated before or NULL if
  542.         this function failed. The task will stay in the last context used
  543.         in this case.
  544.  
  545.     NOTES
  546.         This call uses the tc_Switch() and tc_Launch() functions of the
  547.         task structure. What basically happens here is that these functions
  548.         are set to internal procedures that swap the context specific
  549.         MMU table or the global MMU in and flush the ATC of the MMU.
  550.  
  551.         This call may fail, check the return code for NULL - either due to
  552.         lack of memory or because the task is part of a protected context
  553.         the current task hasn't entered.
  554.  
  555.         If you want to use the tc_Switch() and tc_Launch() functions your-
  556.         self, you should install a task specific context hook, see 
  557.         AddContextHook().
  558.  
  559.         This function can be used to change the context of a task by
  560.         adding it to a new context. The task specific context switch and
  561.         launch hooks will be "carried over" to the new context, but all
  562.         other MMU specific exceptions are now the matter of the new context.
  563.  
  564.     BUGS
  565.  
  566.     SEE ALSO
  567.         LeaveMMUContext(),ProtectMMUContext(), exec/tasks.h
  568.  
  569. mmu.library/LeaveMMUContext                        mmu.library/LeaveMMUContext
  570.     
  571.     NAME
  572.         LeaveMMUContext - remove a given task from a context.
  573.  
  574.     SYNOPSIS
  575.         context = LeaveMMUContext( task );
  576.         d0                        a1
  577.  
  578.         struct MMUContext * LeaveMMUContext( struct Task *);
  579.  
  580.     FUNCTION
  581.         The specified task leaves its context and enters the global context.
  582.  
  583.     INPUTS
  584.         task - the task that should leave a private context and enter the
  585.             global default context.
  586.  
  587.     RETURNS
  588.         the context the task was added to or NULL on failure.
  589.         Might be the global default context if the task did not enter any 
  590.         context.
  591.  
  592.     NOTES
  593.         It is safe to call this function even if the task wasn't added to
  594.         any context. The function returns the global context in this case.
  595.  
  596.         This function must be called to any task participating a given
  597.         context to be able to delete that context.
  598.  
  599.         This function is equivalent to EnterMMUContext(NULL,task). 
  600.  
  601.         This function makes use of the tc_Switch() and tc_Launch() functions
  602.         of the task structure to be able to set the MMU root pointer.
  603.  
  604.         Make sure that you check for failure. This call may return NULL if
  605.         the task entered a protected context the current task does not
  606.         participate or if switch and launch exceptions are in use.
  607.  
  608.     BUGS
  609.  
  610.     SEE ALSO
  611.         EnterMMUContext(), DeleteMMUContext(), ProtectMMUContext(), 
  612.         RemContextHook(), exec/tasks.h
  613.  
  614. mmu.library/CurrentContext                            mmu.library/CurrentContext
  615.  
  616.     NAME
  617.         CurrentContext - find out the current context of a task.
  618.  
  619.     SYNOPSIS
  620.         context = CurrentMMUContext( task );
  621.         d0                          a1
  622.  
  623.         struct MMUContext * CurrentMMUContext( struct Task * );
  624.  
  625.     FUNCTION
  626.         This function is used to get a handle to the context the given
  627.         task is added to, or to return the context of the calling task.
  628.  
  629.     INPUTS
  630.         task - the address of the task structure you like to investigate
  631.         or NULL to get a handle to the currently active context.
  632.  
  633.     RETURNS
  634.         a handle to the context the given task is added to, the global
  635.         context if the task is not attached to any context or the
  636.         currently active context if the argument is NULL. 
  637.  
  638.     NOTES
  639.         This call fails only if the given task is part of a protected
  640.         context which is not shared by the current task. The NULL
  641.         argument is always safe.
  642.  
  643.     BUGS
  644.         Protected contexts are not yet implemented.
  645.  
  646.     SEE ALSO
  647.         ProtectMMUContext(), FindTask()
  648.  
  649. mmu.library/AddContextHook                            mmu.library/AddContextHook
  650.  
  651.     NAME
  652.         AddContextHook - set an exception handler to a Context
  653.  
  654.     SYNOPSIS
  655.         hook = AddContextHookA ( tags );
  656.                                   a0
  657.  
  658.         hook = AddContextHook ( tag1, ... );
  659.  
  660.         
  661.         struct ExceptionHook * AddContextHookA ( struct TagItem * );
  662.  
  663.         struct ExceptionHook * AddContextHook ( Tag tag1, ... );
  664.  
  665.     FUNCTION
  666.         This call installs an exception hook for a given context for
  667.         various exception types the MMU library can provide.
  668.  
  669.     INPUTS
  670.         tags     -    A taglist defining the type of the exception hook
  671.                     to be added.
  672.  
  673.         Currently defined are:
  674.  
  675.         MADTAG_CONTEXT        -    The context to which this exception hook
  676.                                 should be added. This MUST be given for
  677.                                 "swapped" handlers. If it is left blank
  678.                                 or set to NULL for segmentation fault
  679.                                 handlers, you define a global segmentation
  680.                                 fault handler.
  681.  
  682.         MADTAG_TASK            -    If the hook should be called only if a
  683.                                 specific task is running, specify a pointer
  684.                                 to the task structure here. 
  685.                                 Warning! Adding too many task specific
  686.                                 hooks slows things down unnecessary.
  687.                                 Remember that a MMU Context may hold more
  688.                                 than one task.
  689.                                 This MUST be given for the switch and launch
  690.                                 hooks.
  691.  
  692.         MADTAG_TYPE            -    Type of the exception hook to build. The
  693.                                 following types are available:
  694.  
  695.             MMUEH_SEGFAULT    -    Called on segmentation fault, i.e. write to
  696.                                 a write protected page or access of an
  697.                                 invalid page. Most useful for "Enforcer"
  698.                                 like tools.
  699.  
  700.             MMUEH_SWAPPED    -    Called on access for a "swapped out" page.
  701.                                 Most useful to implement virtual memory.
  702.  
  703.             MMUEH_SWITCH    -    Called when the task looses the CPU.
  704.             MMUEH_LAUNCH    -    Called when the task gains the CPU.
  705.                                 Remember that the tc_Switch() and tc_Launch()
  706.                                 function pointers are no longer available
  707.                                 if the task has been added to a MMUContext.
  708.  
  709.             MMUEH_PAGEACCESS -    Called whenever a MAPP_SINGLE page gets
  710.                                 build by the context. This could be used to
  711.                                 modify the MMU tree "on the fly" if 
  712.                                 necessary, the required parameters are passed
  713.                                 thru.
  714.  
  715.         MADTAG_CODE            -    A function pointer to the code to be called.
  716.                                 This should be an assembly language function.
  717.                                 It is called like this:
  718.  
  719.         Register a0            -    Pointer to the ExceptionData structure or
  720.                                 the PageAccessData.
  721.         Register a1            -    loaded with the MADTAG_DATA provided data.
  722.         Register a4            -    Ditto.
  723.         Register a5            -    Pointer to the code itself.
  724.         Register a6            -    MMUBase. NOT A SCRATCH.
  725.  
  726.         Registers d0-d1/a0-a1/a4-a5 are scratches and are available for the
  727.         Exception handler. You *MUST* set the "Z" condition code and
  728.         clear d0 on exit in case you handled the exception. Details on
  729.         how to write an exception handler are in the "Exception.doc" file.
  730.  
  731.         MADTAG_DATA            -    Data to be loaded for the hook function.
  732.         MADTAG_NAME            -    A name for the hook. Currently unused.
  733.         MADTAG_PRI            -    A priority, ranging from -128...+127.
  734.                                 Hooks of higher priorities are called first.
  735.  
  736.     RESULTS
  737.         A handle to the exception hook. Do not interpret this handle.
  738.         Or NULL on failure.
  739.  
  740.     NOTES
  741.         this call will be used by the high-level function AddMessageHook().
  742.         The global segmentation fault hook may be set by a debugging tool 
  743.         like the enforcer.
  744.  
  745.         The exception will not be activated, you need to call 
  746.         ActivateException() explicitly to make the library call it.
  747.  
  748.         Much more needs to be said about this function, see Exception.doc
  749.         for details about the exception handlers.
  750.  
  751.     BUGS
  752.  
  753.     SEE ALSO
  754.         RemContextHook(), AddMessageHook(), ActivateException(),
  755.         exec/interrupts.h, Exception.doc
  756.  
  757. mmu.library/RemContextHook                            mmu.library/RemContextHook
  758.  
  759.     NAME
  760.         RemContextHook - remove an exception handler from a Context
  761.  
  762.     SYNOPSIS
  763.         RemContextHook( hook )
  764.                          a1
  765.  
  766.         void RemContextHook( struct ExceptionHook * );
  767.  
  768.     FUNCTION
  769.         This function removes a previously installed context hook
  770.         from the hook list.
  771.  
  772.     INPUTS
  773.         The handle of the hook, as obtained by AddContextHook().
  774.  
  775.     RESULTS
  776.         none.
  777.  
  778.     NOTES
  779.         You must call DeactivateException() on your hook before you
  780.         remove it.
  781.         Be aware that the library will call the exec exception handler,
  782.         i.e. will generate a guru in case no exception handler is
  783.         available.
  784.  
  785.     SEE ALSO
  786.         AddContextHook(), DeactivateException(), exec/interrupts.h
  787. mmu.library/AddMessageHook                            mmu.library/AddMessageHook
  788.  
  789.     NAME
  790.         AddMessageHook - install a high-level hook function.
  791.  
  792.     SYNOPSIS
  793.         hook = AddMessageHookA ( tags );
  794.                                   a0
  795.  
  796.         hook = AddMessageHook ( tag1, ... );
  797.  
  798.  
  799.         struct ExceptionHook * AddMessageHookA ( struct TagItem * );
  800.  
  801.         struct ExceptionHook * AddMessageHook ( Tag tag1, ... );
  802.  
  803.     FUNCTION
  804.         Installs a high-level hook of the tag-given properties.
  805.         As soon as an exception of the requested type occurs, an exception 
  806.         message (see below) will be sent to the port. The task that caused 
  807.         the exception will be halted until the message gets replied.
  808.         BE WARNED: Message hooks perform only operation if task switching
  809.         is enabled and interrupts are allowed and the code failed in
  810.         User mode. They will just "drop thru" to the next handler if this 
  811.         is not the case.
  812.  
  813.     INPUTS
  814.         tags     -    A taglist defining the type of the exception hook
  815.                     to be added.
  816.  
  817.         Currently defined are:
  818.  
  819.         MADTAG_CONTEXT        -    The context to which this exception hook
  820.                                 should be added. This MUST be given.
  821.  
  822.         MADTAG_TASK            -    If the hook should be called only if a
  823.                                 specific task is running, specify a pointer
  824.                                 to the task structure here. 
  825.                                 Warning! Adding too many task specific
  826.                                 hooks slows things down unnecessary.
  827.                                 Remember that a MMU Context may hold more
  828.                                 than one task.
  829.                                 This MUST be given for the switch and launch
  830.                                 hooks.
  831.  
  832.         MADTAG_TYPE            -    Type of the exception hook to build. The
  833.                                 following types are available:
  834.  
  835.             MMUEH_SEGFAULT    -    Called on segmentation fault, i.e. write to
  836.                                 a write protected page or access of an
  837.                                 invalid page. Most useful for "Enforcer"
  838.                                 like tools.
  839.  
  840.             MMUEH_SWAPPED    -    Called on access for a "swapped out" page.
  841.                                 Most useful to implement virtual memory.
  842.  
  843.         MADTAG_CATCHERPORT    -    The port to sent the data to.
  844.         MADTAG_NAME            -    A name for the hook. Currently unused.
  845.         MADTAG_PRI            -    A priority, ranging from -128...+127.
  846.                                 Hooks of higher priorities are called first.
  847.  
  848.         On an exception, the following message will be sent to the port:
  849.  
  850.         struct ExceptionMessage {
  851.             struct Message            exm_msg;
  852.             struct ExceptionData     exm_Data;
  853.         };
  854.  
  855.         For details about the ExceptionData structure, see Exception.doc.
  856.  
  857.         Once the message gets replied, the faulted task is restarted.
  858.  
  859.     RESULTS
  860.         a handle for the exception that must be passed back to 
  861.         RemMessageHook() for removal or NULL on failure.
  862.         Do not interpret this handle.
  863.         
  864.     NOTES
  865.         The handler must have been added to a context with EnterMMUContext()
  866.         before this function can be used. Unlike the AddContextHook() 
  867.         function, this DOES NOT work for "plain" tasks without a context.
  868.  
  869.         The hook must be activated with ActivateException() before it 
  870.         gets called.
  871.  
  872.         This function is used by the memory.library to install its
  873.         exception handler. The port will be in this case the port of
  874.         the swapper daemon that loads swapped out pages from disk.
  875.  
  876.     BUGS
  877.         
  878.     SEE ALSO
  879.         AddContextHook(), RemContextHook(), RemMessageHook(), 
  880.         ActivateException(), Exception.doc
  881.  
  882. mmu.library/RemMessageHook                            mmu.library/RemMessageHook
  883.  
  884.     NAME
  885.         RemMessageHook    -    remove a high-level hook from a context.
  886.  
  887.     SYNOPSIS
  888.         RemMessageHook( handle );
  889.                          a1
  890.  
  891.         void RemMessageHook( struct ExceptionHook * );
  892.  
  893.  
  894.     FUNCTION
  895.         This function removed a previously installed Message hook from
  896.         the hook list of the context.
  897.  
  898.     INPUTS
  899.         handle - a handle to the message hook as returned by the 
  900.             AddMessageHook function.
  901.  
  902.     RESULTS
  903.         none.
  904.  
  905.     NOTES
  906.         To remove a message hook safely, deactivate it first with
  907.         DeactivateException(), then tell the daemon to reply all 
  908.         exceptions of this hook, then remove it. 
  909.  
  910.         Not following these rules may cause deadlocks.
  911.     
  912.     BUGS
  913.         
  914.     SEE ALSO
  915.         AddMessageHook(), AddContextHook(), RemContextHook(),
  916.         DeactivateException(), Exception.doc
  917.  
  918. mmu.library/ActivateException                    mmu.library/ActivateException
  919.  
  920.     NAME
  921.         ActivateException    -    enable an exception hook.
  922.  
  923.     SYNOPSIS
  924.         ActivateException( hook );
  925.                             a1
  926.  
  927.         void ActivateException( struct ExceptionHook * );
  928.  
  929.     FUNCTION
  930.         Activates a formerly installed exception hook, either a low
  931.         level context hook or a high-level message hook.
  932.     
  933.     RETURNS
  934.         
  935.     NOTES
  936.         Hooks of either kind must be activated before the mmu.library
  937.         will call them. Hooks are deactivated after creation and must
  938.         be deactivated before they get removed.
  939.         This call can be safely used within interrupts and from super-
  940.         visor mode.
  941.  
  942.     BUGS
  943.  
  944.     SEE ALSO
  945.         DeactivateException(), AddContextHook(), AddMessageHook(),
  946.         Exception.doc
  947.  
  948. mmu.library/DeactivateException                mmu.library/DeactivateException
  949.  
  950.     NAME
  951.         DeactivateException    -    enable an exception hook.
  952.  
  953.     SYNOPSIS
  954.         DeactivateException( hook );
  955.                             a1
  956.  
  957.         void DeactivateException( struct ExceptionHook * );
  958.  
  959.     FUNCTION
  960.         Deactivates a formerly installed exception hook, either a low
  961.         level context hook or a high-level message hook, i.e. disables
  962.         it from being called.
  963.     
  964.     RETURNS
  965.         
  966.     NOTES
  967.         Hooks of either kind must be activated before the mmu.library
  968.         will call them. Hooks are deactivated after creation and must
  969.         be deactivated before they get removed.
  970.         This call can be safely used within interrupts and from super-
  971.         visor mode.
  972.  
  973.     BUGS
  974.  
  975.     SEE ALSO
  976.         ActivateException(), RemContextHook(), RemMessageHook(),
  977.         Exception.doc
  978.  
  979. mmu.library/GetPageSize                                mmu.library/GetPageSize
  980.  
  981.     NAME
  982.         GetPageSize - return the page size of a context.
  983.  
  984.     SYNOPSIS
  985.         pagesz = GetPageSize( context );
  986.         d0                      a0
  987.  
  988.         ULONG GetPageSize( struct MMUContext * );
  989.  
  990.     FUNCTION
  991.         This function returns the page size selected by the MMU library for
  992.         the given context. Possible page sizes are limited by the hardware
  993.         and cannot be adjusted from the outside. The page size is set up
  994.         by the MMU library for the global public context, and it can be
  995.         selected from the available page sizes for private MMUContexts, see
  996.         CreateMMUContext().
  997.  
  998.     INPUTS
  999.         context - a handle to the context to be investigated or NULL for
  1000.             the active context.
  1001.  
  1002.     RESULTS
  1003.         the page size in bytes or zero for failure.
  1004.  
  1005.     NOTES
  1006.  
  1007.     BUGS
  1008.         Context protection is currently unsupported.
  1009.  
  1010.     SEE ALSO
  1011.         CreateMMUContext()
  1012.  
  1013. mmu.library/RemapSize                                mmu.library/RemapSize
  1014.  
  1015.     NAME
  1016.         RemapSize - return the block size for memory remapping.
  1017.  
  1018.     SYNOPSIS
  1019.         remapsize = RemapSize( context );
  1020.         d0                         a0
  1021.  
  1022.         ULONG RemapSize( struct MMUContext * );
  1023.  
  1024.     FUNCTION
  1025.         This function returns the smallest possible block size, and
  1026.         therefore the alignment restrictions, for remapping of memory that
  1027.         should be added to the exec memory pool. Since the MMU tables have
  1028.         to be placed in non-fragmented memory, certain alignment 
  1029.         restrictions for the memory blocks the MMU tables are placed in
  1030.         arise. 
  1031.         This harder aligment condition is only required for memory
  1032.         that is put into the exec free list, but as long as remapped
  1033.         memory is never returned from AllocMem, the page size is good 
  1034.         enough.
  1035.  
  1036.     INPUTS
  1037.         context - a handle to the context to be investigated or NULL for
  1038.             the active context.
  1039.  
  1040.     RESULTS
  1041.         the smallest admissable block size for memory returned by 
  1042.         AllocMem().
  1043.  
  1044.     NOTES
  1045.         The call will fail if the given context is protected, the result
  1046.         will be zero in this case.
  1047.  
  1048.         Even though the mmu.library does support memory remapping, this
  1049.         does not mean all other programs do. For example, remember that
  1050.         the inputs to the "MAPP_REMAPPED" pages is a physical page size,
  1051.         hence your program has to translate the logical address obtained
  1052.         by AllocMem() to a physical address at first. This can be done 
  1053.         with the PhysicalLocation() function.
  1054.         
  1055.         Additionally, DMA devices might or might not support memory
  1056.         remapping, just for the same reason: They require physical, not
  1057.         logical addresses. The MMU library provides a translation mechanism
  1058.         in form of the ChachePreDMA() and CachePostDMA() functions of
  1059.         ExecBase, but not all DMA device drivers call these functions
  1060.         properly. Certain patches might be made available for devices
  1061.         not following this rule.
  1062.  
  1063.     BUGS
  1064.         Adding remapped memory to the freelist is highly untested and
  1065.         not recommended because of the quirks of this mechanism.
  1066.  
  1067.     SEE ALSO
  1068.         PhysicalLocation(), GetPageSize(), exec/CachePreDMA(),
  1069.         DMAInitiate()
  1070.  
  1071. mmu.library/SetPropertiesA                        mmu.library/SetPropertiesA
  1072.  
  1073.     
  1074.     NAME
  1075.         SetPropertiesA - set memory attributes for a given logical range.
  1076.  
  1077.     SYNOPSIS
  1078.  
  1079.         result = SetPropertiesA( context, flags, mask, lower, size, tags);
  1080.         d0                         a0          d1     d2    a1        d0      a2
  1081.  
  1082.         BOOL SetPropertiesA( struct MMUContext *, ULONG, ULONG, ULONG, ULONG,
  1083.                              struct TagItem *);
  1084.  
  1085.  
  1086.         result = SetProperties( context, flags, mask, lower, size, tag1, ...);
  1087.  
  1088.         BOOL SetProperties( struct MMUContext *, ULONG, ULONG, ULONG, ULONG,
  1089.                             Tag tag1, ...);
  1090.  
  1091.     FUNCTION
  1092.         This call sets attributes of a certain memory range of the
  1093.         software abstraction layer of the MMU tree, aligned to page 
  1094.         boundaries.
  1095.  
  1096.     INPUTS
  1097.         context - a handle to the context to modify or NULL for the active
  1098.             context.
  1099.  
  1100.         flags    - a binary flags field for the attributes to define. The
  1101.                 following bits have been defined:
  1102.  
  1103.                 MAPP_WRITEPROTECTED     -    The page will be write 
  1104.                     protected. Writes to this area will cause a segmentation
  1105.                     fault.
  1106.  
  1107.                 MAPP_ROM                - Read only memory, writes tolerated.
  1108.                     This is almost identically to MAPP_READONLY except that
  1109.                     writes into this area will not cause a call of the
  1110.                     segmentation fault handler. The library will filter them
  1111.                     out.
  1112.                     This property can be used to simulate a ROM in RAM and
  1113.                     might be useful for kickstart remappers.
  1114.  
  1115.                 MAPP_USED                -    The "used" bit of the pages
  1116.                     will be set. The CPU will set this bit automatically
  1117.                     as soon as the pages are accessed.
  1118.  
  1119.                     This flag will turn on the "USED" bit in the hard-
  1120.                     ware MMU bit. NOT setting this flag means that the
  1121.                     USED bit in the hardware tree is preserved, regard-
  1122.                     less of the mask value.
  1123.  
  1124.                 MAPP_MODIFIED            -    The "modified" bit of the pages
  1125.                     will be set. The CPU will set this bit automatically
  1126.                     as soon as a write is performed to the page in question.
  1127.                     DO NOT SET THIS BIT TOGETHER WITH MAPP_WRITEPROTECTED
  1128.                     OR WITHOUT MAPP_USED or the CPU might hang. 
  1129.  
  1130.                     This flag will turn on the "MODIFIED" bit in the hard-
  1131.                     ware MMU bit. NOT setting this flag means that the
  1132.                     MODIFIED bit in the hardware tree is preserved, regard-
  1133.                     less of the mask value.
  1134.  
  1135.                 MAPP_PRIVATE            -    The page will be marked invalid
  1136.                     for all but the given contexts.
  1137.  
  1138.                 MAPP_INVALID            -    The page will be marked as 
  1139.                     invalid. Accessing it will invoke the bus error hook.
  1140.                     User data can be provided for this property mode,
  1141.                     provided you don't select MAPP_SINGLEPAGE or 
  1142.                     MAPP_REPAIRABLE as well.
  1143.  
  1144.                 MAPP_SWAPPED            -    The page will be marked as
  1145.                     swapped out.
  1146.                     A block ID *MUST* be provided for this property mode.
  1147.  
  1148.                 MAPP_CACHEINHIBIT        -    The page will be marked as non-
  1149.                     cacheable.
  1150.  
  1151.                 MAPP_IMPRECISEEXECPTION    -    The page will be marked as 
  1152.                     "imprecise exception". MAPP_CACHEINHIBIT is mandatory
  1153.                     in this case or this flag does nothing.
  1154.                     Only available for the 68060, but does not harm for
  1155.                     other MMUs.
  1156.  
  1157.                 MAPP_NONSERIALIZED        -    The page will be marked as
  1158.                     serialized. MAPP_CACHEINHIBIT is mandatory if this
  1159.                     property is selected. 
  1160.                     Only available for the 68040, but does not harm for
  1161.                     other MMUs.
  1162.  
  1163.                 MAPP_COPYBACK            -    The page will be marked as
  1164.                     "copyback" instead of "writethrough". Generally re-
  1165.                      commended since this is faster for the '40 and '60.
  1166.                     Only available for 68040 and 68060, but does not harm
  1167.                     if selected for other MMUs. MAPP_CACHINHIBIT MUST NOT
  1168.                     be selected.
  1169.     
  1170.                 MAPP_REMAPPED                -    Map the page to a different
  1171.                     memory location. Parameters are given in the tag items.
  1172.  
  1173.                     Even though this seems simple, remapping memory is
  1174.                     full of quirks. Obviously, DMA devices and the MMU
  1175.                     itself see the true physical addresses and not the
  1176.                     logical addresses as filtered by the MMU. Therefore,
  1177.                     adding remapped memory to the exec.library freelist
  1178.                     will cause nothing than trouble and hard to trace
  1179.                     disk faults and crashes as soon as this memory is
  1180.                     used by a DMA device or the mmu.library itself.
  1181.                     (Note that even though the library is supposed to
  1182.                      support this, this is currently untested)
  1183.                     Even though there *are* documented methods how to
  1184.                     prepare a DMA transfer for remapped memory, USING
  1185.                     these exec function calls is unfortunately the 
  1186.                     exceptions. Therefore, this method is currently un-
  1187.                     supported, by most (!really!) DMA device drivers. 
  1188.                     Amongst the broken devices are the gvpscsi.device 
  1189.                     and the cybscsi.device, to give just two examples.
  1190.  
  1191.                     The omniscsi.device (the "Guru ROM") can be fixed
  1192.                     with the MuOmniScsiPatch.
  1193.  
  1194.                     If you really *MUST* remap public memory, then align
  1195.                     it *AT LEAST* to the border given by RemapSize().    
  1196.                     Just page alignment WILL NOT BE ENOUGH due to the way
  1197.                     how the library works internally.    
  1198.  
  1199.                     YOU HAVE BEEN WARNED!
  1200.                     
  1201.                 MAPP_SUPERVISORONLY        -    The page will be not available
  1202.                     for user programs.
  1203.  
  1204.                     NOTE: This mode is currently implemented using invalid 
  1205.                     page descriptors for the user pages and is ignored
  1206.                     when building supervisor tables. This method saves some
  1207.                     space for the 68040 and 68060 and was the only way how
  1208.                     it could be done for the 68030 and 68851 without using
  1209.                     MMU tables twice as large.
  1210.  
  1211.                 MAPP_USERPAGE0            -    Set user page attribute 0.
  1212.                     This selects the user page attribute 0 for the 68040
  1213.                     and 68060. "USER" DOES NOT MEAN YOU!
  1214.                     The status of this bit appears on special pins of the
  1215.                     CPU and might be required by some hardware, so don't     
  1216.                     play with this. You should not change this bit, by no
  1217.                     means.
  1218.  
  1219.                 MAPP_USERPAGE1            -    Set user page attribute 1.
  1220.                     This selects the user page attribute 0 for the 68040
  1221.                     and 68060. See above for warnings.
  1222.  
  1223.                 MAPP_GLOBAL                -    The pages are part of the
  1224.                     global (public) memory. 
  1225.                     You should not set this bit manually, it is under
  1226.                     control of the library to optimize table flushes.
  1227.  
  1228.                 MAPP_BLANK                -    Blank memory.
  1229.                     The pages are mapped to one special area in RAM so
  1230.                     erraneous reads and writes to these pages won't harm. 
  1231.                     MAPP_BLANK should ONLY be used to mark special memory
  1232.                     areas as "non-available" and un-handled by the hardware,
  1233.                     nothing else. 
  1234.  
  1235.                 MAPP_SHARED                -     Properties are identically to
  1236.                     the public context.
  1237.                     This tells the library to use the same properties as
  1238.                     for the global context. However, MAPP_SHARED pages
  1239.                     are not automatically updated when the global context
  1240.                     changes, it's just a convenient way of saying "I want
  1241.                     to uninstall my settings".
  1242.  
  1243.                 MAPP_TRANSLATED            -    Under control of the TTx 
  1244.                     registers.
  1245.                     NEVER SET THIS BIT YOURSELF.
  1246.                     Pages with the "MAPP_TRANSLATED" bit set are under
  1247.                     control of the "transparent translation registers" of
  1248.                     the MMU and are "out of scope" for the mmu.library.
  1249.                     Defining any properties for this domain will do nothing
  1250.                     (or little, dependent on the TTx register configuration).
  1251.                     A virtual memory program MUST NOT use virtual addresses
  1252.                     which are transparently translated, this won't work.
  1253.                     The mmu.library tries to be smart about the TTx registers
  1254.                     and disables "unuseful" TTx settings itself.
  1255.  
  1256.                 MAPP_INDIRECT            -     Map to a user provided page
  1257.                     descriptor.
  1258.                     The provided pages(s) are mapped by a user provided
  1259.                     page descriptor. This page descriptor MUST BE aligned
  1260.                     to a long word address, and it MUST BE a valid page
  1261.                     descriptor for the MMU used.
  1262.  
  1263.                     NEVER EVER attempt DMA, such as harddisk reads or
  1264.                     writes to a memory domain marked as MAPP_INDIRECT.
  1265.  
  1266.                     Due to some cache peculatities, the data might be
  1267.                     incorrect and the result would be corrupt data.
  1268.  
  1269.                     The library will be able to mark pages as non-cacheable
  1270.                     if this is required for the DMA transfer, but this
  1271.                     magic does not work for indirect pages.
  1272.  
  1273.                     JUST DON'T DO THAT, MAPP_INIDIRECT is definitely an
  1274.                     advanced feature.
  1275.  
  1276.                 MAPP_BUNDLED            -    Map all pages in range to
  1277.                     a single page in RAM.
  1278.  
  1279.                     The main purpose of this function is to provide a
  1280.                     MAPP_BLANK property with a user-selectable target
  1281.                     page.
  1282.  
  1283.                 MAPP_SINGLEPAGE            -    Make this page available for
  1284.                     SetPagePropertiesA().
  1285.  
  1286.                     WARNING! Setting this bit shortcuts some optimizations
  1287.                     the library might perform on the MMU table. The system
  1288.                     may easely run out of memory if you select this
  1289.                     property for "too many" pages. Use it with care, you
  1290.                     have been warned!
  1291.  
  1292.                 MAPP_REPAIRABLE            -    Inform the exception handler
  1293.                     to provide write data and to allow pipeline fill.
  1294.  
  1295.                     If this bit is set, the exception handler gets informed
  1296.                     that you want to know the write data in case writes
  1297.                     fail, or you want to provide the read data in case
  1298.                     reads fail. The read/write data is available in the
  1299.                     ExceptionData structure, read the exception handler
  1300.                     documentation.
  1301.  
  1302.                     This flag should be combined with MAPP_INVALID,
  1303.                     MAPP_WRITEPROTECTED, MAPP_SWAPPED or 
  1304.                     MAPP_SUPERVISORONLY
  1305.  
  1306.                     However, this technique requires a lot of "trickery"
  1307.                     and should be expected to be slow and to create
  1308.                     sub-optimal and over-sized MMU tables. Use it with
  1309.                     care, on as few pages as possible and only if your
  1310.                     exception handler is "not on a hurry".
  1311.  
  1312.                 MAPP_USERATTRIBUTE0        -    This is for your private use.
  1313.                     This bit does not have any specific function, it is
  1314.                     for your private use.
  1315.  
  1316.                 MAPP_USERATTRIBUTE1        -    This is for your private use.
  1317.                 MAPP_USERATTRIBUTE2
  1318.                 MAPP_USERATTRIBUTE3
  1319.  
  1320.  
  1321.         mask    -    A bit mask of the attributes to be changed.
  1322.  
  1323.                 Note that the hardware USED and MODIFIED bits will never
  1324.                 be cleared, even though the properties say so and the
  1325.                 corresponding bits in the mask are set. However, you can
  1326.                 force them "ON" if you like, this saves unnecessary write-
  1327.                 backs of the MMU.
  1328.         
  1329.         lower    -    The lower boundary of the logical address to be 
  1330.                 modified. This must be aligned to the page size or this call
  1331.                 will guru.
  1332.  
  1333.         size    -    Size of the region to be modified. Must be a multiple
  1334.                 of the page size.
  1335.  
  1336.         tags    -    A tag array with additional data. Currently defined:
  1337.  
  1338.                 MAPTAG_DESTINATION    -    the physical destination of the
  1339.                     logical address. Must be provided for the MAPP_MAPPED
  1340.                     or MAPP_BUNDLED    bits. 
  1341.  
  1342.                 MAPTAG_BLOCKID        -    a unique ID the MMU.library doesn't
  1343.                     care about, for external usage of the memory.library.
  1344.                     Must be provided for the MAPP_SWAPPED flag and may be
  1345.                     used to indicate where on disk the swapped page is
  1346.                     kept.
  1347.                 
  1348.                 MAPTAG_USERDATA        -    a unique cookie you might provide
  1349.                     for MAPP_INVALID pages and which is passed thru to the
  1350.                     segmentation fault exception handler.
  1351.  
  1352.                 MAPTAG_DESCRIPTOR    -    a pointer to a long word aligned
  1353.                     table descriptor for MAPP_INDIRECT.
  1354.                 
  1355.  
  1356.     RESULTS
  1357.         A boolean success/failure indicator. Might fail if the context
  1358.         is protected or no memory is available for the modification.
  1359.  
  1360.     NOTES
  1361.         This call adjusts only the abstraction layer of the MMU table
  1362.         and marks the pages as "dirty". An explicit call to 
  1363.         RebuildTree() is required to make the changes active.
  1364.         You should bundle changes to the MMU table and call RebuildTree()
  1365.         once when you're done because rebuilding the MMU tree is a costy
  1366.         operation.
  1367.         If you need to modify the MMU table "on the fly" then consider
  1368.         using "SetPagePropertiesA()", even though its use is restricted
  1369.         to single pages. Even faster are MAPP_INDIRECT pages, but - to
  1370.         say that again - DO NOT PERFORM DMA ON THESE PAGES.
  1371.  
  1372.         The page size can be read with GetPageSize(). 
  1373.  
  1374.         SUPERVISORONLY, SWAPPED and INVALID memory are implemented 
  1375.         using the same MMU attributes (invalid, namely), but the 
  1376.         library exception handler will filter them out and call 
  1377.         the appropriate hook.
  1378.  
  1379.         Write protection goes only for the context specified. It 
  1380.         usually makes sense to mark the memory region as PRIVATE as well, 
  1381.         unless you modify the public hook.
  1382.         (Note that MAPP_PRIVATE is currently not implemented because it
  1383.          will slow down things considerably.)
  1384.  
  1385.         You may freely mark the first memory page as INVALID provided
  1386.         the context MCXTAG_EXECBASE flag is set (it usually is).
  1387.         Long word read accesses to AbsExecBase will be filtered out by 
  1388.         the exception handler of the library and will be satisfied trans-
  1389.         parently to the program, as well as all other accesses except
  1390.         those into the first 1024 bytes.
  1391.  
  1392.     BUGS
  1393.  
  1394.         If the mask contains any property that requires user data, i.e.
  1395.         MAPP_REMAPPED or MAPP_SWAPPED, you *have* to redefine the user 
  1396.         data by tag items and MAY NOT leave them out, as the library 
  1397.         WILL NOT be able to restore the previously defined user data.
  1398.  
  1399.     SEE ALSO
  1400.         GetPropertiesA(), SetContextHook(), GetPageSize(), 
  1401.         RemapSize(), RebuildTree(), SetPagePropertiesA(),    
  1402.         SetMappingPropertiesA()
  1403.  
  1404. mmu.library/SetPagePropertiesA                mmu.library/SetPagePropertiesA
  1405.  
  1406.     NAME
  1407.         SetPagePropertiesA - set hardware memory attributes for a single
  1408.         page.
  1409.  
  1410.     SYNOPSIS
  1411.  
  1412.         result = SetPagePropertiesA( context, flags, mask, lower, tags);
  1413.         d0                               a0        d1      d2    a1        a2
  1414.  
  1415.         BOOL SetPagePropertiesA( struct MMUContext *, ULONG, ULONG, ULONG,
  1416.                              struct TagItem *);
  1417.  
  1418.  
  1419.         result = SetPageProperties( context, flags, mask, lower, tag1, ...);
  1420.  
  1421.         BOOL SetPageProperties( struct MMUContext *, ULONG, ULONG, ULONG, 
  1422.                             Tag tag1, ...);
  1423.  
  1424.     FUNCTION
  1425.         This call sets the hardware attributes of a memory page.
  1426.  
  1427.     INPUTS
  1428.         context - a handle to the context to modify or NULL for the active
  1429.             context.
  1430.  
  1431.         flags    - a binary flags field for the attributes to define. For
  1432.                     the available attributes, see the SetPropertiesA()
  1433.                     function.
  1434.  
  1435.                     Differences:
  1436.  
  1437.                     MAPP_MODIFIED and MAPP_USED are really set or cleared
  1438.                     in the true hardware table, the mask is considered
  1439.                     correctly.
  1440.  
  1441.                     Note that this function is the only method to clear
  1442.                     these two hardware flags, SetPropertiesA() or
  1443.                     RebuildTree() don't do this.
  1444.  
  1445.         mask    -    a bit mask of all bits to be changed.
  1446.  
  1447.         tags    -    A tag array with additional data. Check 
  1448.                     SetPropertiesA() for details.
  1449.  
  1450.     RESULTS
  1451.         A boolean success/failure indicator. Might fail if the context
  1452.         is protected or no memory is available for the modification or
  1453.         the page is not marked with MAPP_SINGLEPAGE.
  1454.  
  1455.     NOTES
  1456.         BE WARNED! This function is very restricted in its use. It may well
  1457.         return FALSE even if all parameters are valid due to hardware 
  1458.         restrictions. This function does never ever rebuild an MMU tree,
  1459.         it just modifies "what is there". If the library choose to optimize
  1460.         the MMU library tree and to map a couple of pages by one descriptor,
  1461.         for what reasons ever, this call will fail. The details when this
  1462.         happens depends not only on the MMU, but on the general system
  1463.         layout.
  1464.  
  1465.         The ONLY documented way to get a mapping for a page that can be
  1466.         adjusted using this call is to set the page to MAPP_SINGLEPAGE using
  1467.         SetPropertiesA() before.
  1468.  
  1469.         This call adjusts the hardware level of the MMU table if a descriptor 
  1470.         is available for a single page. It does not modify more than one
  1471.         page at once.
  1472.  
  1473.         It might happen that the library does not satisfy a request
  1474.         setting a page as "cacheable" if a DMA operation is currently in
  1475.         progress and the page must remain "nonacheable". However, the
  1476.         function will not fail in this case, but just delay the operation
  1477.         until the DMA is complete. The properties will always fall back to
  1478.         the next available option.
  1479.  
  1480.         This routine is safe to be called from within interrupts, it does
  1481.         not break any Forbid() or Disable() and is ideal for 
  1482.         quick-and-dirty repair operations within exceptions handlers,
  1483.         provided the MAPP_SINGLEPAGE flag has been set. 
  1484.  
  1485.     BUGS
  1486.         Note that MAPP_SINGLEPAGE is the flag you want here, not 
  1487.         MAPP_REPAIRABLE. That's something different!
  1488.  
  1489.         If the mask contains any property that requires user data, i.e.
  1490.         MAPP_REMAPPED or MAPP_SWAPPED, you *have* to redefine the user 
  1491.         data by tag items and MAY NOT leave them out, as the library 
  1492.         WILL NOT be able to restore the previously defined user data.
  1493.  
  1494.     SEE ALSO
  1495.             GetPagePropertiesA(), SetContextHook(), 
  1496.             GetPageSize(), RebuildTree(), SetPropertiesA(),
  1497.             SetMappingPropertiesA()
  1498. mmu.library/RebuildTree                            mmu.library/RebuildTree
  1499.  
  1500.     NAME    
  1501.         RebuildTree - build a MMU hardware tree from the software abstraction
  1502.         layer.
  1503.  
  1504.     SYNOPSIS
  1505.         result = RebuildTree( context );
  1506.         d0                      a0
  1507.  
  1508.         BOOL RebuildTree ( struct MMUContext * );
  1509.  
  1510.     FUNCTION
  1511.         This function adjusts the MMU hardware tree to reflect the settings
  1512.         of the software abstraction layer defined with SetPropertiesA().
  1513.  
  1514.     INPUTS
  1515.         context - a handle to the context to investigate or NULL for the
  1516.         active context.
  1517.  
  1518.     RESULTS
  1519.         a boolean success/failure indicator. TRUE if the operation was
  1520.         performed successfully.
  1521.  
  1522.     NOTES
  1523.         This is the big - and admittedly - slow one.
  1524.  
  1525.         Rebuilding the MMU tree is a relatively slow operation. The library
  1526.         tries to be smart about it and rebuilds only the pages whose
  1527.         mappings have been adjusted, but it's still a heavy beast.
  1528.  
  1529.         Properties temporarely defined with SetPagePropertiesA() will be
  1530.         lost after the rebuild, except for the MAPP_USED and MAPP_MODIFIED
  1531.         bits.
  1532.  
  1533.         BE WARNED! A consistent use of the two flags is only possible
  1534.         if the pages are marked as MAPP_SINGLE. The page building algorithm
  1535.         does not guarantee consistent use of these two bits except for
  1536.         MAPP_SINGLE pages. Even though it *might* look well most the time,
  1537.         it is not documented that these two bits are kept correctly for non-
  1538.         SINGLE pages. If you need MODIFIED or USED page information, the only 
  1539.         way to get them is to mark these pages as MAPP_SINGLE. There's no 
  1540.         consistent use for these flags if early termination descriptors 
  1541.         (hence, w/o MAPP_SINGLE) are used by the library. 
  1542.  
  1543.         Even though some pages in the abstraction layer might be marked as
  1544.         un-USED or un-MODIFIED, this routine NEVER clears the hardware bits.
  1545.         It requires a call to SetPagePropertiesA(), and hence the MAPP_SINGLE
  1546.         attribute (once again!) to do this.
  1547.  
  1548.     BUGS
  1549.         Much more should be said about this function.
  1550.  
  1551.     SEE ALSO
  1552.         SetPropertiesA(), SetPagePropertiesA(), GetPropertiesA(),
  1553.         GetPagePropertiesA()
  1554.  
  1555. mmu.library/GetPropertiesA                        mmu.library/GetPropertiesA
  1556.  
  1557.     NAME
  1558.         GetPropertiesA - read memory attributes for a given logical page
  1559.         from the MMU table abstraction layer.
  1560.  
  1561.     SYNOPSIS
  1562.  
  1563.         flags = GetPropertiesA( context, lower, tags);
  1564.         d0                         a0         a1        a2
  1565.  
  1566.         ULONG GetPropertiesA( struct MMUContext *, void *, struct TagItem *);
  1567.  
  1568.  
  1569.         flags = GetProperties( context, lower, tag1, ...);
  1570.  
  1571.         ULONG GetProperties( struct MMUContext *, void *, Tag tag1, ...);
  1572.  
  1573.     FUNCTION
  1574.         This call reads the page properties of a certain address in
  1575.         memory from the software abstraction layer. It is the counterpart
  1576.         of SetPropertiesA().
  1577.  
  1578.     INPUTS
  1579.         context - a handle to the context to investigate or NULL for the
  1580.             active context.
  1581.  
  1582.         lower    - the logical address of the page to investigate. The
  1583.             size of the page depends on the hardware and is selected by
  1584.             the MMU library. The number of bytes in a page is returned
  1585.             by GetPageSize().
  1586.  
  1587.         tags    - additional tags. Currently defined are:
  1588.  
  1589.                 MAPTAG_DESTINATION    -    a pointer to a void * where 
  1590.                     the physical destination of the logical address is
  1591.                     filled in. Only available if the page is physically
  1592.                     mapped to somewhere. Not filled in otherwise.
  1593.  
  1594.                 MAPTAG_BLOCKID        -    read the a unique ID for the 
  1595.                     MAPP_SWAPPED property. Untouched if the page isn't
  1596.                     swapped. The tag data points to a long word which will
  1597.                     be filled in for swapped out pages.
  1598.                 
  1599.                 MAPTAG_USERDATA        -    read the unique cookie for 
  1600.                     INVALID pages, fill in the long word pointed to by
  1601.                     the tag data field.
  1602.  
  1603.                 MAPTAG_DESCRIPTOR    -    fill in the location of the
  1604.                     indirect descriptor which is used to perform the
  1605.                     mapping. Only used if MAPP_INDIRECT is used.
  1606.  
  1607.     RESULTS
  1608.         Returns a binary flags field for the attributes to define. See
  1609.         SetPropertiesA() for details. Remember that MAPP_USED or 
  1610.         MAPP_MODIFIED reflect the bits on the abstraction layer, not the
  1611.         true hardware bits. You MUST call GetPagePropertiesA() to read
  1612.         them, and hence *MUST* use MAPP_SINGLE pages.
  1613.  
  1614.     NOTES
  1615.         The page size can be read with GetPageSize(). Check the return    
  1616.         code of this call!
  1617.  
  1618.         The flags returned are valid for the given context, a different
  1619.         context may return a different flag setting and even a different
  1620.         physical locations.
  1621.  
  1622.         WARNING: The flags returned DO NOT reflect the hardware flags
  1623.         in the MMU table for the context. They DO reflect the settings
  1624.         installed with SetPropertiesA() on the abstraction layer of the
  1625.         MMU tables.
  1626.  
  1627.         The hardware table might differ for the following reasons:
  1628.  
  1629.             - SetPropertiesA() was called, but the changes haven't been
  1630.               made active with RebuildTree() yet.
  1631.             - A program modified the hardware layer directly using
  1632.               SetPagePropertiesA().
  1633.             - DMA is currently active and the page in question has 
  1634.               therefore been marked as non-cacheable temporarely.
  1635.  
  1636.         Additionally, the library might have adjusted the abstraction
  1637.         layer itself by allocating non-cacheabe memory for its
  1638.         MMU tables.
  1639.  
  1640.         This routine is *NOT* safe to be called from within interrupts.
  1641.  
  1642.     BUGS
  1643.  
  1644.     SEE ALSO
  1645.         SetPropertiesA(), SetContextHook(), GetMappingPropertiesA(),
  1646.         GetPageSize(), GetPagePropertiesA(), RebuildTree()
  1647.  
  1648. mmu.library/GetPagePropertiesA                    mmu.library/GetPagePropertiesA
  1649.  
  1650.     
  1651.     NAME
  1652.         GetPropertiesA - read memory attributes from the hardware level
  1653.         for a given logical page. 
  1654.  
  1655.     SYNOPSIS
  1656.  
  1657.         flags = GetPagePropertiesA( context, lower, tags);
  1658.         d0                              a0          a1     a2
  1659.  
  1660.         ULONG GetPagePropertiesA( struct MMUContext *, void *, 
  1661.  
  1662.                                 struct TagItem *);
  1663.  
  1664.  
  1665.         result = GetPageProperties( context, lower, tag1, ...);
  1666.  
  1667.         BOOL GetPageProperties( struct MMUContext *, void *, Tag tag1, ...);
  1668.  
  1669.     FUNCTION
  1670.         This call reads the page properties of a certain address in
  1671.         memory directly from the hardware. It is the counterpart
  1672.         of SetPagePropertiesA().
  1673.  
  1674.     INPUTS
  1675.         context - a handle to the context to investigate or NULL for the
  1676.             active context. The library might use the MMU hardware directly
  1677.             if NULL is passed in, this call might be faster therefore.
  1678.  
  1679.         lower    - the logical address of the page to investigate. The
  1680.             size of the page depends on the hardware and is selected by
  1681.             the MMU library. The number of bytes in a page is returned
  1682.             by GetPageSize().
  1683.  
  1684.         tags    - additional tags. See GetPropertiesA() for details.
  1685.  
  1686.  
  1687.     RESULTS
  1688.         Returns a binary flags field for the attributes to define. See
  1689.         SetPropertiesA() for details.
  1690.  
  1691.     NOTES
  1692.         The page size can be read with GetPageSize(). 
  1693.  
  1694.         The flags returned are valid for the given context, a different
  1695.         context may return a different flag setting and even a different
  1696.         physical location.
  1697.  
  1698.         WARNING: The flags returned reflect the NOT the hardware flags
  1699.         in the MMU table for the context except for the MODIFIED and USED
  1700.         properties, even though the hardware level is *almost* consistent
  1701.         with these flags. 
  1702.  
  1703.         The hardware table might differ slightly in the following 
  1704.         situations:
  1705.  
  1706.             - DMA is currently active and the page in question has 
  1707.               therefore been marked as non-cacheable temporarely.
  1708.               Therefore, the cache settings returned are what will be
  1709.               re-installed here when DMA is finished. The library
  1710.               will "fake" the flags you have installed for the page
  1711.               investigated.
  1712.             - The library will use invalid descriptors to implement
  1713.               supervisor only or swapped pages.
  1714.  
  1715.         However, even though the flags might differ from the hardware
  1716.         flags, you're always safe to re-install the properties with
  1717.         SetPageProperties, there's no need to keep track of pecularities
  1718.         like cache disabling for DMA pages. The library does this for you.
  1719.  
  1720.         MAPP_MODIFIED and MAPP_USED are always read from the hardware
  1721.         directly.
  1722.  
  1723.         KEEP IN MIND that these two bits are only set and handled
  1724.         consistently for MAPP_SINGLE pages. You MUST NOT interpret
  1725.         them in all other cases, their values might get lost on a
  1726.         RebuildTree() call.
  1727.  
  1728.         This routine is safe to be called from within interrupts, most
  1729.         useful within exception handlers.
  1730.  
  1731.     BUGS
  1732.  
  1733.     SEE ALSO
  1734.             GetPropertiesA(), SetContextHook(), 
  1735.             GetPageSize(), SetPagePropertiesA(), RebuildTree()
  1736.  
  1737. mmu.library/AllocAligned                                mmu.library/AllocAligned
  1738.  
  1739.     NAME
  1740.         AllocAligned     -    allocate memory aligned to a memory border.
  1741.  
  1742.     SYNOPSIS
  1743.         mem = AllocAligned( bytesize, reqments, align );
  1744.         d0                    d0           d1         a0
  1745.  
  1746.         void * AllocAligned( ULONG, ULONG, ULONG);
  1747.  
  1748.     FUNCTION
  1749.         Allocate memory aligned to certain boundaries.
  1750.  
  1751.     INPUTS
  1752.         bytesize - the size of the memory to allocate. 
  1753.  
  1754.         reqments -    exec style memory attributes
  1755.  
  1756.         align    -    the alignment restrictions of the page.
  1757.                     MUST be a power of two.
  1758.  
  1759.     RETURNS
  1760.         a pointer to the allocated memory, aligned to the given border or
  1761.         NULL if no free physical memory could be found.
  1762.  
  1763.     NOTES
  1764.         Examples of how to use the "align" parameter:
  1765.  
  1766.         mem = AllocAligned(123,MEMF_PUBLIC|MEMF_CLEAR,1024);
  1767.  
  1768.         will allocate 123 bytes starting at a 1024 byte border, i.e. 
  1769.         the address returned will be divisible by 1024. The call will 
  1770.         clear the 123 bytes, NOT MORE.
  1771.  
  1772.         This is a service routine for the memory.library and shouldn't be
  1773.         used for all-day purposes.
  1774.  
  1775.         A DOS process will have its pr_Result2 field set to
  1776.         ERROR_NO_FREE_STORE if the memory allocation fails.
  1777.  
  1778.         The mmu.library calls this function by using its LVO library entry,
  1779.         so it can be patched to a smarter implementation if desired.
  1780.  
  1781.     BUGS
  1782.  
  1783.     SEE ALSO
  1784.         GetPageSize(), exec/memory.h
  1785.  
  1786. mmu.library/LockMMUContext                        mmu.library/LockMMUContext
  1787.  
  1788.     NAME
  1789.         LockMMUContext        -    lock a MMU context
  1790.  
  1791.     SYNOPSIS
  1792.         LockMMUContext( context );
  1793.                           a0
  1794.  
  1795.         void LockMMUContext( struct MMUContext * );
  1796.  
  1797.     FUNCTION
  1798.         Lock the software abstraction layer of the MMU table against
  1799.         modifications from other tasks.
  1800.  
  1801.     INPUTS
  1802.         A handle to a MMUContext or NULL for the active context.
  1803.  
  1804.     RETURNS
  1805.  
  1806.     NOTES
  1807.          This mechanism DOES NOT avoid changes of the MMU table on a lower
  1808.         level by SetPageProperties(), only SetProperties() from other
  1809.         tasks will be locked.
  1810.         Hence, it locks the abstraction layer, but not the hardware
  1811.         level.
  1812.  
  1813.         DO NOT lock more than one context at once, unless you locked
  1814.         also the context list with LockContextList(). Not following 
  1815.         this rule might cause deadlocks.
  1816.  
  1817.     BUGS
  1818.  
  1819.     SEE ALSO
  1820.         UnlockMMUContext(), SetPageProperties(), SetProperties(),
  1821.         LockContextList().
  1822.  
  1823. mmu.library/UnlockMMUContext                    mmu.library/UnlockMMUContext
  1824.  
  1825.     NAME
  1826.         UnlockMMUContext    -    release a MMU context
  1827.  
  1828.     SYNOPSIS
  1829.         UnlockMMUContext( context );
  1830.                           a0
  1831.  
  1832.         void UnlockMMUContext( struct MMUContext * );
  1833.  
  1834.     FUNCTION
  1835.         Release the software abstraction layer of the MMU table, allow
  1836.         modifications from other tasks.
  1837.  
  1838.     INPUTS
  1839.         A handle to a MMUContext or NULL for the active context.
  1840.  
  1841.     RETURNS
  1842.  
  1843.     NOTES
  1844.          This mechanism DOES NOT avoid changes of the MMU table on a lower
  1845.         level by SetPageProperties(), only SetProperties() from other
  1846.         tasks will be locked.
  1847.         Hence, it locks the abstraction layer, but not the hardware
  1848.         level.
  1849.  
  1850.     BUGS
  1851.  
  1852.     SEE ALSO
  1853.         LockMMUContext(), SetPageProperties(), SetProperties(),
  1854.         AttemptLockMMUContext()
  1855.  
  1856. mmu.library/AttemptLockMMUContext            mmu.library/AttemptLockMMUContext
  1857.  
  1858.     NAME
  1859.         AttemptLockMMUContext        -    attempt to lock a MMU context
  1860.  
  1861.     SYNOPSIS
  1862.         ok = AttemptLockMMUContext( context );
  1863.                                         a0
  1864.  
  1865.         LONG AttemptLockMMUContext( struct MMUContext * );
  1866.  
  1867.     FUNCTION
  1868.         Grants non-blocking access to a MMU context.
  1869.         Attempts to lock the software abstraction layer of the MMU 
  1870.         table against modifications from other tasks. 
  1871.  
  1872.     INPUTS
  1873.         A handle to a MMUContext or NULL for the active context.
  1874.  
  1875.     RETURNS
  1876.         TRUE in case of success - the context is then locked for you
  1877.         and this lock must be released with UnlockMMUContext().
  1878.         FALSE in case any other task holds a lock.
  1879.  
  1880.     NOTES
  1881.          This mechanism DOES NOT avoid changes of the MMU table on a lower
  1882.         level by SetPageProperties(), only SetProperties() from other
  1883.         tasks will be locked.
  1884.         Hence, it locks the abstraction layer, but not the hardware
  1885.         level.
  1886.  
  1887.         DO NOT lock more than one context at once, unless you locked
  1888.         also the context list with LockContextList(). Not following 
  1889.         this rule might cause deadlocks.
  1890.  
  1891.     BUGS
  1892.         In pre-V39 machines, this call does not lock the context again
  1893.         in case you already hold a lock. This is a bug of the pre-V39
  1894.         AttemptSemaphore(), read the exec autodocs for a workaround.
  1895.  
  1896.     SEE ALSO
  1897.         UnlockMMUContext(), SetPageProperties(), SetProperties(),
  1898.         LockContextList(), AttemptSemaphore()
  1899.  
  1900. mmu.library/LockContextList                        mmu.library/LockContextList
  1901.  
  1902.     NAME
  1903.         LockContextList        -    arbitrate a master lock.
  1904.  
  1905.     SYNOPSIS
  1906.         LockContextList( );
  1907.  
  1908.         void LockContextList( void );
  1909.  
  1910.     FUNCTION
  1911.         Arbitrates a master lock that allows locking more than one context
  1912.         at once to avoid deadlocks.
  1913.  
  1914.     INPUTS
  1915.  
  1916.     RETURNS
  1917.  
  1918.     NOTES
  1919.         This lock grants access for locking more than one context at once,
  1920.         to avoid deadlocks. I.e. in case you need to lock more than one
  1921.         context at a time, get this lock FIRST, then lock the contexts
  1922.         in any order you prefer.
  1923.  
  1924.         This call DOES NOT avoid modification of the context list or 
  1925.         individual contexts at all, i.e. other tasks are still able
  1926.         to create and to dispose contexts. To avoid this, you must lock
  1927.         the contexts afterwards.
  1928.  
  1929.         When you're done with the contexts, unlock the contexts first,
  1930.         THEN release this lock with UnlockContextList(). NOTE THE ORDER!
  1931.     
  1932.     BUGS
  1933.  
  1934.     SEE ALSO
  1935.         UnlockMMUContextList(), LockMMUContext(), AttemptLockContextList()
  1936.  
  1937. mmu.library/UnlockContextList                mmu.library/UnlockContextList
  1938.  
  1939.     NAME
  1940.         UnlockContextList    -    release the master context lock
  1941.  
  1942.     SYNOPSIS
  1943.         UnlockContextList( );
  1944.  
  1945.         void UnlockContextList( void );
  1946.  
  1947.     FUNCTION
  1948.         Releases the master lock that allows locking more than one context
  1949.         at once to avoid deadlocks.
  1950.  
  1951.     INPUTS
  1952.  
  1953.     RETURNS
  1954.  
  1955.     NOTES
  1956.         This lock grants access for locking more than one context at once,
  1957.         to avoid deadlocks. I.e. in case you need to lock more than one
  1958.         context at a time, get this lock FIRST, then lock the contexts
  1959.         in any order you prefer.
  1960.  
  1961.         This call DOES NOT avoid modification of the context list or 
  1962.         individual contexts at all, i.e. other tasks are still able
  1963.         to create and to dispose contexts. To avoid this, you must lock
  1964.         the contexts afterwards.
  1965.  
  1966.         When you're done with the contexts, unlock the contexts first,
  1967.         THEN release this lock with UnlockContextList(). NOTE THE ORDER!
  1968.  
  1969.     BUGS
  1970.  
  1971.     SEE ALSO
  1972.         LockContextList(), LockContext(), AttemptLockContextList()
  1973.  
  1974. mmu.library/AttemptLockContextList            mmu.library/AttemptLockContextList
  1975.  
  1976.     NAME
  1977.         AttemptLockContextList        -    attempt to arbitrate the master lock.
  1978.  
  1979.     SYNOPSIS
  1980.         ok = AttemptLockContextList( );
  1981.  
  1982.         LONG AttemptLockContextList( void );
  1983.  
  1984.     FUNCTION
  1985.         Attempts granting the context master lock in a non-blocking
  1986.         fashion. 
  1987.  
  1988.     INPUTS
  1989.  
  1990.     RETURNS
  1991.         TRUE in case the master lock could be arbitrated. You have then to
  1992.         release it with UnlockContextList().
  1993.         FALSE in case it is already locked and access could not be granted.
  1994.  
  1995.     NOTES
  1996.         This lock grants access for locking more than one context at once,
  1997.         to avoid deadlocks. I.e. in case you need to lock more than one
  1998.         context at a time, get this lock FIRST, then lock the contexts
  1999.         in any order you prefer.
  2000.  
  2001.         This call DOES NOT avoid modification of the context list or 
  2002.         individual contexts at all, i.e. other tasks are still able
  2003.         to create and to dispose contexts. To avoid this, you must lock
  2004.         the contexts afterwards.
  2005.  
  2006.         When you're done with the contexts, unlock the contexts first,
  2007.         THEN release this lock with UnlockContextList(). NOTE THE ORDER!
  2008.  
  2009.     BUGS
  2010.         In pre-V39 machines, this call does not lock the context again
  2011.         in case you already hold a lock. This is a bug of the pre-V39
  2012.         AttemptSemaphore(), read the exec autodocs for a workaround.
  2013.  
  2014.     SEE ALSO
  2015.         UnlockContextList(), LockContext(), LockContextList(),
  2016.         AttemptLockSemaphore()
  2017.     
  2018. mmu.library/AllocLineVec                            mmu.library/AllocLineVec
  2019.  
  2020.     NAME
  2021.         AllocLineMem        -     allocate cache line aligned, keep size
  2022.  
  2023.     SYNOPSIS
  2024.         AllocLineVec ( bytesize , attributes );
  2025.                           d0        d1
  2026.  
  2027.         void * AllocLineVec ( ULONG, ULONG );
  2028.  
  2029.     FUNCTION
  2030.         Allocates memory like AllocVec(), but the memory is guaranteed
  2031.         to be aligned to cache lines of the processors in the system,
  2032.         even though the pointer returned IS NOT.
  2033.         Minimal guaranteed alignment is currently 32 bytes, i.e. a 
  2034.         PPC cache line. Future hardware may require stricter alignments.
  2035.  
  2036.         AllocLineMem'd memory is released with FreeVec() from the
  2037.         exec.library.
  2038.  
  2039.     INPUTS
  2040.         bytesize     -    the size of the memory block in bytes.
  2041.         attributes    -    memory attributes, see exec.library/AllocMem.
  2042.  
  2043.     RETURNS
  2044.         a pointer to the memory allocated or NULL on failure.
  2045.  
  2046.         A DOS process will have its pr_Result2 field set to
  2047.         ERROR_NO_FREE_STORE if the memory allocation fails.
  2048.  
  2049.     NOTES
  2050.         BIG WARNING: The pointer returned IS NEVER cache line aligned
  2051.         itself, but the complete memory block toghether with the
  2052.         vector size is kept in a cache line, regardless of the size
  2053.         passed in. Due to alignment restrictions, the routine might
  2054.         allocate a larger memory block than requested. It is however
  2055.         guaranteed that AT LEAST the size requested is returned, and
  2056.         that a FreeVec() will, indeed, free all memory.
  2057.  
  2058.         If MEMF_CLEAR is requested, the memory is cleared on the
  2059.         MC68K side, but the "zeros written" might be still in the
  2060.         cache. Hence, it is a good idea to flush the cache if the
  2061.         memory is passed over to the PPC.
  2062.  
  2063.         However, the vector size itself is always "pushed" to 
  2064.         memory, it is therefore guaranteed to be properly written
  2065.         back to the memory.
  2066.  
  2067.         The memory allocated this way is released by FreeVec() of
  2068.         the exec.library.
  2069.  
  2070.     BUGS
  2071.  
  2072.     SEE ALSO
  2073.         exec.library/AllocVec(), exec.library/FreeVec(), AllocLineMem()
  2074.  
  2075. mmu.library/PhysicalPageLocation            mmu.library/PhysicalPageLocation
  2076.  
  2077.     NAME
  2078.         PhysicalPageLocation    -    translate logical address to physical
  2079.  
  2080.     SYNOPSIS
  2081.         addr = PhysicalPageLocation( context , addr );
  2082.         d0                               a0         a1
  2083.  
  2084.         void * PhysicalPageLocation( struct MMUContext * , void * );
  2085.  
  2086.     FUNCTION
  2087.         This function finds the physical address for the logical address
  2088.         passed in by scanning the MMU hardware table. 
  2089.         If the physical address is not available, NULL is returned.
  2090.  
  2091.     INPUTS
  2092.         context - the context to enter or NULL for the current context.
  2093.         addr    - the logical address to be translated.
  2094.  
  2095.     RETURNS
  2096.         the physical address of the logical address passed in, or NULL
  2097.         in case the logical address is not swapped in or otherwise out of
  2098.         control of the library.
  2099.  
  2100.     NOTES
  2101.         This is the low-level function, consider using the high-level
  2102.         function PhysicalLocation() when possible.
  2103.         This call can be safely used within interrupts.
  2104.  
  2105.     BUGS
  2106.         The function will also return NULL in case the logical address
  2107.         is translated to the address 0L. However, 0L should never be 
  2108.         used as physical address anyhow.
  2109.  
  2110.     SEE ALSO
  2111.         GetPageProperties(), PhysicalLocation()
  2112. mmu.library/PhysicalLocation                    mmu.library/PhysicalLocation
  2113.  
  2114.     NAME
  2115.         PhysicalLocation    -    translate logical address to physical
  2116.  
  2117.     SYNOPSIS
  2118.         props = PhysicalLocation( context, addrptr, lenptr );
  2119.         d0                               d1         a0          a1
  2120.  
  2121.         ULONG PhysicalLocation( struct MMUContext * , void ** , ULONG * );
  2122.  
  2123.     FUNCTION
  2124.         This function finds the physical address for the logical address
  2125.         passed in by scanning the software abstraction layer.
  2126.         If the physical address is not available, NULL is returned.
  2127.  
  2128.     INPUTS
  2129.         context - the context to enter or NULL for the current context.
  2130.         addrptr - points to the logical address to be translated.
  2131.                   The physical address is filled in here.
  2132.         lenptr     - Points to the length of the address range to be trans-
  2133.                   lated. The function returns the length of the largest 
  2134.                   possible continous memory range contained in the memory
  2135.                   range passed in. Hence, this function may shorten the
  2136.                   memory block for fragmentized memory models.
  2137.  
  2138.     RETURNS
  2139.         the properties of the memory range.
  2140.  
  2141.     NOTES
  2142.         This is the high-level function, it is not callable from within
  2143.         interrupts.
  2144.  
  2145.         In case you've to operate on a range of physical memory, start
  2146.         the translation with this call, then compare the size returned
  2147.         with the size of the memory block passed in. Because this 
  2148.         function may shorten the memory size in case the physical 
  2149.         memory is fragmentated, you should be prepared that the size
  2150.         returned is smaller than what was passed in. In this case, operate
  2151.         on the memory region returned, then add the returned size to
  2152.         the original logical address and call this function again to
  2153.         get the physical location of the next chunk.
  2154.  
  2155.     BUGS
  2156.         The function will also return NULL in case the logical address
  2157.         is translated to the address 0L. However, 0L should never be 
  2158.         used as physical address anyhow.
  2159.  
  2160.     SEE ALSO
  2161.         GetProperties(), PhysicalPageLocation()
  2162. mmu.library/DMAInitiate                                mmu.library/DMAInitiate
  2163.  
  2164.     NAME
  2165.         DMAInitiate        -    start a DMA transport given a logical address.
  2166.  
  2167.     SYNOPSIS
  2168.         DMAInitiate( context, addrptr, lenptr, write );
  2169.                         d1         a0          a1    d0
  2170.  
  2171.         void DMAInitiate( struct MMUContext * , void ** , ULONG * , BOOL );
  2172.  
  2173.     FUNCTION
  2174.         This function finds the physical address for the logical address
  2175.         passed in by scanning a backup of the MMU translation tree.
  2176.         It ignores modifications made by the high-level and low-level
  2177.         functions unless RebuildTree() is called.
  2178.  
  2179.     INPUTS
  2180.         context - the context to enter or NULL for the current context.
  2181.                   NOTE: This parameter is currently a dummy and should be
  2182.                   set to NULL. The mmu.library will always use the public
  2183.                   context for translation.
  2184.         addrptr - points to the logical address to be translated.
  2185.                   The physical address is filled in here.
  2186.         lenptr     - Points to the length of the address range to be trans-
  2187.                   lated. The function returns the length of the largest 
  2188.                   possible continous memory range contained in the memory
  2189.                   range passed in. Hence, this function may shorten the
  2190.                   memory block for fragmentized memory models.
  2191.         write    - set this to TRUE for transports from a DMA device INTO
  2192.                   the memory, i.e. device reads. Set this to FALSE for
  2193.                   writes from memory to the device.
  2194.  
  2195.     RETURNS
  2196.  
  2197.     NOTES
  2198.         The function checks whether the memory range passed in is available
  2199.         for DMA. It will guru in case it is not, i.e. the page is either
  2200.         swapped out, invalid, indirect, or write protected for
  2201.         DMA device reads. Reads into ROM addresses are silently tolerated,
  2202.         and, hence, are translations to and from blank dummy pages.
  2203.  
  2204.         This function is callable from within interrupts, but does only
  2205.         use a backup of the high-level table for its translation.
  2206.         Changes to the software abstraction level are not visible for
  2207.         this function unless RebuildTree() is called. Changes to the
  2208.         hardware level are not at all visible to this (and all other
  2209.         high-level) functions.
  2210.  
  2211.         In case you've to operate on a range of physical memory, start
  2212.         the translation with this call, then compare the size returned
  2213.         with the size of the memory block passed in. Because this 
  2214.         function may shorten the memory size in case the physical 
  2215.         memory is fragmentated, you should be prepared that the size
  2216.         returned is smaller than what was passed in. With the physical
  2217.         address returned, start the DMA and call DMATerminate() when
  2218.         done.
  2219.         In case the returned size is smaller than the block passed in,
  2220.         add the returned size to the original logical address and 
  2221.         call this function again to get the physical location of the 
  2222.         next chunk.
  2223.  
  2224.         EACH CALL TO DMAInitiate() must be matched by ONE AND PRECISELY
  2225.         ONE call to DMATerminate().
  2226.  
  2227.         Even though this function does not require locking the context,    
  2228.         I highly recommend doing so. It won't crash if you don't, but
  2229.         someone else could modify the MMU translation table in between.
  2230.         The library can deal with that, but the result of the DMA 
  2231.         operation might be different than what you expect.
  2232.  
  2233.     BUGS
  2234.         This function should really use the context passed in, but
  2235.         since most (if not all) DMA device drivers do not keep the 
  2236.         context of the task that actually initiated the transfer and
  2237.         hence would use the wrong context anyhow, DMA is currently limited
  2238.         to the public context.
  2239.  
  2240.     SEE ALSO
  2241.         DMATerminate(), PhysicalPageLocation(), exec/CachePreDMA()
  2242. mmu.library/DMATerminate                            mmu.library/DMATerminate
  2243.  
  2244.     NAME
  2245.         DMATerminate    -    end a DMA transfer initiated by DMAInitiate.
  2246.  
  2247.     SYNOPSIS
  2248.         DMATerminate( context );
  2249.                         d1         
  2250.  
  2251.         void DMATerminate( struct MMUContext * );
  2252.  
  2253.     FUNCTION
  2254.         This function ends a DMA transfer initiated by DMAInitate. It
  2255.         releases the resources by the first call.
  2256.  
  2257.     INPUTS
  2258.         context - the context to enter or NULL for the current context.
  2259.                   NOTE: This parameter is currently a dummy and should be
  2260.                   set to NULL. The mmu.library will always use the public
  2261.                   context for translation.
  2262.  
  2263.     RETURNS
  2264.  
  2265.     NOTES
  2266.         This function is callable from within interrupts, but does only
  2267.         use a backup of the high-level table for its translation.
  2268.         Changes to the software abstraction level are not visible for
  2269.         this function unless RebuildTree() is called. Changes to the
  2270.         hardware level are not at all visible to this (and all other
  2271.         high-level) functions.
  2272.  
  2273.         EACH CALL TO DMAInitiate() must be matched by ONE AND PRECISELY
  2274.         ONE call to DMATerminate().
  2275.  
  2276.         For details, check the DMAInitiate() function.
  2277.  
  2278.     BUGS
  2279.         This function should really use the context passed in, but
  2280.         since most (if not all) DMA device drivers do not keep the 
  2281.         context of the task that actually initiated the transfer and
  2282.         hence would use the wrong context anyhow, DMA is currently limited
  2283.         to the public context.
  2284.  
  2285.     SEE ALSO
  2286.         DMAInitiate(), PhysicalPageLocation(), exec/CachePostDMA()
  2287. mmu.library/GetMapping                                mmu.library/GetMapping
  2288.  
  2289.     NAME
  2290.         GetMapping     -    get access to the memory map of a MMUContext
  2291.  
  2292.     SYNOPSIS
  2293.         list = GetMapping( context );
  2294.         d0                    a0
  2295.  
  2296.         struct MinList * GetMapping( struct MMUContext * );
  2297.  
  2298.     FUNCTION
  2299.         This function makes a copy of the MapNodes for the given context.
  2300.         The nodes in this list describe the memory map as seen from tasks
  2301.         attached to this context, sorted by logical addresses.
  2302.         The list must be released afterwards with ReleaseMapping().
  2303.  
  2304.     INPUTS
  2305.         context - the context to enter or NULL for the current context.
  2306.  
  2307.     RETURNS
  2308.         a pointer to a struct MinList which contains the MapNodes for this
  2309.         context, sorted by physical address, or NULL in case of failure.
  2310.  
  2311.     NOTES
  2312.         The nodes are just a copy of the real nodes within the context.
  2313.     
  2314.         This function is most useful to make a backup of the context
  2315.         memory map before altering it. In case any of the modifications
  2316.         fail, you are able to undo all modifications completely with
  2317.         a call to SetPropertyList() - which can't fail. 
  2318.  
  2319.         To give an example:
  2320.  
  2321.         /* make a backup of the context how it looks now */
  2322.  
  2323.         LockMMUContext(ctx);
  2324.  
  2325.         if (list=GetMapping(ctx)) {
  2326.             fine=TRUE;
  2327.  
  2328.             /* Try to alter it, step by step. */
  2329.  
  2330.             if (!SetProperties(...)) 
  2331.                 fine=FALSE;
  2332.  
  2333.             if (!SetProperties(...))
  2334.                 fine=FALSE;
  2335.  
  2336.             /* etc, etc.... */
  2337.  
  2338.             /* Oops, we failed! Re-install the old setup. */
  2339.             if (!fine) 
  2340.                 SetPropertyList(ctx,list);
  2341.         }
  2342.         
  2343.         ReleaseMapping(ctx,list);
  2344.         UnlockMMUContext(ctx);
  2345.         /* and so on... */
  2346.  
  2347.         Note that you've still to call ReleaseContextList(), even in
  2348.         case of failure when you've already re-installed backup property
  2349.         list.
  2350.  
  2351.     BUGS
  2352.  
  2353.     SEE ALSO
  2354.         ReleaseMapping(), SetPropertyList(), mmu/context.h
  2355. mmu.library/ReleaseMapping                            mmu.library/ReleaseMapping
  2356.  
  2357.     NAME
  2358.         ReleaseMapping     -    get access to the memory map
  2359.  
  2360.     SYNOPSIS
  2361.         ReleaseMapping( context , list );
  2362.                          a0           a1
  2363.  
  2364.         void ReleaseMapping( struct MMUContext * , struct MinList * );
  2365.  
  2366.     FUNCTION
  2367.         This function releases the list of MapNodes arbitrated by 
  2368.         GetMapping.
  2369.  
  2370.     INPUTS
  2371.         context - the context the nodes where taken from.
  2372.         list    - the backup property list to release.
  2373.  
  2374.     RETURNS
  2375.  
  2376.     NOTES
  2377.         This function *MUST* be called, even in case the property list
  2378.         was re-installed with SetPropertyList().
  2379.  
  2380.     BUGS
  2381.  
  2382.     SEE ALSO
  2383.         NewMapping(), GetMapping(), SetPropertyList()
  2384.  
  2385. mmu.library/NewMapping                                mmu.library/NewMapping
  2386.  
  2387.     NAME
  2388.         NewMapping            -    build a new memory map
  2389.  
  2390.     SYNOPSIS
  2391.         list = NewMapping ( );
  2392.         d0
  2393.  
  2394.         struct MinList * NewMapping ( void );
  2395.  
  2396.     FUNCTION
  2397.         Build and initialize a new memory map list. All addresses in this
  2398.         list will be marked as MAPP_BLANK.
  2399.  
  2400.     INPUTS
  2401.         nothing.
  2402.  
  2403.     RESULTS
  2404.         a MinList structure, initialized with MapNodes representing a
  2405.         completely blank memory layout or NULL on failure. You either need 
  2406.         to copy the layout from a context with CopyContextRegion(), or 
  2407.         define your own layout with calls to SetMappingPropertiesA().
  2408.  
  2409.     NOTES
  2410.         Don't forget to release the list (and its contents) with 
  2411.         ReleaseMapping() when you're done.
  2412.  
  2413.     BUGS
  2414.  
  2415.     SEE ALSO
  2416.         CopyContextRegion(), SetMappingPropertiesA(), ReleaseMapping(),
  2417.         GetMapping()
  2418.  
  2419. mmu.library/CopyMapping                                mmu.library/CopyMapping
  2420.  
  2421.     NAME
  2422.         CopyMapping            -    transfer memory properties between lists
  2423.  
  2424.     SYNOPSIS
  2425.         fine = CopyMapping ( from , to , base , length , mask );
  2426.         d0                     a0        a1     d0        d1         d2        
  2427.  
  2428.  
  2429.         BOOL CopyMapping ( struct MinList * , struct MinList * ,
  2430.  
  2431.                              ULONG , ULONG , ULONG );
  2432.  
  2433.     FUNCTION
  2434.         Copy the memory properties from one memory map to another, thru
  2435.         a mask.
  2436.  
  2437.     INPUTS
  2438.         from    -    the memory map which is (partially) to be transfered.
  2439.         to        -    the destination of the copy operation.
  2440.         base    -    base address. Memory properties will be copied starting
  2441.                     at this address.
  2442.         length    -    length of the memory region in bytes whose properties
  2443.                     shall be transfered.
  2444.         mask    -    a mask of property bits which are to be transfered. A
  2445.                     zero bit in this mask indicates that the corresponding
  2446.                     property in the destination will not be touched. For
  2447.                     all the properties, check the SetPropertiesA() function.
  2448.  
  2449.     RESULTS
  2450.         a boolean success/failure indicator. It is TRUE in case the 
  2451.         operation was performed, FALSE otherwise. The destination will
  2452.         not have been touched at all in this case.
  2453.  
  2454.     NOTES
  2455.         this call does not copy memory. It just copies memory attributes
  2456.         from one memory map to another.
  2457.  
  2458.         Check CopyContextRegion() to copy the properties from a context
  2459.         instead from a list.
  2460.  
  2461.         Since this call is not context based, the library will not be able
  2462.         to perform checks for correct page alignment, you have to do that
  2463.         yourself. Especially, note that SetPropertyList() - which attaches
  2464.         a memory map to a context - does not perform any check on this
  2465.         list either. Hence, *NOT* checking for page alignment here might
  2466.         result in an invalid context if you try to attach an incorrectly
  2467.         aligned list to a context later on. 
  2468.  
  2469.     BUGS
  2470.  
  2471.     SEE ALSO
  2472.         SetPropertyList(), ReleaseMapping(), DupMapping(), SetPropertiesA(),
  2473.         CopyContextRegion()
  2474.  
  2475. mmu.library/DupMapping                                mmu.library/DupMapping
  2476.  
  2477.     NAME
  2478.         DupMapping            -    make a one-to-one copy of a memory map
  2479.  
  2480.     SYNOPSIS
  2481.         dup = DupMapping ( list );
  2482.         d0                    a0
  2483.  
  2484.         struct MinList * DupMapping( struct MinList * );
  2485.  
  2486.     FUNCTION
  2487.         this call builds an identical copy of the memory map passed in.
  2488.  
  2489.     INPUTS
  2490.         list    -    the memory map to be copied.
  2491.  
  2492.     RESULTS
  2493.         another memory list, identical to the list passed in, or NULL on
  2494.         failure.
  2495.  
  2496.     NOTES
  2497.         Don't forget to release the memory list with ReleaseMapping()
  2498.         if you're done with it. You need to release both, the original as
  2499.         well as the duplicate.
  2500.         In case you want to make a copy of the memory map of a context,
  2501.         use GetMapping() instead.
  2502.  
  2503.     BUGS
  2504.  
  2505.     SEE ALSO
  2506.         GetMapping(), ReleaseMapping()
  2507.  
  2508. mmu.library/CopyContextRegion                    mmu.library/CopyContextRegion
  2509.  
  2510.     NAME
  2511.         CopyContextRegion    -    transfer properties from a context to a list
  2512.  
  2513.     SYNOPSIS
  2514.         fine = CopyContextRegion ( ctx, list, base, length, mask );
  2515.         d0                            a0   a1       d0     d1         d2
  2516.  
  2517.         BOOL CopyContextRegion ( struct MMUContext *, struct MinList *,
  2518.                                  
  2519.                                  ULONG, ULONG, ULONG );
  2520.  
  2521.     FUNCTION
  2522.         Copy the properties of a memory region defined by a context to 
  2523.         another memory map, thru a mask.
  2524.  
  2525.     INPUTS
  2526.         ctx        -    source context whose memory map shall be transfered.
  2527.         list    -    the destination memory map which is to be altered.
  2528.         base    -    base address of the memory region whose properties are
  2529.                     to be copied.
  2530.         length    -    length of the memory region in bytes whose properties
  2531.                     will be transfered.
  2532.         mask    -    a mask of property bits, see the SetPropertiesA() 
  2533.                     function for a detailed explanation. A zero bit in this
  2534.                     mask means that the corresponding property in the 
  2535.                     destination will be left alone and will remain unchanged.
  2536.  
  2537.     RESULTS
  2538.         a boolean success/failure indicator, TRUE for success. On failure,
  2539.         the destination memory map will not have been touched at all.
  2540.  
  2541.     NOTES
  2542.         This call does not copy memory at all, it just defines the memory
  2543.         properties of a given memory map from that of a given context.
  2544.  
  2545.         Check CopyMapping() to transport memory properties from one list
  2546.         to another.
  2547.  
  2548.         Since this call is not context based, the library will not be able
  2549.         to perform checks for correct page alignment, you have to do that
  2550.         yourself. Especially, note that SetPropertyList() - which attaches
  2551.         a memory map to a context - does not perform any check on this
  2552.         list either. Hence, *NOT* checking for page alignment here might
  2553.         result in an invalid context if you try to attach an incorrectly
  2554.         aligned list to a context later on. 
  2555.  
  2556.     BUGS
  2557.  
  2558.     SEE ALSO
  2559.         SetPropertyList(), ReleaseMapping(), SetPropertiesA(),
  2560.         SetPropertiesMapping()
  2561.  
  2562. mmu.library/SetPropertiesMapping                mmu.library/SetPropertiesMapping
  2563.  
  2564.     NAME
  2565.         SetPropertiesMapping    -    transfer properties from a map list 
  2566.                                     to a context
  2567.  
  2568.     SYNOPSIS
  2569.         fine = SetPropertiesMapping ( ctx, list, base, length, mask );
  2570.         d0                              a0   a1     d0        d1        d2
  2571.  
  2572.         BOOL SetPropertiesMapping ( struct MMUContext *, struct MinList *,
  2573.                                  
  2574.                                  ULONG, ULONG, ULONG );
  2575.  
  2576.     FUNCTION
  2577.         Copy the properties of a memory map to a context, thru a mask.
  2578.         This is equivalent to SetPropertiesA(), except that the source
  2579.         data is contained in a memory map instead given as function
  2580.         arguments. This function is reverse to CopyContextRegion().
  2581.  
  2582.     INPUTS
  2583.         ctx        -    destination context whose memory map shall be set.
  2584.         list    -    the source memory map, containing the data to be 
  2585.                     transfered.
  2586.         base    -    base address of the memory region whose properties are
  2587.                     to be copied.
  2588.         length    -    length of the memory region in bytes whose properties
  2589.                     will be transfered.
  2590.         mask    -    a mask of property bits, see the SetPropertiesA() 
  2591.                     function for a detailed explanation. A zero bit in this
  2592.                     mask means that the corresponding property in the 
  2593.                     destination will be left alone and will remain unchanged.
  2594.  
  2595.     RESULTS
  2596.         a boolean success/failure indicator, TRUE for success. On failure,
  2597.         the destination context will not have been touched at all.
  2598.  
  2599.     NOTES
  2600.         This call does not copy memory at all, it just defines the memory
  2601.         properties of the context passed in.
  2602.  
  2603.         Check CopyMapping() to transport memory properties from one list
  2604.         to another, or CopyContextRegion() to transfer properties from a
  2605.         context to a list (the other direction).
  2606.  
  2607.         The library will not be able to perform checks for correct page 
  2608.         alignment, you have to do that yourself. 
  2609.     BUGS
  2610.  
  2611.     SEE ALSO
  2612.         SetPropertyList(), ReleaseMapping(), SetPropertiesA(),
  2613.         CopyContextRegion()
  2614.  
  2615. mmu.library/SetMappingPropertiesA            mmu.library/SetMappingPropertiesA
  2616.  
  2617.     NAME
  2618.         SetMappingPropertiesA    -    set memory attributes in a memory map.
  2619.  
  2620.     SYNOPSIS
  2621.  
  2622.         result = SetMappingPropertiesA( list, flags, mask, lower, size, tags);
  2623.         d0                                 a0        d1      d2    a1        d0      a2
  2624.  
  2625.         int SetMappingPropertiesA( struct MinList *, ULONG, ULONG, 
  2626.                                    ULONG, ULONG, struct TagItem *);
  2627.  
  2628.  
  2629.         result = SetMappingProperties( list, flags, mask, 
  2630.                                        lower, size, tag1, ...);
  2631.  
  2632.         int SetMappingProperties( struct MinList *, ULONG, ULONG, 
  2633.                                   ULONG, ULONG, Tag tag1, ...);
  2634.  
  2635.     FUNCTION
  2636.         This call sets attributes of a certain memory range of a given
  2637.         memory map.
  2638.  
  2639.     INPUTS
  2640.         list     - a minlist structure keeping the memory map to be altered.
  2641.         flags    - a binary flags field for the attributes to define. Check
  2642.                   SetProperties() for details about the defined bits.
  2643.         mask    - A bit mask of the attributes to be changed.
  2644.         lower    - The lower boundary of the logical address to be modified. 
  2645.         size    - Size of the region to be modified. 
  2646.         tags    - A tag array with additional data, identical to the
  2647.                   tags defined for SetPropertiesA().
  2648.  
  2649.     RESULTS
  2650.         Unlike SetPropertiesA() or SetPagePropertiesA(), this does not
  2651.         return a boolean value! The result code is 0 on failure, and
  2652.         different from zero on success, though. To be more precise, this
  2653.         routine will return "1" in case of success, and "2" in case the
  2654.         memory map was really altered and is now "dirty", hence upper
  2655.         software layers might require a "rebuild".
  2656.  
  2657.     NOTES
  2658.         This call really doesn't do anything to the MMU, it is just an
  2659.         administration call to modify a memory map - a handy data structure
  2660.         you might want to use for your own memory administration. Its
  2661.         context-based equivalent SetPropertiesA() will, hence, adjust the
  2662.         memory map which is kept by a context, and SetPagePropertiesA()
  2663.         will perform the same operation truely on the hardware.
  2664.  
  2665.         Since this call is not context based, the library will not be able
  2666.         to perform checks for correct page alignment, you have to do that
  2667.         yourself. Especially, note that SetPropertyList() - which attaches
  2668.         a memory map to a context - does not perform any check on this
  2669.         list either. Hence, *NOT* checking for page alignment here might
  2670.         result in an invalid context if you try to attach an incorrectly
  2671.         aligned list to a context later on. 
  2672.  
  2673.     BUGS
  2674.  
  2675.     SEE ALSO
  2676.         SetPropertyList(), ReleaseMapping(), SetPropertiesA(),
  2677.         SetPagePropertiesA(), GetMappingPropertiesA()
  2678.  
  2679. mmu.library/GetMappingPropertiesA            mmu.library/GetMappingPropertiesA
  2680.  
  2681.     NAME
  2682.         GetMappingPropertiesA     - read memory attributes from a memory map.
  2683.  
  2684.     SYNOPSIS
  2685.  
  2686.         flags = GetMappingPropertiesA( list, lower, tags);
  2687.         d0                                a0      a1     a2
  2688.  
  2689.         ULONG GetMappingPropertiesA( struct MinList *, ULONG, 
  2690.                                      struct TagItem *);
  2691.  
  2692.         result = GetMappingProperties( list, lower, tag1, ...);
  2693.  
  2694.         ULONG GetMappingProperties( struct MinList *, ULONG, Tag tag1, ...);
  2695.  
  2696.     FUNCTION
  2697.         This call reads the page properties of a certain address in
  2698.         memory from a memory map. It is the counterpart of 
  2699.         SetMappingPropertiesA() and the memory map analogue of 
  2700.         GetPropertiesA().
  2701.  
  2702.     INPUTS
  2703.         list    -    a MinList holding the memory map, obtained from either
  2704.                     GetMapping(), DupMapping() or NewMapping().
  2705.         lower    -     the logical address of the address to investigate. 
  2706.         tags    -   additional tags, identical to those defined for
  2707.                     GetPropertiesA(). Check the documentation of this
  2708.                     function for details.
  2709.  
  2710.     RESULTS
  2711.         Returns a binary flags field for the attributes to define. See
  2712.         SetPropertiesA() for details. 
  2713.  
  2714.     NOTES
  2715.         This call is the analogue of the GetPropertiesA() call. It operates
  2716.         directly on memory maps, unlike the former which operates only on
  2717.         the memory map of a context. This function does not require page 
  2718.         alignment because the mmu.library does not have a context to check
  2719.         the alignment restrictions, but you should note that a memory map
  2720.         that is to be attached to a context with DefineMapping() *HAS* to
  2721.         be correctly aligned.
  2722.  
  2723.         This routine is *NOT* safe to be called from within interrupts.
  2724.  
  2725.     BUGS
  2726.  
  2727.     SEE ALSO
  2728.         SetMappingPropertiesA(), SetPropertiesA(), GetPagePropertiesA(),
  2729.         GetPropertiesA()
  2730.  
  2731. mmu.library/SetPropertyList                        mmu.library/SetPropertyList
  2732.  
  2733.     NAME
  2734.         SetPropertyList        -    re-install a backup memory map
  2735.  
  2736.     SYNOPSIS
  2737.         SetPropertyList ( context, list );
  2738.                             a0        a1
  2739.  
  2740.         void SetPropertyList ( struct MMUContext * , struct MinList * );
  2741.  
  2742.     FUNCTION
  2743.         This call re-installes a property list, i.e. a complete memory
  2744.         map of a context, obtained from GetMapping() before.
  2745.     
  2746.     INPUTS
  2747.         context        -    the context the list should be installed in.
  2748.                         This should be the same context the list was
  2749.                         taken from.
  2750.         list        -    the property list to install. 
  2751.  
  2752.         This list *MUST* have been obtained with GetMapping() before.
  2753.  
  2754.     RESULTS
  2755.         Nothing. The big advantage of this call is that it cannot fail.
  2756.  
  2757.     NOTES
  2758.         The property list will become part of the context and is empty
  2759.         after this call. You can't re-use it for that reason. However,
  2760.         you still need to call ReleaseMapping() with the list pointer
  2761.         you've obtained before.
  2762.  
  2763.         For additional tips how this function should be used, see the
  2764.         GetMapping() function; especially, you can only un-do changes
  2765.         to the software abstraction level of a MMU-tree, and only as
  2766.         long as you haven't called RebuildTree() to translate these
  2767.         into hardware MMU tables. Trying to un-do these changes with
  2768.         SetPropertyList() will fail, and it will even fail if you call
  2769.         RebuildTree() afterwards. SetPropertyList() *does not* inform
  2770.         the software abstraction level about any changes, it is just a
  2771.         quick un-do operation. (For the experts: It even re-installs
  2772.         the "dirty" flags).
  2773.  
  2774.     BUGS
  2775.         
  2776.     SEE ALSO
  2777.         GetMapping(), ReleaseMapping(), RebuildTree()
  2778.  
  2779. mmu.library/LockContext                                mmu.library/LockContext
  2780.  
  2781.     NAME
  2782.         LockContext - arbitrate a MMUContext for exclusive access
  2783.  
  2784.     SYNOPSIS
  2785.         LockContext( context );
  2786.                         a0
  2787.  
  2788.         void LockContext( struct MMUContext * );
  2789.  
  2790.     FUNCTION
  2791.         Locks a context from modification by any task except the calling
  2792.         task, i.e. implements a semaphore protection for the context
  2793.         passed in.
  2794.  
  2795.     INPUTS
  2796.         context - the context to enter or NULL for the current context.
  2797.  
  2798.     RETURNS
  2799.  
  2800.     NOTES
  2801.         This lock includes locking the memory map by GetMapping(). It is
  2802.         therefore safe to call GetMapping() while holding a context lock.
  2803.  
  2804.         The lock must be released later on with UnlockContext().
  2805.  
  2806.     BUGS
  2807.  
  2808.     SEE ALSO
  2809.         UnlockContext()
  2810. mmu.library/UnlockContext                            mmu.library/UnlockContext
  2811.  
  2812.     NAME
  2813.         UnlockContext - release a MMUContext lock
  2814.  
  2815.     SYNOPSIS
  2816.         UnlockContext( context );
  2817.                         a0
  2818.  
  2819.         void UnlockContext( struct MMUContext * );
  2820.  
  2821.     FUNCTION
  2822.         Releases a lock to a MMUContext arbitrated by LockContext().
  2823.  
  2824.     INPUTS
  2825.         context - the context to enter or NULL for the current context.
  2826.  
  2827.     RETURNS
  2828.  
  2829.     NOTES
  2830.  
  2831.     BUGS
  2832.  
  2833.     SEE ALSO
  2834.         LockContext()    
  2835. mmu.library/GetMMUType                                    mmu.library/GetMMUType
  2836.  
  2837.     NAME
  2838.         GetMMUType - return the type of the MMU available in the system.
  2839.  
  2840.     SYNOPSIS
  2841.         mmu = GetMMUType( );
  2842.                         
  2843.  
  2844.         char GetMMUType( void );
  2845.  
  2846.     FUNCTION
  2847.         Returns an identifier for the MMU available in the system or
  2848.         NUL in case no MMU is installed.
  2849.  
  2850.     INPUTS
  2851.  
  2852.     RETURNS
  2853.         a character identifying the MMU type:
  2854.  
  2855.         MUTYPE_NONE                    no working MMU detected.
  2856.         MUTYPE_68851                a 68020 system with an external 68851
  2857.                                     MMU.
  2858.         MUTYPE_68030                a 68030 MMU.
  2859.         MUTYPE_68040                the internal 68040 MMU.
  2860.         MUTYPE_68060                the 68060 MMU.
  2861.  
  2862.     NOTES
  2863.         The mmu library is smart enough to detect EC processors without a
  2864.         working MMU, but the library does not detect multiple CPUs in the
  2865.         system. (How?)
  2866.  
  2867.     BUGS
  2868.  
  2869.     SEE ALSO
  2870.         mmu/mmubase.h
  2871. mmu.library/SuperContext                            mmu.library/SuperContext
  2872.  
  2873.     NAME
  2874.         SuperContext - find the supervisor context for a given context.
  2875.  
  2876.     SYNOPSIS
  2877.         super = SuperContext( context );
  2878.         d0                        a0                        
  2879.  
  2880.         struct MMUContext * SuperContext( struct MMUContext * );
  2881.  
  2882.     FUNCTION
  2883.         Returns the context that manages the supervisor mode for the user
  2884.         mode context passed in.
  2885.  
  2886.     INPUTS
  2887.         A user mode context or NULL for the current context.
  2888.  
  2889.     RETURNS
  2890.         A pointer to the context managing the supervisor type accesses with-
  2891.         in the current context.
  2892.  
  2893.     NOTES
  2894.         All contexts build by CreateMMUContext are by default user mode
  2895.         contexts. The current version of the library manages one global
  2896.         supervisor tree, and optionally private supervisor trees for private
  2897.         contexts if you ask for one on context creation. This is different 
  2898.         to former releases!
  2899.     
  2900.         To find the public supervisor mode context, call DefaultContext() 
  2901.         first and pass in its return value to this function.
  2902.  
  2903.     BUGS
  2904.  
  2905.     SEE ALSO
  2906.         DefaultContext(), CreateMMUContext()
  2907.  
  2908. mmu.library/DefaultContext                            mmu.library/DefaultContext
  2909.  
  2910.     NAME
  2911.         DefaultContext    -    get the global default context
  2912.  
  2913.     SYNOPSIS
  2914.         public = DefaultContext( );
  2915.         d0
  2916.  
  2917.         struct MMUContext * DefaultContext( void );
  2918.  
  2919.     FUNCTION
  2920.         Returns the global default user mode context which is used for
  2921.         tasks that are not attached to any other private context.
  2922.  
  2923.     INPUTS
  2924.  
  2925.     RETURNS
  2926.         A pointer to the context managing the user mode accesses for
  2927.         "context less" tasks.
  2928.  
  2929.     NOTES
  2930.         A task is by default part of this default context unless you
  2931.         call EnterMMUContext() and attach it to a different context.
  2932.  
  2933.         Note that you might have to enter even the default context
  2934.         explicitly to be able to use certain features of the exception
  2935.         hook mechanism.
  2936.  
  2937.     BUGS
  2938.  
  2939.     SEE ALSO
  2940.         SuperContext()
  2941. mmu.library/WithoutMMU                                mmu.library/WithoutMMU
  2942.  
  2943.     NAME
  2944.         WithoutMMU - execute a short subroutine with the MMU disabled.
  2945.  
  2946.     SYNOPSIS
  2947.         result = WithoutMMU( userFunc );
  2948.         d0                     a5
  2949.  
  2950.         ULONG WithoutMMU(void *);
  2951.  
  2952.     FUNCTION
  2953.         Executes a small assembly language routine pointed to in a5
  2954.         in supervisor mode, with all interrupts disabled, and the MMU
  2955.         disabled. All registers are preserved by this call.
  2956.         The function must end with an RTS instruction.
  2957.  
  2958.     INPUTS
  2959.         userFunc    -    A pointer to a *short* assembly language routine,
  2960.                         ending with RTS. The function has full access to
  2961.                         all registers.
  2962.  
  2963.     RETURNS
  2964.         whatever was left in register d0 by the called function.
  2965.  
  2966.     NOTES
  2967.         This is a low-level function. Remember that disabling the MMU
  2968.         might or might not be what you want, especially if memory is
  2969.         remapped.
  2970.  
  2971.     BUGS
  2972.         Big trouble if the supervisor stack is in remapped memory.
  2973.  
  2974.     SEE ALSO
  2975.         exec/Supervisor()
  2976. mmu.library/SetBusError                                mmu.library/SetBusError
  2977.  
  2978.     NAME
  2979.         SetBusError - define the bus error handler.
  2980.  
  2981.     SYNOPSIS
  2982.         SetBusError ( newfuncptr , oldfuncptrptr );
  2983.         d0                a0                a1
  2984.  
  2985.  
  2986.         void SetBusError ( void (*)() , void (**)() );
  2987.  
  2988.     FUNCTION
  2989.         This defines the bus error handler which is called in case the
  2990.         MMU library exception handler was not able to handle the fault.
  2991.  
  2992.         This happens for true physical bus errors, errors initiated by
  2993.         the unsupported TAS, CAS and CAS2 instructions using "locked
  2994.         transfers" not supported by the amiga hardware, and MOVE16 in-
  2995.         structions causing an access fault.
  2996.  
  2997.         The default bus error handler is whatever the library finds in
  2998.         the autovectors of the CPU when starting up. It is usually the
  2999.         exec fault handler which presents the nice guru 80000002.
  3000.  
  3001.     INPUTS
  3002.         newfuncptr    -    A pointer to the new bus error handler. It is
  3003.                         called without any parameters in supervisor state, 
  3004.                         with the exception stack frame on the stack.
  3005.         oldfuncptrptr -    A pointer to a pointer filled in with the previously
  3006.                         defined handler, or NULL.
  3007.  
  3008.     RETURNS
  3009.  
  3010.     NOTES
  3011.         The function pointer is guaranteed to be flushed to memory by
  3012.         the library, the function pointer pointer could be used, for
  3013.         example, to modify the destination of a JMP instruction.
  3014.  
  3015.         The bus error handler *MUST BE IMMEDIATELY* ready for run after
  3016.         this function has to be called.
  3017.  
  3018.         This is a low-level function. You do not want to call it.
  3019.  
  3020.     BUGS
  3021.  
  3022.     SEE ALSO
  3023.  
  3024. mmu.library/GetMMUContextData                    mmu.library/GetMMUContextData
  3025.  
  3026.     NAME
  3027.         GetMMUContextData - read MMUContext specific data
  3028.  
  3029.     SYNOPSIS
  3030.         GetMMUContextData ( ctx , id );
  3031.         d0                    a0    d0
  3032.  
  3033.         ULONG GetMMUContextData ( struct MMUContext * , ULONG );
  3034.  
  3035.     FUNCTION
  3036.         This function reads various parameters of the MMU context,
  3037.         indexed by an ID from mmu/mmutags.h. All legal tag items
  3038.         of CreateMMContext() are available, plus the following:
  3039.  
  3040.             MGXTAG_PAGESIZE        -        Return the page size in bytes
  3041.                                         of the input context. Unlike
  3042.                                         MCXTAG_PAGEBITS, this is *NOT*
  3043.                                         an exponent. This is identical
  3044.                                         to GetPageSize().
  3045.  
  3046.             MGXTAG_REMAPSIZE    -        Returns the alignment restriction
  3047.                                         for remapped memory to be added to
  3048.                                         the exec memory free list. This is
  3049.                                         identical to RemapSize().
  3050.  
  3051.             MGXTAG_ROOT            -        Return the pointer to the root of
  3052.                                         the MMU tree. You have to cast the
  3053.                                         result to an ULONG *. 
  3054.                                         Note that you DO NOT WANT to modify 
  3055.                                         this tree directly.
  3056.  
  3057.             MGXTAG_CONFIG        -        Returns the pointer to a 
  3058.                                         struct MMUConfig * specifying the
  3059.                                         complete MMU configuration for 
  3060.                                         this context. You usually DO NOT
  3061.                                         NEED to touch this.
  3062.  
  3063.     INPUTS
  3064.         ctx        -        A pointer to a struct MMUContext *.
  3065.  
  3066.         id        -        An ID specifying which data you want to read.
  3067.                         NOTE THAT THIS IS NOT A TAG LIST, but just the
  3068.                         tag item id from mmutags.h.
  3069.     RETURNS
  3070.         the data requested. You need to cast it to the correct type.
  3071.  
  3072.     NOTES
  3073.  
  3074.     BUGS
  3075.  
  3076.     SEE ALSO
  3077.         CreateMMUContext(), mmu/config.h
  3078.     
  3079. mmu.library/SetMMUContextDataA                mmu.library/SetMMUContextDataA
  3080.  
  3081.     NAME
  3082.         SetMMUContextDataA - define MMU context specifications on the fly
  3083.  
  3084.     SYNOPSIS
  3085.         SetMMUContextDataA ( ctx , tags );
  3086.                              a0    a1
  3087.  
  3088.         SetMMUContextData ( ctx , ... );
  3089.  
  3090.  
  3091.         void SetMMUContextDataA ( struct MMUContext * , struct TagItem * );
  3092.  
  3093.         void SetMMUContextData ( struct MMUContext * , Tag tag1 , ... );
  3094.  
  3095.     FUNCTION
  3096.         This function allows to adjust *some* of the MMUContext 
  3097.         specifications on the fly. The following tag items of the 
  3098.         CreateMMUContextA() call are supported:
  3099.  
  3100.             MCXTAG_BLANKFILL    -        define the data to read from the
  3101.                                         dummy "blank" pages. Note that
  3102.                                         a *working* program should never
  3103.                                         read this data.
  3104.  
  3105.             MCXTAG_MEMORYATTRS    -        define the memory attributes the
  3106.                                         MMU tables will be allocated from.
  3107.                                         This will *NOT* reallocate the MMU
  3108.                                         tables already build, cf. 
  3109.                                         exec/memory.h
  3110.  
  3111.             MCXTAG_EXECBASE        -        specify whether or not page 0 will
  3112.                                         be threated specially and accesses
  3113.                                         to the first Kbyte should be
  3114.                                         emulated. If set to FALSE, the 
  3115.                                         first page will be threated as all
  3116.                                         other pages.
  3117.  
  3118.             MCXTAG_ZEROBASE        -        Specify a base address for where 
  3119.                                         possibly emulated zero page accesses
  3120.                                         have to be redirected to. This address
  3121.                                         is usually ignored unless the zero-
  3122.                                         page is invalidated and MCXTAG_EXEBASE
  3123.                                         is TRUE. For the messy details, check
  3124.                                         the CreateMMUContext() autodocs.
  3125.  
  3126.         No other tag items are valid here.
  3127.  
  3128.     INPUTS
  3129.         ctx        -        A pointer to a struct MMUContext *.
  3130.  
  3131.         tags    -        A tag list containing the parameters to be
  3132.                         adjusted.
  3133.     RETURNS
  3134.  
  3135.     NOTES
  3136.  
  3137.     BUGS
  3138.  
  3139.     SEE ALSO
  3140.         CreateMMUContext(), exec/memory.h
  3141.  
  3142. mmu.library/BuildIndirect                            mmu.library/BuildIndirect
  3143.  
  3144.     NAME
  3145.         BuildIndirect        -    build a true hardware page descriptor.
  3146.  
  3147.     SYNOPSIS
  3148.         descr = BuildIndirect ( ctx , address , props );
  3149.         d0                        a0        d0          d1
  3150.  
  3151.         ULONG    BuildIndirect ( struct MMUContext * , ULONG , ULONG );
  3152.  
  3153.     FUNCTION
  3154.         This function builds a true hardware page descriptor, to be used for
  3155.         the MAPP_INDIRECT property. 
  3156.  
  3157.     INPUTS
  3158.         ctx        -    the MMUContext handle in which this descriptor is to
  3159.                     be used as the destination of a MAPP_INDIRECT descriptor.
  3160.  
  3161.         address    -    in case this descriptor is "valid", this is the 
  3162.                     PHYSICAL destination address, to be told to the MMU, to
  3163.                     which accesses will be redirected to. Unlike 
  3164.                     SetPropertiesA(), there is *NO* MAPP_REMAPPED bit. In
  3165.                     case you do not want remapping, set this to the logical
  3166.                     address. DO NOT LEAVE THIS BLANK or accesses will be
  3167.                     redirected to address 0 - which is most likely not want
  3168.                     you want. Note that this address must be, as all other
  3169.                     addresses the MMU cares about, page aligned!
  3170.                     In case this descriptor is of invalid type, the address
  3171.                     can be used for your purposes, but note that this MUST
  3172.                     STILL be a number which is page aligned for the given
  3173.                     context. It *MAY NOT* be arbitrary.
  3174.                 
  3175.         props    -    Properties for the descriptor to be defined.
  3176.                     NOTE THAT THIS IS A TRUE HARDWARE DESCRIPTOR! The
  3177.                     library WILL NOT BE ABLE to help you out by emulating
  3178.                     missing features of one MMU or another. Instead, it will
  3179.                     just ignore them. This means for you, specifically, 
  3180.                     that only a minor subset of the usual properties may be
  3181.                     used safely here, and that parsing the hardware 
  3182.                     properties later on with GetIndirect() might result in
  3183.                     different properties than you intended because of
  3184.                     missing features of the MMU in use. To be precise, the
  3185.                     following properties *might* be available - meaning that
  3186.                     all others ARE NOT!
  3187.  
  3188.                 MAPP_WRITEPROTECTED     -    The page will be write protected. 
  3189.                     Writes to this area will cause a segmentation fault.
  3190.  
  3191.                 MAPP_USED                -    The "used" bit of the pages
  3192.                     will be set. The CPU will set this bit automatically
  3193.                     as soon as the pages are accessed.
  3194.  
  3195.                 MAPP_MODIFIED            -    The "modified" bit of the pages
  3196.                     will be set. The CPU will set this bit automatically
  3197.                     as soon as a write is performed to the page in question.
  3198.                     DO NOT SET THIS BIT TOGETHER WITH MAPP_WRITEPROTECTED
  3199.                     OR WITHOUT MAPP_USED or the CPU might hang. 
  3200.  
  3201.                 MAPP_INVALID            -    The page will be marked as 
  3202.                     invalid. Accessing it will invoke the bus error hook.
  3203.                     See below for how to mark this page as REMAIRABLE. Note
  3204.                     that the MAPP_REPAIRABLE bit is *here* not available.
  3205.  
  3206.                 MAPP_SWAPPED            -    The page will be marked as
  3207.                     swapped out. This is for this kind of descriptors 
  3208.                     identical to MAPP_INVALID and will be read as such
  3209.                     later on.
  3210.  
  3211.                 MAPP_CACHEINHIBIT        -    The page will be marked as non-
  3212.                     cacheable.
  3213.  
  3214.                 MAPP_IMPRECISEEXECPTION    -    The page will be marked as 
  3215.                     "imprecise exception". MAPP_CACHEINHIBIT is mandatory
  3216.                     in this case or this flag does nothing. Only avail-
  3217.                     able for the 060, ignored and read as zero 
  3218.                     by all others.
  3219.  
  3220.                 MAPP_NONSERIALIZED        -    The page will be marked as
  3221.                     serialized. MAPP_CACHEINHIBIT is mandatory if this
  3222.                     property is selected. Only available for the 040, 
  3223.                     ignored and read as zero by all others.
  3224.  
  3225.                 MAPP_COPYBACK            -    The page will be marked as
  3226.                     "copyback" instead of "writethrough". Generally re-
  3227.                      commended since this is faster for the '40 and '60.
  3228.                     MAPP_CACHEINHIBIT *MUST* be disabled for this to work.
  3229.                     Only available for the 040 and 060, ignored and read
  3230.                     as zero by others.
  3231.  
  3232.                 MAPP_USERPAGE0            -    Set user page attribute 0,
  3233.                     only available for the 040 and 060, ignored and read
  3234.                     as zero by all others.
  3235.                     The status of this bit appears on special pins of the
  3236.                     CPU and might be required by some hardware, so don't     
  3237.                     play with this. 
  3238.  
  3239.                 MAPP_USERPAGE1            -    Set user page attribute 1,
  3240.                     see above for details.
  3241.  
  3242.                 MAPP_GLOBAL                -    DIFFERENT TO SetProperties()
  3243.                     and others! 
  3244.                     Set the GLOBAL bit in the page descriptor, only avail-
  3245.                     able for the 040 and 060, ignored and read as zero by
  3246.                     all others. 
  3247.                     Setting this bit means that certain specialized 
  3248.                     instructions will not flush this descriptor from the
  3249.                     cache (the ATC) of the MMU.
  3250.                     The mmu.library writes only descriptors without this
  3251.                     bit set and does not use these instructions. It will
  3252.                     always flush descriptors independent of the G bit.
  3253.                     There is little use of this bit.
  3254.  
  3255.     RESULTS
  3256.         a page descriptor for the current MMU in use, designed and to be
  3257.         used for as the destination of an MAPP_INDIRECT descriptor. NOT
  3258.         to be used as a true page descriptor, and NOT to be used as a 
  3259.         table descriptor.
  3260.         In case the library finds no MMU or the alignment restrictions 
  3261.         aren't satisfied, it will return BAD_DESCRIPTOR (0x03), it 
  3262.         WILL NOT return NULL as this is a "valid invalid" descriptor.
  3263.             
  3264.     NOTES
  3265.         Note specifically that MAPP_SUPERVISORONLY *IS NOT* supported. The
  3266.         mmu.library enforces a distinct user/supervisor model and as such
  3267.         you might want to install an invalid descriptor into the user table
  3268.         and a valid descriptor into the supervisor table to emulate this
  3269.         feature. True "supervisor only" descriptors are available for the
  3270.         040 and 060 anyways, but this "emulation" works for all MMUs.
  3271.  
  3272.         MAPP_REMAPPED is not supported either because you have to specify
  3273.         a physical destination address in all cases, even if no remapping
  3274.         has to be performed. Use the logical address as physical address in
  3275.         case remapping is not desired.
  3276.  
  3277.         MAPP_REPAIRABLE is not available because this flag is in fact an
  3278.         emulation provided by the library. However, you may make access 
  3279.         faults to this page repairable by setting the MAPP_REPAIRABLE bit
  3280.         for the MAPP_INDIRECT descriptor that POINTS to the descriptor 
  3281.         you're building by this call. This will be enough to inform the
  3282.         library about how to treat access faults.
  3283.         
  3284.  
  3285.         How to use this function:
  3286.  
  3287.         Allocate four bytes of memory, long-word aligned, and gets its
  3288.         TRUE PHYSICAL location with PhysicalLocation(), build a descriptor 
  3289.         with this call and install it into this memory by calling 
  3290.         SetIndirect(). *DO NOT* write it to the memory yourself! 
  3291.         Due to CPU caching effects, this must be done by the library. 
  3292.         Then build a MAPP_INDIRECT descriptor, and tell the library with the
  3293.         MAPTAG_DESCRIPTOR tag of SetPropertiesA() to make it point to your
  3294.         memory. In case you want access faults on this to be repairable,
  3295.         set the MAPP_REPAIRABLE bit for this call. In case you want it write 
  3296.         protected but want to ignore write accesses, set MAPP_ROM, too. Then
  3297.         call RebuildTree() as usual. In case you want to exchange descriptors
  3298.         really fast - this is after all what indirect descriptors are 
  3299.         designed for - build all descriptors you require in a first step
  3300.         and keep them. A single call to SetIndirect() will exchange them
  3301.         VERY RAPIDLY which is ideal for certain applications. 
  3302.     
  3303.     BUGS
  3304.         Much more must be said about this function. It is definitely an
  3305.         advanced feature, so don't play with this in case you don't know
  3306.         what it does.
  3307.  
  3308.     SEE ALSO
  3309.         SetIndirect(), GetIndirect()
  3310.  
  3311. mmu.library/SetIndirect                                mmu.library/SetIndirect
  3312.  
  3313.     NAME
  3314.         SetIndirect        -    Write a page descritor to memory
  3315.  
  3316.     SYNOPSIS
  3317.         SetIndirect ( destination , logical , descriptor );
  3318.                         a0            a1            d0
  3319.  
  3320.         void SetIndirect ( ULONG *, ULONG, ULONG );
  3321.  
  3322.     FUNCTION
  3323.         Write a page descriptor, used as the destination of one or
  3324.         several MAPP_INDIRECT descriptors, out to memory and make the MMU
  3325.         aware of the change.
  3326.  
  3327.     INPUTS
  3328.         destination        -    the memory location to which the descriptor
  3329.                             should be written to. This is the same address
  3330.                             specified by MAPTAD_DESCRIPTOR in the corresponding
  3331.                             SetProperties() call. NOTE THAT THIS IS A 
  3332.                             PHYSICAL, NOT A LOGICAL ADDRESS.
  3333.  
  3334.         logical            -    The logical address covered by this descriptor, 
  3335.                             i.e. the address of the page which this 
  3336.                             descriptor is managing. In case you installed
  3337.                             the same descriptor for several logical addresses,
  3338.                             specify -1L.
  3339.  
  3340.         descriptor        -    The descriptor to install.
  3341.  
  3342.     RESULTS
  3343.         doesn't return a result.
  3344.  
  3345.     NOTES
  3346.         Do NOT try to install a descriptor yourself, even though this 
  3347.         *seems* to be more effective. Somewhat more must be done than just
  3348.         writing the descriptor to memory. This call ensures that the
  3349.         descriptor is really written out to memory, and really fetched by
  3350.         the MMU. Specifying -1 as logical address is possible and supported
  3351.         but *slightly* less efficient than giving the correct 
  3352.         logical address.
  3353.         This call DOES NOT ensure that all data in the page to be modified
  3354.         is really written out. Hence, if you change the cache mode, the
  3355.         protection status or the validity status of a page, you should call
  3356.         CacheClearU() or CacheClearE() before. Furthermore, note that the
  3357.         cache of the 020 and 030 keeps logical addresses. On these processors,
  3358.         you must flush the cache, too, if you install a descriptor which    
  3359.         points to a different physical address.
  3360.  
  3361.         This call is *very* effective, there is little reason to try this
  3362.         yourself, not counting the portability problems.
  3363.  
  3364.     BUGS
  3365.  
  3366.     SEE ALSO
  3367.         GetIndirect(), BuildIndirect()
  3368.  
  3369. mmu.library/GetIndirect                                mmu.library/GetIndirect
  3370.  
  3371.     NAME
  3372.         GetIndirect        -    Read a hardware page descritor from memory
  3373.  
  3374.     SYNOPSIS
  3375.         GetIndirect ( ctx , adt , address );
  3376.                       a0    a1        d0
  3377.  
  3378.         void GetIndirect ( struct MMUContext *, 
  3379.                            struct AbstractDescriptor *, ULONG * );
  3380.  
  3381.     FUNCTION
  3382.         Reads a true hardware page descriptor, used as the destination 
  3383.         of one or several MAPP_INDIRECT descriptors, and places its data
  3384.         in the AbstractDescriptor structure.
  3385.  
  3386.     INPUTS
  3387.         ctx                -    the MMU context handle this page descriptor
  3388.                             belongs.
  3389.         adt                -    An abstract table descriptor, to be filled
  3390.                             out with the descriptor data.
  3391.         address            -    the address from where the descriptor is to 
  3392.                             be read. This is the same address which has been
  3393.                             passed as argument to the MAPTAG_DESCRIPTOR
  3394.                             tag of the SetPropertiesA() call when building
  3395.                             the indirect descriptor.
  3396.     
  3397.     RESULTS
  3398.         no direct result code, but the AbstractDescriptor is filled
  3399.         out:
  3400.  
  3401.         struct AbstractDescriptor {
  3402.             ULONG        atd_Pointer;
  3403.             ULONG        atd_Properties;
  3404.             UWORD        atd_LowerLimit;
  3405.             UWORD        atd_UpperLimit;
  3406.             UBYTE        atd_ThisType;
  3407.             UBYTE        atd_NextType;
  3408.             UWORD        atd_reserved;
  3409.         };
  3410.  
  3411.         atd_Pointer is either the physical address the accesses to the
  3412.         page(s) this descriptor is installed for are redirected to, or
  3413.         the user data if this descriptor is of invalid type. This is the
  3414.         same value that was passed in as "address" argument to the
  3415.         corresponding BuildProperties() call.
  3416.  
  3417.         atd_Properties is the set of MMU properties read from the 
  3418.         descriptor. This NEED NOT to be identical to the properties setup
  3419.         by BuildIndirect(), for two reasons: First, the MMU sets the
  3420.         USED and MODIFIED attributes as soon as any access or a write
  3421.         access happens to the page(s) handled by the descriptor. Second,
  3422.         not all MMUs support all properties. Unavailable properties are
  3423.         ignored by BuildIndirect(), and read as zero by this function.
  3424.  
  3425.         All other fields are currently not documented and should not be
  3426.         read.
  3427.  
  3428.     NOTES
  3429.         Do NOT try to read a descriptor yourself, even though this 
  3430.         *seems* to be more effective. Somewhat more care must be kept for
  3431.         doing this. NOT following this rule might even lock up your
  3432.         machine!
  3433.  
  3434.         This call is *very* effective, there is little reason to try this
  3435.         yourself, not counting the portability problems.
  3436.  
  3437.     BUGS
  3438.  
  3439.     SEE ALSO
  3440.         SetIndirect(), BuildIndirect(), mmu/descriptor.h
  3441.