home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Misc / 3_1DOCS.DMS / in.adf / autodocs.lha / doc / exec.doc < prev    next >
Encoding:
Text File  |  1993-10-29  |  158.3 KB  |  5,265 lines

  1. TABLE OF CONTENTS
  2.  
  3. exec.library/AbortIO
  4. exec.library/AddDevice
  5. exec.library/AddHead
  6. exec.library/AddIntServer
  7. exec.library/AddLibrary
  8. exec.library/AddMemHandler
  9. exec.library/AddMemList
  10. exec.library/AddPort
  11. exec.library/AddResource
  12. exec.library/AddSemaphore
  13. exec.library/AddTail
  14. exec.library/AddTask
  15. exec.library/Alert
  16. exec.library/AllocAbs
  17. exec.library/Allocate
  18. exec.library/AllocEntry
  19. exec.library/AllocMem
  20. exec.library/AllocPooled
  21. exec.library/AllocSignal
  22. exec.library/AllocTrap
  23. exec.library/AllocVec
  24. exec.library/AttemptSemaphore
  25. exec.library/AttemptSemaphoreShared
  26. exec.library/AvailMem
  27. exec.library/CacheClearE
  28. exec.library/CacheClearU
  29. exec.library/CacheControl
  30. exec.library/CachePostDMA
  31. exec.library/CachePreDMA
  32. exec.library/Cause
  33. exec.library/CheckIO
  34. exec.library/CloseDevice
  35. exec.library/CloseLibrary
  36. exec.library/ColdReboot
  37. exec.library/CopyMem
  38. exec.library/CopyMemQuick
  39. exec.library/CreateIORequest
  40. exec.library/CreateMsgPort
  41. exec.library/CreatePool
  42. exec.library/Deallocate
  43. exec.library/Debug
  44. exec.library/DeleteIORequest
  45. exec.library/DeleteMsgPort
  46. exec.library/DeletePool
  47. exec.library/Disable
  48. exec.library/DoIO
  49. exec.library/Enable
  50. exec.library/Enqueue
  51. exec.library/FindName
  52. exec.library/FindPort
  53. exec.library/FindResident
  54. exec.library/FindSemaphore
  55. exec.library/FindTask
  56. exec.library/Forbid
  57. exec.library/FreeEntry
  58. exec.library/FreeMem
  59. exec.library/FreePooled
  60. exec.library/FreeSignal
  61. exec.library/FreeTrap
  62. exec.library/FreeVec
  63. exec.library/GetCC
  64. exec.library/GetMsg
  65. exec.library/InitCode
  66. exec.library/InitResident
  67. exec.library/InitSemaphore
  68. exec.library/InitStruct
  69. exec.library/Insert
  70. exec.library/MakeFunctions
  71. exec.library/MakeLibrary
  72. exec.library/ObtainQuickVector
  73. exec.library/ObtainSemaphore
  74. exec.library/ObtainSemaphoreList
  75. exec.library/ObtainSemaphoreShared
  76. exec.library/OldOpenLibrary
  77. exec.library/OpenDevice
  78. exec.library/OpenLibrary
  79. exec.library/OpenResource
  80. exec.library/Permit
  81. exec.library/Procure
  82. exec.library/PutMsg
  83. exec.library/RawDoFmt
  84. exec.library/ReleaseSemaphore
  85. exec.library/ReleaseSemaphoreList
  86. exec.library/RemDevice
  87. exec.library/RemHead
  88. exec.library/RemIntServer
  89. exec.library/RemLibrary
  90. exec.library/RemMemHandler
  91. exec.library/Remove
  92. exec.library/RemPort
  93. exec.library/RemResource
  94. exec.library/RemSemaphore
  95. exec.library/RemTail
  96. exec.library/RemTask
  97. exec.library/ReplyMsg
  98. exec.library/SendIO
  99. exec.library/SetExcept
  100. exec.library/SetFunction
  101. exec.library/SetIntVector
  102. exec.library/SetSignal
  103. exec.library/SetSR
  104. exec.library/SetTaskPri
  105. exec.library/Signal
  106. exec.library/StackSwap
  107. exec.library/SumKickData
  108. exec.library/SumLibrary
  109. exec.library/SuperState
  110. exec.library/Supervisor
  111. exec.library/TypeOfMem
  112. exec.library/UserState
  113. exec.library/Vacate
  114. exec.library/Wait
  115. exec.library/WaitIO
  116. exec.library/WaitPort
  117. SAD/--Overview--
  118. SAD/ALLOCATE_MEMORY
  119. SAD/CALL_ADDRESS
  120. SAD/FREE_MEMORY
  121. SAD/GET_CONTEXT_FRAME
  122. SAD/NOP
  123. SAD/READ_ARRAY
  124. SAD/READ_BYTE
  125. SAD/READ_LONG
  126. SAD/READ_WORD
  127. SAD/RESET
  128. SAD/RETURN_TO_SYSTEM
  129. SAD/TURN_OFF_SINGLE
  130. SAD/TURN_ON_SINGLE
  131. SAD/WRITE_ARRAY
  132. SAD/WRITE_BYTE
  133. SAD/WRITE_LONG
  134. SAD/WRITE_WORD
  135. exec.library/AbortIO                                     exec.library/AbortIO
  136.  
  137.    NAME
  138.     AbortIO - attempt to abort an in-progress I/O request
  139.  
  140.    SYNOPSIS
  141.     AbortIO(iORequest)
  142.             A1
  143.  
  144.     VOID AbortIO(struct IORequest *);
  145.  
  146.    FUNCTION
  147.     Ask a device to abort a previously started IORequest.  This is done
  148.     by calling the device's ABORTIO vector, with your given IORequest.
  149.  
  150.  
  151.     AbortIO is a command the device that may or may not grant.  If
  152.     successful, the device will stop processing the IORequest, and
  153.     reply to it earlier than it would otherwise have done.
  154.  
  155.    NOTE
  156.     AbortIO() does NOT Remove() the IORequest from your ReplyPort, OR
  157.     wait for it to complete.  After an AbortIO() you must wait normally
  158.     for the reply message before actually reusing the request.
  159.  
  160.     If a request has already completed when AbortIO() is called, no
  161.     action is taken.
  162.  
  163.    EXAMPLE
  164.         AbortIO(timer_request);
  165.         WaitIO(timer_request);
  166.         /* Message is free to be reused */
  167.  
  168.    INPUTS
  169.     iORequest - pointer to an I/O request block (must have been used
  170.         at least once.  May be active or finished).
  171.  
  172.    SEE ALSO
  173.     WaitIO, DoIO, SendIO, CheckIO
  174.  
  175. exec.library/AddDevice                                 exec.library/AddDevice
  176.  
  177.    NAME
  178.     AddDevice -- add a device to the system
  179.  
  180.    SYNOPSIS
  181.     AddDevice(device)
  182.           A1
  183.  
  184.     void AddDevice(struct Device *);
  185.  
  186.    FUNCTION
  187.     This function adds a new device to the system device list, making
  188.     it available to other programs.  The device must be ready to be
  189.     opened at this time.
  190.  
  191.    INPUTS
  192.     device - pointer to a properly initialized device node
  193.  
  194.    SEE ALSO
  195.     RemDevice, OpenDevice, CloseDevice, MakeLibrary
  196.  
  197. exec.library/AddHead                                     exec.library/AddHead
  198.  
  199.    NAME
  200.     AddHead -- insert node at the head of a list
  201.  
  202.    SYNOPSIS
  203.     AddHead(list, node)
  204.         A0    A1
  205.  
  206.     void AddHead(struct List *, struct Node *)
  207.  
  208.    FUNCTION
  209.     Add a node to the head of a doubly linked list. Assembly
  210.     programmers may prefer to use the ADDHEAD macro from
  211.     "exec/lists.i".
  212.  
  213.    WARNING
  214.     This function does not arbitrate for access to the list.  The
  215.     calling task must be the owner of the involved list.
  216.  
  217.    INPUTS
  218.     list - a pointer to the target list header
  219.     node - the node to insert at head
  220.  
  221.    SEE ALSO
  222.     AddTail, Enqueue, Insert, Remove, RemHead, RemTail
  223.  
  224. exec.library/AddIntServer                           exec.library/AddIntServer
  225.  
  226.    NAME
  227.     AddIntServer -- add an interrupt server to a system server chain
  228.  
  229.    SYNOPSIS
  230.     AddIntServer(intNum, interrupt)
  231.              D0-0:4  A1
  232.  
  233.     void AddIntServer(ULONG, struct Interrupt *);
  234.  
  235.    FUNCTION
  236.     This function adds a new interrupt server to a given server chain.
  237.     The node is located on the chain in a priority dependent position.
  238.     If this is the first server on a particular chain, interrupts will
  239.     be enabled for that chain.
  240.  
  241.     Each link in the chain will be called in priority order until the
  242.     chain ends or one of the servers returns with the 68000's Z condition
  243.     code clear (indicating non-zero).  Servers on the chain should return
  244.     with the Z flag clear if the interrupt was specifically for that
  245.     server, and no one else.  VERTB servers should always return Z set.
  246.     (Take care with High Level Language servers, the language may not
  247.     have a mechanism for reliably setting the Z flag on exit).
  248.  
  249.     Servers are called with the following register conventions:
  250.  
  251.         D0 - scratch
  252.         D1 - scratch
  253.  
  254.         A0 - scratch
  255.         A1 - server is_Data pointer (scratch)
  256.  
  257.         A5 - jump vector register (scratch)
  258.         A6 - scratch
  259.  
  260.         all other registers must be preserved
  261.  
  262.    INPUTS
  263.     intNum - the Paula interrupt bit number (0 through 14). Processor
  264.          level seven interrupts (NMI) are encoded as intNum 15.
  265.          The PORTS, COPER, VERTB, EXTER and NMI interrupts are
  266.          set up as server chains.
  267.     interrupt - pointer to an Interrupt structure.
  268.          By convention, the LN_NAME of the interrupt structure must
  269.          point a descriptive string so that other users may
  270.          identify who currently has control of the interrupt.
  271.  
  272.    WARNING
  273.     Some compilers or assemblers may optimize code in unexpected ways,
  274.     affecting the conditions codes returned from the function.  Watch
  275.     out for a "MOVEM" instruction (which does not affect the condition
  276.     codes) turning into "MOVE" (which does).
  277.  
  278.    BUGS
  279.     The graphics library's VBLANK server, and some user code, currently
  280.     assume that address register A0 will contain a pointer to the custom
  281.     chips. If you add a server at a priority of 10 or greater, you must
  282.     compensate for this by providing the expected value ($DFF000).
  283.  
  284.    SEE ALSO
  285.     RemIntServer, SetIntVector, hardware/intbits.i,exec/interrupts.i
  286.  
  287. exec.library/AddLibrary                               exec.library/AddLibrary
  288.  
  289.    NAME
  290.     AddLibrary -- add a library to the system
  291.  
  292.    SYNOPSIS
  293.     AddLibrary(library)
  294.            A1
  295.  
  296.     void AddLibrary(struct Library *);
  297.  
  298.    FUNCTION
  299.     This function adds a new library to the system, making it available
  300.     to other programs.  The library should be ready to be opened at
  301.     this time.  It will be added to the system library name list, and
  302.     the checksum on the library entries will be calculated.
  303.  
  304.    INPUTS
  305.     library - pointer to a properly initialized library structure
  306.  
  307.    SEE ALSO
  308.     RemLibrary, CloseLibrary, OpenLibrary, MakeLibrary
  309.  
  310. exec.library/AddMemHandler                         exec.library/AddMemHandler
  311.  
  312.    NAME
  313.     AddMemHandler - Add a low memory handler to exec                 (V39)
  314.  
  315.    SYNOPSIS
  316.     AddMemHandler(memHandler)
  317.                   A1
  318.  
  319.     VOID AddMemHandler(struct Interrupt *);
  320.  
  321.    FUNCTION
  322.     This function adds a low memory handler to the system.  The handler
  323.     is described in the Interrupt structure.  Due to multitasking
  324.     issues, the handler must be ready to run the moment this function
  325.     call is made.  (The handler may be called before the call returns)
  326.  
  327.    NOTE
  328.     Adding a handler from within a handler will cause undefined
  329.     actions.  It is safe to add a handler to the list while within
  330.     a handler but the newly added handler may or may not be called
  331.     for the specific failure currently running.
  332.  
  333.    EXAMPLE
  334.     struct Interrupt *myInt;  /* Assume it is allocated */
  335.  
  336.     myInt->is_Node.ln_Pri=50;  /* Relatively early; before RAMLIB */
  337.  
  338.     /* Please fill in the name field! */
  339.     myInt->is_Node.ln_Name="Example Handler";
  340.  
  341.     myInt->is_Data=(APTR)mydata_pointer;
  342.     myInt->is_Code=myhandler_code;
  343.  
  344.     AddMemHandler(myInt);
  345.     ... /* and so on */
  346.  
  347.     _myhandler_code:
  348.             ; This is the handler code
  349.             ; We are passed a pointer to struct MemHandlerData
  350.             ; in a0, the value of is_Data in a1 and
  351.             ; ExecBase in a6.
  352.             ; We must not break forbid!!!
  353.     ;
  354.     ; Start off assuming we did nothing
  355.     ;
  356.         moveq.l    #MEM_DID_NOTHING,d0
  357.         move.l    memh_RequestFlags(a0),d1
  358.         btst.l    #MEMB_CHIP,d1    ; Did the failure happen in CHIP
  359.         beq.s    handler_nop    ; If not, we have nothing to do
  360.         bsr    DoMyMagic    ; Do the magic...
  361.         ; DoMyMagic frees whatever we can and returns d0 set...
  362.     handler_nop:
  363.         rts            ; Return with d0 set...
  364.  
  365.    INPUTS
  366.     memHandler - A pointer to a completely filled in Interrupt structure
  367.                  The priority field determine the position of the handler
  368.                  with respect to other handlers in the system.  The higher
  369.                  the priority, the earlier the handler is called.
  370.                  Positive priorities will have the handler called before
  371.                  any of the library expunge vectors are called.  Negative
  372.                  priority handlers will be called after the library
  373.                  expunge routines are called.
  374.                  (Note:  RAMLIB is a handler at priority 0)
  375.  
  376.    SEE ALSO
  377.     RemMemHandler, exec/interrupts.i
  378.  
  379. exec.library/AddMemList                               exec.library/AddMemList
  380.  
  381.    NAME
  382.     AddMemList - add memory to the system free pool
  383.  
  384.    SYNOPSIS
  385.     AddMemList( size, attributes, pri, base, name )
  386.                      D0      D1        D2   A0    A1
  387.  
  388.     void AddMemList(ULONG, ULONG, LONG, APTR, STRPTR);
  389.  
  390.    FUNCTION
  391.     Add a new region of memory to the system free pool.  The first few
  392.     bytes will be used to hold the MemHeader structure.  The remainder
  393.     will be made available to the rest of the world.
  394.  
  395.    INPUTS
  396.     size - the size (in bytes) of the memory area
  397.     attributes - the attributes word that the memory pool will have
  398.     pri  - the priority for this memory.  CHIP memory has a pri of -10,
  399.            16 bit expansion memory has a priority of 0.  The higher the
  400.            priority, the closer to the head of the memory list it will
  401.            be placed.
  402.     base - the base of the new memory area
  403.     name - the name that will be used in the memory header, or NULL
  404.            if no name is to be provided.  This name is not copied, so it
  405.            must remain valid for as long as the memory header is in the
  406.            system.
  407.  
  408.    NOTES
  409.     *DO NOT* add memory to the system with the attribute of MEMF_KICK.
  410.     EXEC will mark your memory as such if it is of the right type.
  411.  
  412.    SEE ALSO
  413.     AllocMem, exec/memory.h
  414.  
  415. exec.library/AddPort                                     exec.library/AddPort
  416.  
  417.    NAME
  418.     AddPort -- add a public message port to the system
  419.  
  420.    SYNOPSIS
  421.     AddPort(port)
  422.         A1
  423.  
  424.     void AddPort(struct MsgPort *);
  425.  
  426.    FUNCTION
  427.     This function attaches a message port structure to the system's
  428.     public message port list, where it can be found by the FindPort()
  429.     function.  The name and priority fields of the port structure must
  430.     be initialized prior to calling this function.    If the user does
  431.     not require the priority field, it should be initialized to zero.
  432.  
  433.     Only ports that will be searched for with FindPort() need to
  434.     be added to the system list.  In addition, adding ports is often
  435.     useful during debugging.  If the port will be searched for,
  436.     the priority field should be at least 1 (to avoid the large number
  437.     of inactive ports at priority zero).  If the port will be searched
  438.     for often, set the priority in the 50-100 range (so it will be
  439.     before other less used ports).
  440.  
  441.     Once a port has been added to the naming list, you must be careful
  442.     to remove the port from the list (via RemPort) before deallocating
  443.     its memory.
  444.  
  445.    NOTE
  446.     A point of confusion is that clearing a MsgPort structure to all
  447.     zeros is not enough to prepare it for use.  As mentioned in the
  448.     Exec chapter of the ROM Kernel Manual, the List for the MsgPort
  449.     must be initialized.  This is automatically handled by AddPort(),
  450.     and amiga.lib/CreatePort.  This initialization can be done manually
  451.     with amiga.lib/NewList or the assembly NEWLIST macro.
  452.  
  453.     Do not AddPort an active port.
  454.  
  455.    INPUTS
  456.     port - pointer to a message port
  457.  
  458.    SEE ALSO
  459.     RemPort, FindPort, amiga.lib/CreatePort, amiga.lib/NewList
  460.  
  461. exec.library/AddResource                             exec.library/AddResource
  462.  
  463.    NAME
  464.     AddResource -- add a resource to the system
  465.  
  466.    SYNOPSIS
  467.     AddResource(resource)
  468.             A1
  469.  
  470.     void AddResource(APTR);
  471.  
  472.    FUNCTION
  473.     This function adds a new resource to the system and makes it
  474.     available to other users.  The resource must be ready to be called
  475.     at this time.
  476.  
  477.     Resources currently have no system-imposed structure, however they
  478.     must start with a standard named node (LN_SIZE), and should with
  479.     a standard Library node (LIB_SIZE).
  480.  
  481.    INPUTS
  482.     resource - pointer an initialized resource node
  483.  
  484.    SEE ALSO
  485.     RemResource, OpenResource, MakeLibrary
  486.  
  487. exec.library/AddSemaphore                           exec.library/AddSemaphore
  488.  
  489.    NAME
  490.     AddSemaphore -- initialize then add a signal semaphore to the system
  491.  
  492.    SYNOPSIS
  493.     AddSemaphore(signalSemaphore)
  494.              A1
  495.  
  496.     void AddSemaphore(struct SignalSemaphore *);
  497.  
  498.    FUNCTION
  499.     This function attaches a signal semaphore structure to the system's
  500.     public signal semaphore list.  The name and priority fields of the
  501.     semaphore structure must be initialized prior to calling this
  502.     function.  If you do not want to let others rendezvous with this
  503.     semaphore, use InitSemaphore() instead.
  504.  
  505.     If a semaphore has been added to the naming list, you must be
  506.     careful to remove the semaphore from the list (via RemSemaphore)
  507.     before deallocating its memory.
  508.  
  509.     Semaphores that are linked together in an allocation list (which
  510.     ObtainSemaphoreList() would use) may not be added to the system
  511.     naming list, because the facilities use the link field of the
  512.     signal semaphore in incompatible ways
  513.  
  514.    INPUTS
  515.        signalSemaphore -- an signal semaphore structure
  516.  
  517.    BUGS
  518.     Does not work in Exec <V36.  Instead use this code:
  519.  
  520.         #include <exec/execbase.h>
  521.         #include <exec/nodes.h>
  522.         extern struct ExecBase *SysBase;
  523.         ...
  524.         void LocalAddSemaphore(s)
  525.         struct SignalSemaphore *s;
  526.         {
  527.         s->ss_Link.ln_Type=NT_SIGNALSEM;
  528.         InitSemaphore(s);
  529.         Forbid();
  530.         Enqueue(&SysBase->SemaphoreList,s);
  531.         Permit();
  532.         }
  533.  
  534.    SEE ALSO
  535.     RemSemaphore, FindSemaphore, InitSemaphore
  536.  
  537. exec.library/AddTail                                     exec.library/AddTail
  538.  
  539.    NAME
  540.     AddTail -- append node to tail of a list
  541.  
  542.    SYNOPSIS
  543.     AddTail(list, node)
  544.                 A0    A1
  545.  
  546.     void AddTail(struct List *, struct Node *);
  547.  
  548.    FUNCTION
  549.     Add a node to the tail of a doubly linked list.  Assembly
  550.     programmers may prefer to use the ADDTAIL macro from
  551.     "exec/lists.i".
  552.  
  553.    WARNING
  554.     This function does not arbitrate for access to the list.  The
  555.     calling task must be the owner of the involved list.
  556.  
  557.    INPUTS
  558.     list - a pointer to the target list header
  559.     node - a pointer to the node to insert at tail of the list
  560.  
  561.    SEE ALSO
  562.     AddHead, Enqueue, Insert, Remove, RemHead, RemTail
  563.  
  564. exec.library/AddTask                                     exec.library/AddTask
  565.  
  566.    NAME
  567.     AddTask -- add a task to the system
  568.  
  569.    SYNOPSIS
  570.     AddTask(task, initialPC, finalPC)
  571.         A1    A2     A3
  572.  
  573.     APTR AddTask(struct Task *, APTR, APTR);
  574.  
  575.    FUNCTION
  576.     Add a task to the system.  A reschedule will be run; the task with
  577.     the highest priority in the system will start to execute (this may
  578.     or may not be the new task).
  579.  
  580.     Certain fields of the task control block must be initialized and a
  581.     stack allocated prior to calling this function.  The absolute
  582.     smallest stack that is allowable is something in the range of 100
  583.     bytes, but in general the stack size is dependent on what
  584.     subsystems are called. In general 256 bytes is sufficient if only
  585.     Exec is called, and 4K will do if anything in the system is called.
  586.     DO NOT UNDERESTIMATE.  If you use a stack sniffing utility,
  587.     leave a healthy pad above the minimum value.  The system guarantees
  588.     that its stack operations will leave the stack longword aligned.
  589.  
  590.     This function will temporarily use space from the new task's stack
  591.     for the task's initial set of registers.  This space is allocated
  592.     starting at the SPREG location specified in the task control block
  593.     (not from SPUPPER).  This means that a task's stack may contain
  594.     static data put there prior to its execution.  This is useful for
  595.     providing initialized global variables or some tasks may want to
  596.     use this space for passing the task its initial arguments.
  597.  
  598.     A task's initial registers are set to zero (except the PC).
  599.  
  600.     The TC_MEMENTRY field of the task structure may be extended by
  601.     the user to hold additional MemLists (as returned by AllocEntry()).
  602.     These will be automatically be deallocated at RemTask() time.
  603.     If the code you have used to start the task has already added
  604.     something to the MEMENTRY list, simply use AddHead to add your
  605.     new MemLists in.  If no initialization has been done, a NewList will
  606.     need to be performed.
  607.  
  608.    INPUTS
  609.     task  - pointer to the task control block (TCB).  All unset fields
  610.         must be zero.
  611.     initialPC - the initial entry point's address
  612.     finalPC - the finalization code entry point's address.  If zero,
  613.           the system will use a general finalizer. This pointer is
  614.           placed on the stack as if it were the outermost return
  615.           address.
  616.  
  617.    RESULTS
  618.     For V36, AddTask returns either a NULL or the address of the new
  619.     task.  Old code need not check this.
  620.  
  621.    WARNING
  622.     Tasks are a low-level building block, and are unable to call
  623.     dos.library, or any system function that might call dos.library.
  624.     See the AmigaDOS CreateProc() for information on Processes.
  625.  
  626.    SEE ALSO
  627.     RemTask, FindTask, amiga.lib/CreateTask, dos/CreateProc,
  628.     amiga.lib/NewList
  629.  
  630. exec.library/Alert                                         exec.library/Alert
  631.  
  632.    NAME
  633.     Alert -- alert the user of an error
  634.  
  635.    SYNOPSIS
  636.     Alert(alertNum)
  637.           D7
  638.  
  639.     void Alert(ULONG);
  640.  
  641.    FUNCTION
  642.     Alerts the user of a serious system problem.  This function will
  643.     bring the system to a grinding halt, and do whatever is necessary
  644.     to present the user with a message stating what happened.
  645.     Interrupts are disabled, and an attempt to post the alert is made.
  646.     If that fails, the system is reset.  When the system comes up
  647.     again, Exec notices the cause of the failure and tries again to
  648.     post the alert.
  649.  
  650.     If the Alert is a recoverable type, this call MAY return.
  651.  
  652.     This call may be made at any time, including interrupts.
  653.     (Well, only in interrupts if it is non-recoverable)
  654.  
  655.     New, for V39:
  656.     The alert now times out based on the value in LastAlert[3]
  657.     This value is transfered accross warm-reboots and thus will let
  658.     you set it once.  The value is the number of frames that need to
  659.     be displayed before the alert is auto-answered.  A value of
  660.     0 will thus make the alert never be displayed.  Note that
  661.     it is recommended that applications *NOT* change the value in
  662.     LastAlert[] since the main reason for this is to make
  663.     unattended operation of the Amiga (in production enviroments)
  664.     possible.
  665.  
  666.    POST-MORTEM DIAGNOSIS
  667.     There are several options for determining the cause of a crash.
  668.     Descriptions of each alert number can be found in the "alerts.h"
  669.     include file.
  670.  
  671.     A remote terminal can be attached to the Amiga's first built-in
  672.     serial port.  Set the communication parameters to 9600 baud, 8 bits,
  673.     no parity.  Before resetting the machine, the Alert function will
  674.     blink the power LED 10 times.  While the power indicator is flashing,
  675.     pressing DELETE on the remote terminal will invoke the ROM debugger.
  676.  
  677.    INPUT
  678.     alertNum   - a number indicating the particular alert.  -1 is
  679.                  not a valid input.
  680.  
  681.    NOTE
  682.     Much more needs to be said about this function and its implications.
  683.  
  684.    SEE ALSO
  685.     exec/alerts.h
  686.  
  687. exec.library/AllocAbs                                   exec.library/AllocAbs
  688.  
  689.    NAME
  690.     AllocAbs -- allocate at a given location
  691.  
  692.    SYNOPSIS
  693.     memoryBlock = AllocAbs(byteSize, location)
  694.     D0               D0     A1
  695.  
  696.     void *AllocAbs(ULONG, APTR);
  697.  
  698.    FUNCTION
  699.     This function attempts to allocate memory at a given absolute
  700.     memory location.  Often this is used by boot-surviving entities
  701.     such as recoverable ram-disks.    If the memory is already being
  702.     used, or if there is not enough memory to satisfy the request,
  703.     AllocAbs will return NULL.
  704.  
  705.     This block may not be exactly the same as the requested block
  706.     because of rounding, but if the return value is non-zero, the block
  707.     is guaranteed to contain the requested range.
  708.  
  709.    INPUTS
  710.     byteSize - the size of the desired block in bytes
  711.            This number is rounded up to the next larger
  712.            block size for the actual allocation.
  713.     location - the address where the memory MUST be.
  714.  
  715.  
  716.    RESULT
  717.     memoryBlock - a pointer to the newly allocated memory block, or
  718.               NULL if failed.
  719.  
  720.    NOTE
  721.     If the free list is corrupt, the system will panic with alert
  722.     AN_MemCorrupt, $01000005.
  723.  
  724.     The 8 bytes past the end of an AllocAbs will be changed by Exec
  725.     relinking the next block of memory.  Generally you can't trust
  726.     the first 8 bytes of anything you AllocAbs.
  727.  
  728.    SEE ALSO
  729.     AllocMem, FreeMem
  730.  
  731. exec.library/Allocate                                   exec.library/Allocate
  732.  
  733.    NAME
  734.     Allocate - allocate a block of memory
  735.  
  736.    SYNOPSIS
  737.     memoryBlock=Allocate(memHeader, byteSize)
  738.     D0             A0     D0
  739.  
  740.     void *Allocate(struct MemHeader *, ULONG);
  741.  
  742.    FUNCTION
  743.     This function is used to allocate blocks of memory from a given
  744.     private free memory pool (as specified by a MemHeader and its
  745.     memory chunk list).  Allocate will return the first free block that
  746.     is greater than or equal to the requested size.
  747.  
  748.     All blocks, whether free or allocated, will be block aligned;
  749.     hence, all allocation sizes are rounded up to the next block even
  750.     value (e.g. the minimum allocation resolution is currently 8
  751.     bytes.  A request for 8 bytes will use up exactly 8 bytes.  A
  752.     request for 7 bytes will also use up exactly 8 bytes.).
  753.  
  754.     This function can be used to manage an application's internal data
  755.     memory.  Note that no arbitration of the MemHeader and associated
  756.     free chunk list is done.  You must be the owner before calling
  757.     Allocate.
  758.  
  759.    INPUTS
  760.     memHeader - points to the local memory list header.
  761.     byteSize - the size of the desired block in bytes.
  762.  
  763.    RESULT
  764.     memoryBlock - a pointer to the just allocated free block.
  765.            If there are no free regions large enough to satisfy the
  766.            request, return zero.
  767.  
  768.    EXAMPLE
  769.     #include <exec/types.h>
  770.     #include <exec/memory.h>
  771.     void *AllocMem();
  772.     #define BLOCKSIZE 4096L /* Or whatever you want */
  773.  
  774.     void main()
  775.     {
  776.     struct MemHeader *mh;
  777.     struct MemChunk  *mc;
  778.     APTR   block1;
  779.     APTR   block2;
  780.  
  781.         /* Get the MemHeader needed to keep track of our new block */
  782.         mh = (struct MemHeader *)
  783.          AllocMem((long)sizeof(struct MemHeader), MEMF_CLEAR );
  784.         if( !mh )
  785.         exit(10);
  786.  
  787.         /* Get the actual block the above MemHeader will manage */
  788.         mc = (struct MemChunk *)AllocMem( BLOCKSIZE, 0L );
  789.         if( !mc )
  790.         {
  791.         FreeMem( mh, (long)sizeof(struct MemHeader) ); exit(10);
  792.         }
  793.  
  794.         mh->mh_Node.ln_Type = NT_MEMORY;
  795.         mh->mh_Node.ln_Name = "myname";
  796.         mh->mh_First = mc;
  797.         mh->mh_Lower = (APTR) mc;
  798.         mh->mh_Upper = (APTR) ( BLOCKSIZE + (ULONG) mc );
  799.         mh->mh_Free  = BLOCKSIZE;
  800.  
  801.         /* Set up first chunk in the freelist */
  802.         mc->mc_Next  = NULL;
  803.         mc->mc_Bytes = BLOCKSIZE;
  804.  
  805.         block1 = (APTR) Allocate( mh, 20L );
  806.         block2 = (APTR) Allocate( mh, 314L );
  807.         printf("mh=$%lx mc=$%lx\n",mh,mc);
  808.         printf("Block1=$%lx, Block2=$%lx\n",block1,block2);
  809.  
  810.         FreeMem( mh, (long)sizeof(struct MemHeader) );
  811.         FreeMem( mc, BLOCKSIZE );
  812.     }
  813.  
  814.    NOTE
  815.     If the free list is corrupt, the system will panic with alert
  816.     AN_MemCorrupt, $01000005.
  817.  
  818.    SEE ALSO
  819.     Deallocate, exec/memory.h
  820.  
  821. exec.library/AllocEntry                               exec.library/AllocEntry
  822.  
  823.    NAME
  824.     AllocEntry -- allocate many regions of memory
  825.  
  826.    SYNOPSIS
  827.     memList = AllocEntry(memList)
  828.     D0             A0
  829.  
  830.     struct MemList *AllocEntry(struct MemList *);
  831.  
  832.    FUNCTION
  833.     This function takes a memList structure and allocates enough memory
  834.     to hold the required memory as well as a MemList structure to keep
  835.     track of it.
  836.  
  837.     These MemList structures may be linked together in a task control
  838.     block to keep track of the total memory usage of this task. (See
  839.     the description of TC_MEMENTRY under RemTask).
  840.  
  841.    INPUTS
  842.     memList -- A MemList structure filled in with MemEntry structures.
  843.  
  844.    RESULTS
  845.     memList -- A different MemList filled in with the actual memory
  846.         allocated in the me_Addr field, and their sizes in me_Length.
  847.         If enough memory cannot be obtained, then the requirements of
  848.         the allocation that failed is returned and bit 31 is set.
  849.  
  850.         WARNING: The result is unusual!  Bit 31 indicates failure.
  851.  
  852.    EXAMPLES
  853.     The user wants five regions of 2, 4, 8, 16, and 32 bytes in size
  854.     with requirements of MEMF_CLEAR, MEMF_PUBLIC, MEMF_CHIP!MEMF_CLEAR,
  855.     MEMF_CLEAR, and MEMF_PUBLIC!MEMF_CLEAR respectively.  The
  856.     following code fragment would do that:
  857.  
  858.         MemListDecl:
  859.         DS.B    LN_SIZE         * reserve space for list node
  860.         DC.W    5            * number of entries
  861.         DC.L    MEMF_CLEAR            * entry #0
  862.         DC.L    2
  863.         DC.L    MEMF_PUBLIC            * entry #1
  864.         DC.L    4
  865.         DC.L    MEMF_CHIP!MEMF_CLEAR        * entry #2
  866.         DC.L    8
  867.         DC.L    MEMF_CLEAR               * entry #3
  868.         DC.L    16
  869.         DC.L    MEMF_PUBLIC!MEMF_CLEAR        * entry #4
  870.         DC.L    32
  871.  
  872.         start:
  873.         LEA.L    MemListDecl(PC),A0
  874.         JSR    _LVOAllocEntry(a6)
  875.         BCLR.L    #31,D0
  876.         BEQ.S    success
  877.  
  878.         ------- Type of memory that we failed on is in D0
  879.  
  880.    BUGS
  881.     If any one of the allocations fails, this function fails to back
  882.     out fully.  This is fixed by the "SetPatch" program on V1.3
  883.     Workbench disks.
  884.  
  885.    SEE ALSO
  886.     exec/memory.h
  887.  
  888. exec.library/AllocMem                                   exec.library/AllocMem
  889.  
  890.    NAME
  891.     AllocMem -- allocate memory given certain requirements
  892.  
  893.    SYNOPSIS
  894.     memoryBlock = AllocMem(byteSize, attributes)
  895.     D0               D0     D1
  896.  
  897.     void *AllocMem(ULONG, ULONG);
  898.  
  899.    FUNCTION
  900.     This is the memory allocator to be used by system code and
  901.     applications.  It provides a means of specifying that the allocation
  902.     should be made in a memory area accessible to the chips, or
  903.     accessible to shared system code.
  904.  
  905.     Memory is allocated based on requirements and options.    Any
  906.     "requirement" must be met by a memory allocation, any "option" will
  907.     be applied to the block regardless.  AllocMem will try all memory
  908.     spaces until one is found with the proper requirements and room for
  909.     the memory request.
  910.  
  911.    INPUTS
  912.     byteSize - the size of the desired block in bytes.  (The operating
  913.         system will automatically round this number to a multiple of
  914.         the system memory chunk size)
  915.  
  916.     attributes -
  917.         requirements
  918.  
  919.         If no flags are set, the system will return the best
  920.         available memory block.  For expanded systems, the fast
  921.         memory pool is searched first.
  922.  
  923.         MEMF_CHIP:    If the requested memory will be used by
  924.                 the Amiga custom chips, this flag *must*
  925.                 be set.
  926.  
  927.                 Only certain parts of memory are reachable
  928.                 by the special chip sets' DMA circuitry.
  929.                 Chip DMA includes screen memory, images that
  930.                 are blitted, audio data, copper lists, sprites
  931.                 and Pre-V36 trackdisk.device buffers.
  932.  
  933.  
  934.         MEMF_FAST:    This is non-chip memory.  If no flag is set
  935.                 MEMF_FAST is taken as the default.
  936.  
  937.                 DO NOT SPECIFY MEMF_FAST unless you know
  938.                 exactly what you are doing!  If MEMF_FAST is
  939.                 set, AllocMem() will fail on machines that
  940.                 only have chip memory!  This flag may not
  941.                 be set when MEMF_CHIP is set.
  942.  
  943.  
  944.         MEMF_PUBLIC:    Memory that must not be mapped, swapped,
  945.                 or otherwise made non-addressable. ALL
  946.                 MEMORY THAT IS REFERENCED VIA INTERRUPTS
  947.                 AND/OR BY OTHER TASKS MUST BE EITHER PUBLIC
  948.                 OR LOCKED INTO MEMORY! This includes both
  949.                 code and data.
  950.  
  951.  
  952.         MEMF_LOCAL:    This is memory that will not go away
  953.                 after the CPU RESET instruction.  Normally,
  954.                 autoconfig memory boards become unavailable
  955.                 after RESET while motherboard memory
  956.                 may still be available.  This memory type
  957.                 is now automatically set in V36.  Pre-V36
  958.                 systems may not have this memory type
  959.                 and AllocMem() will then fail.
  960.  
  961.  
  962.         MEMF_24BITDMA:    This is memory that is within the address
  963.                 range of 24-bit DMA devices.  (Zorro-II)
  964.                 This is required if you run a Zorro-II
  965.                 DMA device on a machine that has memory
  966.                 beyond the 24-bit addressing limit of
  967.                 Zorro-II.  This memory type
  968.                 is now automatically set in V36.  Pre-V36
  969.                 systems may not have this memory type
  970.                 and AllocMem() will then fail.
  971.  
  972.  
  973.         MEMF_KICK:    This memory is memory that EXEC was able
  974.                 to access during/before the KickMem and
  975.                 KickTags are processed.  This means that
  976.                 if you wish to use these, you should allocate
  977.                 memory with this flag.  This flag is
  978.                 automaticly set by EXEC in V39.  Pre-V39
  979.                 systems may not have this memory type and
  980.                 AllocMem() will then fail.  Also, *DO NOT*
  981.                 ever add memory the system with this flag
  982.                 set.  EXEC will set the flag as needed
  983.                 if the memory matches the needs of EXEC.
  984.  
  985.  
  986.         options
  987.  
  988.         MEMF_CLEAR:    The memory will be initialized to all
  989.                 zeros.
  990.  
  991.  
  992.         MEMF_REVERSE:    This allocates memory from the top of
  993.                 the memory pool.  It searches the pools
  994.                 in the same order, such that FAST memory
  995.                 will be found first.  However, the
  996.                 memory will be allocated from the highest
  997.                 address available in the pool.  This
  998.                 option is new as of V36.  Note that this
  999.                 option has a bug in pre-V39 systems.
  1000.  
  1001.  
  1002.         MEMF_NO_EXPUNGE    This will prevent an expunge to happen on
  1003.                 a failed memory allocation.  This option is
  1004.                 new to V39 and will be ignored in V37.
  1005.                 If a memory allocation with this flag
  1006.                 set fails, the allocator will not cause
  1007.                 any expunge operations.  (See AddMemHandler())
  1008.  
  1009.  
  1010.    RESULT
  1011.     memoryBlock - a pointer to the newly allocated memory block.
  1012.         If there are no free memory regions large enough to satisfy
  1013.         the request, zero will be returned.  The pointer must be
  1014.         checked for zero before the memory block may be used!
  1015.         The memory block returned is long word aligned.
  1016.  
  1017.    WARNING
  1018.     The result of any memory allocation MUST be checked, and a viable
  1019.     error handling path taken.  ANY allocation may fail if memory has
  1020.     been filled.
  1021.  
  1022.    EXAMPLES
  1023.     AllocMem(64,0L)        - Allocate the best available memory
  1024.     AllocMem(25,MEMF_CLEAR) - Allocate the best available memory, and
  1025.                   clear it before returning.
  1026.     AllocMem(128,MEMF_CHIP) - Allocate chip memory
  1027.     AllocMem(128,MEMF_CHIP|MEMF_CLEAR) - Allocate cleared chip memory
  1028.     AllocMem(821,MEMF_CHIP|MEMF_PUBLIC|MEMF_CLEAR) - Allocate cleared,
  1029.         public, chip memory.
  1030.  
  1031.    NOTE
  1032.     If the free list is corrupt, the system will panic with alert
  1033.     AN_MemCorrupt, $01000005.
  1034.  
  1035.     This function may not be called from interrupts.
  1036.  
  1037.     A DOS process will have its pr_Result2 field set to
  1038.     ERROR_NO_FREE_STORE if the memory allocation fails.
  1039.  
  1040.    SEE ALSO
  1041.     FreeMem
  1042.  
  1043. exec.library/AllocPooled                             exec.library/AllocPooled
  1044.  
  1045.     NAME
  1046.     AllocPooled -- Allocate memory with the pool manager (V39)
  1047.  
  1048.     SYNOPSIS
  1049.     memory=AllocPooled(poolHeader,memSize)
  1050.     d0                 a0         d0
  1051.  
  1052.     void *AllocPooled(void *,ULONG);
  1053.  
  1054.     FUNCTION
  1055.     Allocate memSize bytes of memory, and return a pointer. NULL is
  1056.     returned if the allocation fails.
  1057.  
  1058.     Doing a DeletePool() on the pool will free all of the puddles
  1059.     and thus all of the allocations done with AllocPooled() in that
  1060.     pool.  (No need to FreePooled() each allocation)
  1061.  
  1062.     INPUTS
  1063.     memSize - the number of bytes to allocate
  1064.     poolHeader - a specific private pool header.
  1065.  
  1066.     RESULT
  1067.     A pointer to the memory, or NULL.
  1068.     The memory block returned is long word aligned.
  1069.  
  1070.     NOTES
  1071.     The pool function do not protect an individual pool from
  1072.     multiple accesses.  The reason is that in most cases the pools
  1073.     will be used by a single task.  If your pool is going to
  1074.     be used by more than one task you must Semaphore protect
  1075.     the pool from having more than one task trying to allocate
  1076.     within the same pool at the same time.  Warning:  Forbid()
  1077.     protection *will not work* in the future.  *Do NOT* assume
  1078.     that we will be able to make it work in the future.  AllocPooled()
  1079.     may well break a Forbid() and as such can only be protected
  1080.     by a semaphore.
  1081.  
  1082.     To track sizes yourself, the following code can be used:
  1083.     Assumes a6=ExecBase
  1084.  
  1085.     ;
  1086.     ; Function to do AllocVecPooled(Pool,memSize)
  1087.     ;
  1088.     AllocVecPooled:    addq.l    #4,d0        ; Get space for tracking
  1089.             move.l    d0,-(sp)    ; Save the size
  1090.             jsr    _LVOAllocPooled(a6)    ; Call pool...
  1091.             move.l    (sp)+,d1    ; Get size back...
  1092.             tst.l    d0        ; Check for error
  1093.             beq.s    avp_fail    ; If NULL, failed!
  1094.             move.l    d0,a0        ; Get pointer...
  1095.             move.l    d1,(a0)+    ; Store size
  1096.             move.l    a0,d0        ; Get result
  1097.     avp_fail:    rts            ; return
  1098.  
  1099.     ;
  1100.     ; Function to do FreeVecPooled(pool,memory)
  1101.     ;
  1102.     FreeVecPooled:    move.l    -(a1),d0    ; Get size / ajust pointer
  1103.             jmp    _LVOFreePooled(a6)
  1104.  
  1105.     SEE ALSO
  1106.     FreePooled(), CreatePool(), DeletePool()
  1107.  
  1108. exec.library/AllocSignal                             exec.library/AllocSignal
  1109.  
  1110.    NAME
  1111.     AllocSignal -- allocate a signal bit
  1112.  
  1113.    SYNOPSIS
  1114.     signalNum = AllocSignal(signalNum)
  1115.     D0            D0
  1116.  
  1117.     BYTE AllocSignal(BYTE);
  1118.  
  1119.    FUNCTION
  1120.     Allocate a signal bit from the current tasks' pool.  Either a
  1121.     particular bit, or the next free bit may be allocated.    The signal
  1122.     associated with the bit will be properly initialized (cleared).  At
  1123.     least 16 user signals are available per task.  Signals should be
  1124.     deallocated before the task exits.
  1125.  
  1126.     If the signal is already in use (or no free signals are available)
  1127.     a -1 is returned.
  1128.  
  1129.     Allocated signals are only valid for use with the task that
  1130.     allocated them.
  1131.  
  1132.  
  1133.    WARNING
  1134.     Signals may not be allocated or freed from exception handling code.
  1135.  
  1136.    INPUTS
  1137.     signalNum - the desired signal number {of 0..31} or -1 for no
  1138.             preference.
  1139.  
  1140.    RESULTS
  1141.     signalNum - the signal bit number allocated {0..31}. If no signals
  1142.             are available, this function returns -1.
  1143.  
  1144.    SEE ALSO
  1145.     FreeSignal
  1146.  
  1147. exec.library/AllocTrap                                 exec.library/AllocTrap
  1148.  
  1149.    NAME
  1150.     AllocTrap -- allocate a processor trap vector
  1151.  
  1152.    SYNOPSIS
  1153.     trapNum = AllocTrap(trapNum)
  1154.     D0            D0
  1155.  
  1156.     LONG AllocTrap(LONG);
  1157.  
  1158.    FUNCTION
  1159.     Allocate a trap number from the current task's pool.  These trap
  1160.     numbers are those associated with the 68000 TRAP type instructions.
  1161.     Either a particular number, or the next free number may be
  1162.     allocated.
  1163.  
  1164.     If the trap is already in use (or no free traps are available) a -1
  1165.     is returned.
  1166.  
  1167.     This function only affects the currently running task.
  1168.  
  1169.     Traps are sent to the trap handler pointed at by tc_TrapCode.
  1170.     Unless changed by user code, this points to a standard trap
  1171.     handler.  The stack frame of the exception handler will be:
  1172.  
  1173.         0(SP) = Exception vector number.  This will be in the
  1174.             range of 32 to 47 (corresponding to the
  1175.             Trap #1...Trap #15 instructions).
  1176.         4(SP) = 68000/68010/68020/68030, etc. exception frame
  1177.  
  1178.     tc_TrapData is not used.
  1179.  
  1180.  
  1181.    WARNING
  1182.     Traps may not be allocated or freed from exception handling code.
  1183.     You are not allowed to write to the exception table yourself.  In
  1184.     fact, on some machines you will have trouble finding it - the VBR
  1185.     register may be used to remap its location.
  1186.  
  1187.    INPUTS
  1188.     trapNum - the desired trap number {of 0..15} or -1
  1189.           for no preference.
  1190.  
  1191.    RESULTS
  1192.     trapNum - the trap number allocated {of 0..15}.  If no traps are
  1193.           available, this function returns -1.    Instructions of the
  1194.           form "Trap #trapNum" will be sent to the task's trap
  1195.           handler.
  1196.  
  1197.    SEE ALSO
  1198.     FreeTrap
  1199.  
  1200. exec.library/AllocVec                                   exec.library/AllocVec
  1201.  
  1202.    NAME
  1203.     AllocVec -- allocate memory and keep track of the size  (V36)
  1204.  
  1205.    SYNOPSIS
  1206.     memoryBlock = AllocVec(byteSize, attributes)
  1207.     D0               D0     D1
  1208.  
  1209.     void *AllocVec(ULONG, ULONG);
  1210.  
  1211.    FUNCTION
  1212.     This function works identically to AllocMem(), but tracks the size
  1213.     of the allocation.
  1214.  
  1215.     See the AllocMem() documentation for details.
  1216.  
  1217.    WARNING
  1218.     The result of any memory allocation MUST be checked, and a viable
  1219.     error handling path taken.  ANY allocation may fail if memory has
  1220.     been filled.
  1221.  
  1222.    SEE ALSO
  1223.     FreeVec, AllocMem
  1224.  
  1225. exec.library/AttemptSemaphore                   exec.library/AttemptSemaphore
  1226.  
  1227.    NAME
  1228.     AttemptSemaphore -- try to obtain without blocking
  1229.  
  1230.    SYNOPSIS
  1231.     success = AttemptSemaphore(signalSemaphore)
  1232.     D0               A0
  1233.  
  1234.     LONG AttemptSemaphore(struct SignalSemaphore *);
  1235.  
  1236.    FUNCTION
  1237.     This call is similar to ObtainSemaphore(), except that it will not
  1238.     block if the semaphore could not be locked.
  1239.  
  1240.    INPUT
  1241.        signalSemaphore -- an initialized signal semaphore structure
  1242.  
  1243.    RESULT
  1244.     success -- TRUE if the semaphore was locked, false if some
  1245.         other task already possessed the semaphore.
  1246.  
  1247.     NOTE
  1248.     This call does NOT preserve registers.
  1249.  
  1250.    SEE ALSO
  1251.     ObtainSemaphore() ObtainSemaphoreShared(), ReleaseSemaphore(),
  1252.     exec/semaphores.h
  1253.  
  1254. exec.library/AttemptSemaphoreShared       exec.library/AttemptSemaphoreShared
  1255.  
  1256.    NAME
  1257.     AttemptSemaphoreShared -- try to obtain without blocking       (V37)
  1258.  
  1259.    SYNOPSIS
  1260.     success = AttemptSemaphoreShared(signalSemaphore)
  1261.     D0                     A0
  1262.  
  1263.     LONG AttemptSemaphoreShared(struct SignalSemaphore *);
  1264.  
  1265.    FUNCTION
  1266.     This call is similar to ObtainSemaphoreShared(), except that it
  1267.     will not block if the semaphore could not be locked.
  1268.  
  1269.    INPUT
  1270.        signalSemaphore -- an initialized signal semaphore structure
  1271.  
  1272.    RESULT
  1273.     success -- TRUE if the semaphore was granted, false if some
  1274.         other task already possessed the semaphore in exclusive mode.
  1275.  
  1276.    NOTE
  1277.     This call does NOT preserve registers.
  1278.  
  1279.     Starting in V39 this call will grant the semaphore if the
  1280.     caller is already the owner of an exclusive lock on the semaphore.
  1281.     In pre-V39 systems this would not be the case.  If you need this
  1282.     feature you can do the following workaround:
  1283.  
  1284.     LONG myAttemptSempahoreShared(struct SignalSemaphore *ss)
  1285.     {
  1286.     LONG result;
  1287.  
  1288.         /* Try for a shared semaphore */
  1289.         if (!(result=AttemptSemaphoreShared(ss)))
  1290.         {
  1291.             /* Now try for the exclusive one... */
  1292.             result=AttempSemaphore(ss);
  1293.         }
  1294.         return(result);
  1295.     }
  1296.  
  1297.    SEE ALSO
  1298.     ObtainSemaphore() ObtainSemaphoreShared(), ReleaseSemaphore(),
  1299.     exec/semaphores.h
  1300.  
  1301. exec.library/AvailMem                                   exec.library/AvailMem
  1302.  
  1303.    NAME
  1304.     AvailMem -- memory available given certain requirements
  1305.  
  1306.    SYNOPSIS
  1307.     size = AvailMem(attributes)
  1308.     D0        D1
  1309.  
  1310.     ULONG AvailMem(ULONG);
  1311.  
  1312.    FUNCTION
  1313.     This function returns the amount of free memory given certain
  1314.     attributes.
  1315.  
  1316.     To find out what the largest block of a particular type is, add
  1317.     MEMF_LARGEST into the requirements argument.  Returning the largest
  1318.     block is a slow operation.
  1319.  
  1320.    WARNING
  1321.     Due to the effect of multitasking, the value returned may not
  1322.     actually be the amount of free memory available at that instant.
  1323.  
  1324.    INPUTS
  1325.     requirements - a requirements mask as specified in AllocMem.  Any
  1326.                of the AllocMem bits are valid, as is MEMF_LARGEST
  1327.                which returns the size of the largest block matching
  1328.                the requirements.
  1329.  
  1330.    RESULT
  1331.     size - total free space remaining (or the largest free block).
  1332.  
  1333.    NOTE
  1334.     For V36 Exec, AvailMem(MEMF_LARGEST) does a consistency check on
  1335.     the memory list.  Alert AN_MemoryInsane will be pulled if any mismatch
  1336.     is noted.
  1337.  
  1338.    EXAMPLE
  1339.     AvailMem(MEMF_CHIP|MEMF_LARGEST);
  1340.     /* return size of largest available chip memory chunk */
  1341.  
  1342.    SEE ALSO
  1343.     exec/memory.h
  1344.  
  1345. exec.library/CacheClearE                             exec.library/CacheClearE
  1346.  
  1347.    NAME
  1348.     CacheClearE - Cache clearing with extended control (V37)
  1349.  
  1350.    SYNOPSIS
  1351.     CacheClearE(address,length,caches)
  1352.                 a0      d0     d1
  1353.  
  1354.     void CacheClearE(APTR,ULONG,ULONG);
  1355.  
  1356.    FUNCTION
  1357.     Flush out the contents of the CPU instruction and/or data caches.
  1358.     If dirty data cache lines are present, push them to memory first.
  1359.  
  1360.     Motorola CPUs have separate instruction and data caches.  A data
  1361.     write does not update the instruction cache.  If an instruction is
  1362.     written to memory or modified, the old instruction may still exist
  1363.     in the cache.  Before attempting to execute the code, a flush of
  1364.     the instruction cache is required.
  1365.  
  1366.     For most systems, the data cache is not updated by Direct Memory
  1367.     Access (DMA), or if some external factor changes shared memory.
  1368.  
  1369.     Caches must be cleared after *any* operation that could cause
  1370.     invalid or stale data.  The most common cases are DMA and modifying
  1371.     instructions using the processor.
  1372.  
  1373.     Some examples:
  1374.             Self modifying code
  1375.             Building Jump tables
  1376.             Run-time code patches
  1377.             Relocating code for use at different addresses.
  1378.             Loading code from disk
  1379.  
  1380.    INPUTS
  1381.     address - Address to start the operation.  This may be rounded
  1382.           due to hardware granularity.
  1383.     length    - Length of area to be cleared, or $FFFFFFFF to indicate all
  1384.           addresses should be cleared.
  1385.     caches  - Bit flags to indicate what caches to affect.  The current
  1386.           supported flags are:
  1387.             CACRF_ClearI    ;Clear instruction cache
  1388.             CACRF_ClearD    ;Clear data cache
  1389.           All other bits are reserved for future definition.
  1390.  
  1391.    NOTES
  1392.     On systems with a copyback mode cache, any dirty data is pushed
  1393.     to memory as a part of this operation.
  1394.  
  1395.     Regardless of the length given, the function will determine the most
  1396.     efficient way to implement the operation.  For some cache systems,
  1397.     including the 68030, the overhead partially clearing a cache is often
  1398.     too great.  The entire cache may be cleared.
  1399.  
  1400.     For all current Amiga models, Chip memory is set with Instruction
  1401.     caching enabled, data caching disabled.  This prevents coherency
  1402.     conflicts with the blitter or other custom chip DMA.  Custom chip
  1403.     registers are marked as non-cacheable by the hardware.
  1404.  
  1405.     The system takes care of appropriately flushing the caches for normal
  1406.     operations.  The instruction cache is cleared by all calls that
  1407.     modify instructions, including LoadSeg(), MakeLibrary() and
  1408.     SetFunction().
  1409.  
  1410.    SEE ALSO
  1411.     exec/execbase.i, CacheControl, CacheClearU
  1412.  
  1413. exec.library/CacheClearU                             exec.library/CacheClearU
  1414.  
  1415.    NAME
  1416.     CacheClearU - User callable simple cache clearing (V37)
  1417.  
  1418.    SYNOPSIS
  1419.     CacheClearU()
  1420.  
  1421.     void CacheClearU(void);
  1422.  
  1423.    FUNCTION
  1424.     Flush out the contents of any CPU instruction and data caches.
  1425.     If dirty data cache lines are present, push them to memory first.
  1426.  
  1427.     Caches must be cleared after *any* operation that could cause
  1428.     invalid or stale data.  The most common cases are DMA and modifying
  1429.     instructions using the processor.  See the CacheClearE() autodoc
  1430.     for a more complete description.
  1431.  
  1432.     Some examples of when the cache needs clearing:
  1433.             Self modifying code
  1434.             Building Jump tables
  1435.             Run-time code patches
  1436.             Relocating code for use at different addresses.
  1437.             Loading code from disk
  1438.  
  1439.    SEE ALSO
  1440.     exec/execbase.i, CacheControl, CacheClearE
  1441.  
  1442. exec.library/CacheControl                           exec.library/CacheControl
  1443.  
  1444.    NAME
  1445.     CacheControl - Instruction & data cache control
  1446.  
  1447.    SYNOPSIS
  1448.     oldBits = CacheControl(cacheBits,cacheMask)
  1449.     D0                     D0        D1
  1450.  
  1451.     ULONG CacheControl(ULONG,ULONG);
  1452.  
  1453.    FUNCTION
  1454.     This function provides global control of any instruction or data
  1455.     caches that may be connected to the system.  All settings are
  1456.     global -- per task control is not provided.
  1457.  
  1458.     The action taken by this function will depend on the type of
  1459.     CPU installed.  This function may be patched to support external
  1460.     caches, or different cache architectures.  In all cases the function
  1461.     will attempt to best emulate the provided settings.  Use of this
  1462.     function may save state specific to the caches involved.
  1463.  
  1464.     The list of supported settings is provided in the exec/execbase.i
  1465.     include file.  The bits currently defined map directly to the Motorola
  1466.     68030 CPU CACR register.  Alternate cache solutions may patch into
  1467.     the Exec cache functions.  Where possible, bits will be interpreted to
  1468.     have the same meaning on the installed cache.
  1469.  
  1470.    INPUTS
  1471.     cacheBits - new values for the bits specified in cacheMask.
  1472.  
  1473.     cacheMask - a mask with ones for all bits to be changed.
  1474.  
  1475.    RESULT
  1476.     oldBits   - the complete prior values for all settings.
  1477.  
  1478.    NOTE
  1479.     As a side effect, this function clears all caches.
  1480.  
  1481.    SEE ALSO
  1482.     exec/execbase.i, CacheClearU, CacheClearE
  1483.  
  1484. exec.library/CachePostDMA                           exec.library/CachePostDMA
  1485.  
  1486.    NAME
  1487.     CachePostDMA - Take actions after to hardware DMA  (V37)
  1488.  
  1489.    SYNOPSIS
  1490.     CachePostDMA(vaddress,&length,flags)
  1491.                  a0       a1      d0
  1492.  
  1493.     CachePostDMA(APTR,LONG *,ULONG);
  1494.  
  1495.    FUNCTION
  1496.     Take all appropriate steps after Direct Memory Access (DMA).  This
  1497.     function is primarily intended for writers of DMA device drivers.  The
  1498.     action will depend on the CPU type installed, caching modes, and the
  1499.     state of any Memory Management Unit (MMU) activity.
  1500.  
  1501.     As implemented
  1502.         68000 - Do nothing
  1503.         68010 - Do nothing
  1504.         68020 - Do nothing
  1505.         68030 - Flush the data cache
  1506.         68040 - Flush matching areas of the data cache
  1507.         ????? - External cache boards, Virtual Memory Systems, or
  1508.             future hardware may patch this vector to best emulate
  1509.             the intended behavior.
  1510.             With a Bus-Snooping CPU, this function my end up
  1511.             doing nothing.
  1512.  
  1513.    INPUTS
  1514.     address    - Same as initially passed to CachePreDMA
  1515.     length    - Same as initially passed to CachePreDMA
  1516.     flags    - Values:
  1517.             DMA_NoModify - If the area was not modified (and
  1518.             thus there is no reason to flush the cache) set
  1519.             this bit.
  1520.  
  1521.             DMA_ReadFromRAM - Indicates that this DMA is a
  1522.             read from RAM to the DMA device (ie - a write
  1523.             to the hard drive)  This flag is not required
  1524.             but if used must match in both the PreDMA and
  1525.             PostDMA calls.  This flag *should* be used to
  1526.             help the system provide the best performance.
  1527.             This flag is safe in all versions of CachePostDMA()
  1528.  
  1529.    SEE ALSO
  1530.     exec/execbase.i, CachePreDMA, CacheClearU, CacheClearE
  1531.  
  1532. exec.library/CachePreDMA                             exec.library/CachePreDMA
  1533.  
  1534.    NAME
  1535.     CachePreDMA - Take actions prior to hardware DMA  (V37)
  1536.  
  1537.    SYNOPSIS
  1538.     paddress = CachePreDMA(vaddress,&length,flags)
  1539.     d0                     a0       a1      d0
  1540.  
  1541.     APTR CachePreDMA(APTR,LONG *,ULONG);
  1542.  
  1543.    FUNCTION
  1544.     Take all appropriate steps before Direct Memory Access (DMA).  This
  1545.     function is primarily intended for writers of DMA device drivers.  The
  1546.     action will depend on the CPU type installed, caching modes, and the
  1547.     state of any Memory Management Unit (MMU) activity.
  1548.  
  1549.     This function supports advanced cache architectures that have
  1550.     "copyback" modes.  With copyback, write data may be cached, but not
  1551.     actually flushed out to memory.  If the CPU has unflushed data at the
  1552.     time of DMA, data may be lost.
  1553.  
  1554.     As implemented
  1555.         68000 - Do nothing
  1556.         68010 - Do nothing
  1557.         68020 - Do nothing
  1558.         68030 - Do nothing
  1559.         68040 - Write any matching dirty cache lines back to memory.
  1560.             As a side effect of the 68040's design, matching data
  1561.             cache lines are also invalidated -- future CPUs may
  1562.             be different.
  1563.         ????? - External cache boards, Virtual Memory Systems, or
  1564.             future hardware may patch this vector to best emulate
  1565.             the intended behavior.
  1566.             With a Bus-Snooping CPU, this function my end up
  1567.             doing nothing.
  1568.  
  1569.    INPUTS
  1570.     address    - Base address to start the action.
  1571.     length    - Pointer to a longword with a length.
  1572.     flags    - Values:
  1573.             DMA_Continue - Indicates this call is to complete
  1574.             a prior request that was broken up.
  1575.  
  1576.             DMA_ReadFromRAM - Indicates that this DMA is a
  1577.             read from RAM to the DMA device (ie - a write
  1578.             to the hard drive)  This flag is not required
  1579.             but if used must match in both the PreDMA and
  1580.             PostDMA calls.  This flag *should* be used to
  1581.             help the system provide the best performance.
  1582.             This flag is safe in all versions of CachePreDMA()
  1583.  
  1584.    RESULTS
  1585.     paddress- Physical address that corresponds to the input virtual
  1586.           address.
  1587.     &length    - This length value will be updated to reflect the contiguous
  1588.           length of physical memory present at paddress.  This may
  1589.           be smaller than the requested length.  To get the mapping
  1590.           for the next chunk of memory, call the function again with
  1591.           a new address, length, and the DMA_Continue flag.
  1592.  
  1593.    NOTE
  1594.     Due to processor granularity, areas outside of the address range
  1595.     may be affected by the cache flushing actions.  Care has been taken
  1596.     to ensure that no harm is done outside the range, and that activities
  1597.     on overlapping cache lines won't harm data.
  1598.  
  1599.    SEE ALSO
  1600.     exec/execbase.i, CachePostDMA, CacheClearU, CacheClearE
  1601.  
  1602. exec.library/Cause                                         exec.library/Cause
  1603.  
  1604.    NAME
  1605.        Cause -- cause a software interrupt
  1606.  
  1607.    SYNOPSIS
  1608.        Cause(interrupt)
  1609.          A1
  1610.  
  1611.        void Cause(struct Interrupt *);
  1612.  
  1613.    FUNCTION
  1614.     This function causes a software interrupt to occur.  If it is
  1615.     called from user mode (and processor level 0), the software
  1616.     interrupt will preempt the current task.  This call is often used
  1617.     by high-level hardware interrupts to defer medium-length processing
  1618.     down to a lower interrupt level.  Note that a software interrupt is
  1619.     still a real interrupt, and must obey the same restrictions on what
  1620.     system function it may call.
  1621.  
  1622.     Currently only 5 software interrupt priorities are implemented:
  1623.     -32, -16, 0, +16, and +32.  Priorities in between are truncated,
  1624.     values outside the -32/+32 range are not allowed.
  1625.  
  1626.    NOTE
  1627.     When setting up the Interrupt structure, set the node type to
  1628.     NT_INTERRUPT, or NT_UNKOWN.
  1629.  
  1630.    IMPLEMENTATION
  1631.     1> Checks if the node type is NT_SOFTINT.  If so does nothing since
  1632.        the softint is already pending.  No nest count is maintained.
  1633.     2> Sets the node type to NT_SOFTINT.
  1634.     3> Links into one of the 5 priority queues.
  1635.     4> Pokes the hardware interrupt bit used for softints.
  1636.  
  1637.     The node type returns to NT_INTERRUPT after removal from the list.
  1638.  
  1639.    INPUTS
  1640.     interrupt - pointer to a properly initialized interrupt node
  1641.  
  1642.    BUGS
  1643.     Unlike other Interrupts, SoftInts must preserve the value of A6.
  1644.  
  1645. exec.library/CheckIO                                     exec.library/CheckIO
  1646.  
  1647.    NAME
  1648.     CheckIO -- get the status of an IORequest
  1649.  
  1650.    SYNOPSIS
  1651.     result = CheckIO(iORequest)
  1652.     D0         A1
  1653.  
  1654.     struct IORequest *CheckIO(struct IORequest *);
  1655.  
  1656.    FUNCTION
  1657.     This function determines the current state of an I/O request and
  1658.     returns FALSE if the I/O has not yet completed.  This function
  1659.     effectively hides the internals of the I/O completion mechanism.
  1660.  
  1661.     CheckIO() will NOT remove the returned IORequest from the reply port.
  1662.     This is best performed with WaitIO(). If the request has already
  1663.     completed, WaitIO() will return quickly. Use of the Remove()
  1664.     function is dangerous, since other tasks may still be adding things
  1665.     to your message port; a Disable() would be required.
  1666.  
  1667.     This function should NOT be used to busy loop (looping until IO is
  1668.     complete).  WaitIO() is provided for that purpose.
  1669.  
  1670.    INPUTS
  1671.     iORequest - pointer to an I/O request block
  1672.  
  1673.    RESULTS
  1674.     result - NULL if I/O is still in progress.  Otherwise
  1675.          D0 points to the IORequest block.
  1676.  
  1677.    NOTE
  1678.     CheckIO can hang if called on an IORequest that has never been used.
  1679.     This occurs if LN_TYPE of the IORequest is set to "NT_MESSAGE".
  1680.     Instead simply set LN_TYPE to 0.
  1681.  
  1682.    SEE ALSO
  1683.     DoIO, SendIO, WaitIO, AbortIO
  1684.  
  1685. exec.library/CloseDevice                             exec.library/CloseDevice
  1686.  
  1687.    NAME
  1688.     CloseDevice -- conclude access to a device
  1689.  
  1690.    SYNOPSIS
  1691.     CloseDevice(iORequest)
  1692.             A1
  1693.  
  1694.     void CloseDevice(struct IORequest *);
  1695.  
  1696.    FUNCTION
  1697.     This function informs the device that access to a device/unit
  1698.     previously opened has been concluded.  The device may perform
  1699.     certain house-cleaning operations.
  1700.  
  1701.     The user must ensure that all outstanding IORequests have been
  1702.     returned before closing the device.  The AbortIO function can kill
  1703.     any stragglers.
  1704.  
  1705.     After a close, the I/O request structure is free to be reused.
  1706.     Starting with V36 exec it is safe to CloseDevice() with an
  1707.     IORequest that is either cleared to zeros, or failed to
  1708.     open.
  1709.  
  1710.    INPUTS
  1711.     iORequest - pointer to an I/O request structure
  1712.  
  1713.    SEE ALSO
  1714.     OpenDevice
  1715.  
  1716. exec.library/CloseLibrary                           exec.library/CloseLibrary
  1717.  
  1718.    NAME
  1719.     CloseLibrary -- conclude access to a library
  1720.  
  1721.    SYNOPSIS
  1722.     CloseLibrary(library)
  1723.              A1
  1724.  
  1725.     void CloseLibrary(struct Library *);
  1726.  
  1727.    FUNCTION
  1728.     This function informs the system that access to the given library
  1729.     has been concluded.  The user must not reference the library or any
  1730.     function in the library after this close.
  1731.  
  1732.     Starting with V36, it is safe to pass a NULL instead of
  1733.     a library pointer.
  1734.  
  1735.    INPUTS
  1736.     library - pointer to a library node
  1737.  
  1738.    NOTE
  1739.     Library writers must pass a SegList pointer or NULL back from their
  1740.     open point.  This value is used by the system, and not visible as
  1741.     a return code from CloseLibrary.
  1742.  
  1743.    SEE ALSO
  1744.     OpenLibrary
  1745.  
  1746. exec.library/ColdReboot                               exec.library/ColdReboot
  1747.  
  1748.     NAME
  1749.     ColdReboot - reboot the Amiga (V36)
  1750.  
  1751.     SYNOPSIS
  1752.     ColdReboot()
  1753.  
  1754.     void ColdReboot(void);
  1755.  
  1756.     FUNCTION
  1757.     Reboot the machine.  All external memory and periperals will be
  1758.     RESET, and the machine will start its power up diagnostics.
  1759.  
  1760.     This function never returns.
  1761.  
  1762.     INPUT
  1763.     A chaotic pile of disoriented bits.
  1764.  
  1765.     RESULTS
  1766.     An altogether totally integrated living system.
  1767.  
  1768. exec.library/CopyMem                                     exec.library/CopyMem
  1769.  
  1770.    NAME
  1771.     CopyMem - general purpose memory copy function
  1772.  
  1773.    SYNOPSIS
  1774.     CopyMem( source, dest, size )
  1775.          A0     A1    D0
  1776.  
  1777.     void CopyMem(APTR,APTR,ULONG);
  1778.  
  1779.    FUNCTION
  1780.     CopyMem is a general purpose, fast memory copy function.  It can
  1781.     deal with arbitrary lengths, with its pointers on arbitrary
  1782.     alignments.  It attempts to optimize larger copies with more
  1783.     efficient copies, it uses byte copies for small moves, parts of
  1784.     larger copies, or the entire copy if the source and destination are
  1785.     misaligned with respect to each other.
  1786.  
  1787.     Arbitrary overlapping copies are not supported.
  1788.  
  1789.     The internal implementation of this function will change from
  1790.     system to system, and may be implemented via hardware DMA.
  1791.  
  1792.    INPUTS
  1793.     source - a pointer to the source data region
  1794.     dest  - a pointer to the destination data region
  1795.     size  - the size (in bytes) of the memory area.  Zero copies
  1796.         zero bytes
  1797.  
  1798.    SEE ALSO
  1799.     CopyMemQuick
  1800.  
  1801. exec.library/CopyMemQuick                           exec.library/CopyMemQuick
  1802.  
  1803.    NAME
  1804.     CopyMemQuick - optimized memory copy function
  1805.  
  1806.    SYNOPSIS
  1807.     CopyMemQuick( source, dest, size )
  1808.               A0      A1    D0
  1809.  
  1810.     void CopyMemQuick(ULONG *,ULONG *,ULONG);
  1811.  
  1812.    FUNCTION
  1813.     CopyMemQuick is a highly optimized memory copy function, with
  1814.     restrictions on the size and alignment of its arguments. Both the
  1815.     source and destination pointers must be longword aligned.  In
  1816.     addition, the size must be an integral number of longwords (e.g.
  1817.     the size must be evenly divisible by four).
  1818.  
  1819.     Arbitrary overlapping copies are not supported.
  1820.  
  1821.     The internal implementation of this function will change from system
  1822.     to system, and may be implemented via hardware DMA.
  1823.  
  1824.    INPUTS
  1825.     source - a pointer to the source data region, long aligned
  1826.     dest -  a pointer to the destination data region, long aligned
  1827.     size -  the size (in bytes) of the memory area.  Zero copies
  1828.         zero bytes.
  1829.  
  1830.    SEE ALSO
  1831.     CopyMem
  1832.  
  1833. exec.library/CreateIORequest                     exec.library/CreateIORequest
  1834.  
  1835.    NAME
  1836.     CreateIORequest() -- create an IORequest structure  (V36)
  1837.  
  1838.    SYNOPSIS
  1839.     ioReq = CreateIORequest( ioReplyPort, size );
  1840.                              A0           D0
  1841.  
  1842.     struct IORequest *CreateIORequest(struct MsgPort *, ULONG);
  1843.  
  1844.    FUNCTION
  1845.     Allocates memory for and initializes a new IO request block
  1846.     of a user-specified number of bytes.  The number of bytes
  1847.     must be at least as large as a "struct Message".
  1848.  
  1849.    INPUTS
  1850.     ioReplyPort - Pointer to a port for replies (an initialized message
  1851.         port, as created by CreateMsgPort() ).  If NULL, this
  1852.         function fails.
  1853.     size - the size of the IO request to be created.
  1854.  
  1855.    RESULT
  1856.     ioReq - A pointer to the new IORequest block, or NULL.
  1857.  
  1858.    SEE ALSO
  1859.     DeleteIORequest, CreateMsgPort(), amiga.lib/CreateExtIO()
  1860.  
  1861. exec.library/CreateMsgPort                         exec.library/CreateMsgPort
  1862.  
  1863.    NAME
  1864.     CreateMsgPort - Allocate and initialize a new message port  (V36)
  1865.  
  1866.    SYNOPSIS
  1867.     CreateMsgPort()
  1868.  
  1869.     struct MsgPort * CreateMsgPort(void);
  1870.  
  1871.    FUNCTION
  1872.     Allocates and initializes a new message port.  The message list
  1873.     of the new port will be prepared for use (via NewList).  A signal
  1874.     bit will be allocated, and the port will be set to signal your
  1875.     task when a message arrives (PA_SIGNAL).
  1876.  
  1877.     You *must* use DeleteMsgPort() to delete ports created with
  1878.     CreateMsgPort()!
  1879.  
  1880.    RESULT
  1881.     MsgPort - A new MsgPort structure ready for use, or NULL if out of
  1882.         memory or signals.  If you wish to add this port to the public
  1883.         port list, fill in the ln_Name and ln_Pri fields, then call
  1884.         AddPort().  Don't forget RemPort()!
  1885.  
  1886.    SEE ALSO
  1887.     DeleteMsgPort(), exec/AddPort(), exec/ports.h, amiga.lib/CreatePort()
  1888.  
  1889. exec.library/CreatePool                               exec.library/CreatePool
  1890.  
  1891.     NAME
  1892.     CreatePool -- Generate a private memory pool header (V39)
  1893.  
  1894.     SYNOPSIS
  1895.     newPool=CreatePool(memFlags,puddleSize,threshSize)
  1896.     a0                 d0       d1         d2
  1897.  
  1898.     void *CreatePool(ULONG,ULONG,ULONG);
  1899.  
  1900.     FUNCTION
  1901.     Allocate and prepare a new memory pool header.    Each pool is a
  1902.     separate tracking system for memory of a specific type.  Any number
  1903.     of pools may exist in the system.
  1904.  
  1905.     Pools automatically expand and shrink based on demand.    Fixed sized
  1906.     "puddles" are allocated by the pool manager when more total memory
  1907.     is needed.  Many small allocations can fit in a single puddle.
  1908.     Allocations larger than the threshSize are allocation in their own
  1909.     puddles.
  1910.  
  1911.     At any time individual allocations may be freed.  Or, the entire
  1912.     pool may be removed in a single step.
  1913.  
  1914.     INPUTS
  1915.     memFlags - a memory flags specifier, as taken by AllocMem.
  1916.     puddleSize - the size of Puddles...
  1917.     threshSize - the largest allocation that goes into normal puddles
  1918.                  This *MUST* be less than or equal to puddleSize
  1919.                  (CreatePool() will fail if it is not)
  1920.  
  1921.     RESULT
  1922.     The address of a new pool header, or NULL for error.
  1923.  
  1924.     SEE ALSO
  1925.     DeletePool(), AllocPooled(), FreePooled(), exec/memory.i
  1926.  
  1927. exec.library/Deallocate                               exec.library/Deallocate
  1928.  
  1929.    NAME
  1930.     Deallocate -- deallocate a block of memory
  1931.  
  1932.    SYNOPSIS
  1933.     Deallocate(memHeader, memoryBlock, byteSize)
  1934.            A0          A1       D0
  1935.  
  1936.     void Deallocate(struct MemHeader *,APTR,ULONG);
  1937.  
  1938.    FUNCTION
  1939.     This function deallocates memory by returning it to the appropriate
  1940.     private free memory pool.  This function can be used to free an
  1941.     entire block allocated with the above function, or it can be used
  1942.     to free a sub-block of a previously allocated block.  Sub-blocks
  1943.     must be an even multiple of the memory chunk size (currently 8
  1944.     bytes).
  1945.  
  1946.     This function can even be used to add a new free region to an
  1947.     existing MemHeader, however the extent pointers in the MemHeader
  1948.     will no longer be valid.
  1949.  
  1950.     If memoryBlock is not on a block boundary (MEM_BLOCKSIZE) then it
  1951.     will be rounded down in a manner compatible with Allocate().  Note
  1952.     that this will work correctly with all the memory allocation
  1953.     functions, but may cause surprises if one is freeing only part of a
  1954.     region.  The size of the block will be rounded up, so the freed
  1955.     block will fill to an even memory block boundary.
  1956.  
  1957.    INPUTS
  1958.     memHeader - points to the memory header this block is part of.
  1959.     memoryBlock - address of memory block to free.
  1960.     byteSize - the size of the block in bytes. If NULL, nothing
  1961.            happens.
  1962.  
  1963.    SEE ALSO
  1964.     Allocate, exec/memory.h
  1965.  
  1966. exec.library/Debug                                         exec.library/Debug
  1967.  
  1968.    NAME
  1969.     Debug -- run the system debugger
  1970.  
  1971.    SYNOPSIS
  1972.     Debug(flags)
  1973.           D0
  1974.  
  1975.     void Debug(ULONG);
  1976.  
  1977.    FUNCTION
  1978.     This function calls the system debugger.  By default this debugger
  1979.     is "SAD" in >= V39 and "ROM-WACK" in < V39.  Other debuggers are
  1980.     encouraged to take over this entry point (via SetFunction()) so
  1981.     that when an application calls Debug(), the alternative debugger
  1982.     will get control.  Currently a zero is passed to allow future
  1983.     expansion.
  1984.  
  1985.    NOTE
  1986.     The Debug() call may be made when the system is in a questionable
  1987.     state; if you have a SetFunction() patch, make few assumptions, be
  1988.     prepared for Supervisor mode, and be aware of differences in the
  1989.     Motorola stack frames on the 68000,'10,'20,'30,'40 (etc.)
  1990.  
  1991.    BUGS
  1992.     In ROMWack, calling this function in SUPERVISOR state would have
  1993.     caused the a5 register to be trashed and the user stack pointer to
  1994.     be trashed.  As of V39 (and the instroduction of SAD) this is no
  1995.     longer the case.  However, calling this function in Supervisor
  1996.     state is a bit "tricky" at best...
  1997.  
  1998.     Note that due to a bug, pre-V40 SAD had the command
  1999.     codes wrong.  See the SAD autodoc for more details.
  2000.  
  2001.    SEE ALSO
  2002.     SetFunction()
  2003.     your favorite debugger's manual...
  2004.     the SAD autodocs...
  2005.     the ROM-WACK chapter of the ROM Kernel Manual... (pre-V39)
  2006.  
  2007. exec.library/DeleteIORequest                     exec.library/DeleteIORequest
  2008.  
  2009.    NAME
  2010.     DeleteIORequest() - Free a request made by CreateIORequest()  (V36)
  2011.  
  2012.    SYNOPSIS
  2013.     DeleteIORequest( ioReq );
  2014.                      a0
  2015.  
  2016.     void DeleteIORequest(struct IORequest *);
  2017.  
  2018.    FUNCTION
  2019.     Frees up an IO request as allocated by CreateIORequest().
  2020.  
  2021.    INPUTS
  2022.     ioReq - A pointer to the IORequest block to be freed, or NULL.
  2023.         This function uses the mn_Length field to determine how
  2024.         much memory to free.
  2025.  
  2026.    SEE ALSO
  2027.     CreateIORequest(), amiga.lib/DeleteExtIO()
  2028.  
  2029. exec.library/DeleteMsgPort                         exec.library/DeleteMsgPort
  2030.  
  2031.    NAME
  2032.     DeleteMsgPort - Free a message port created by CreateMsgPort  (V36)
  2033.  
  2034.    SYNOPSIS
  2035.     DeleteMsgPort(msgPort)
  2036.               a0
  2037.  
  2038.     void DeleteMsgPort(struct MsgPort *);
  2039.  
  2040.    FUNCTION
  2041.     Frees a message port created by CreateMsgPort().  All messages that
  2042.     may have been attached to this port must have already been
  2043.     replied to.
  2044.  
  2045.    INPUTS
  2046.     msgPort - A message port.  NULL for no action.
  2047.  
  2048.    SEE ALSO
  2049.     CreateMsgPort(), amiga.lib/DeletePort()
  2050.  
  2051. exec.library/DeletePool                               exec.library/DeletePool
  2052.  
  2053.     NAME
  2054.     DeletePool --  Drain an entire memory pool (V39)
  2055.  
  2056.     SYNOPSIS
  2057.     DeletePool(poolHeader)
  2058.                a0
  2059.  
  2060.     void DeletePool(void *);
  2061.  
  2062.     FUNCTION
  2063.     Frees all memory in all pudles of the specified pool header, then
  2064.     deletes the pool header.  Individual free calls are not needed.
  2065.  
  2066.     INPUTS
  2067.     poolHeader - as returned by CreatePool().
  2068.  
  2069.     SEE ALSO
  2070.     CreatePool(), AllocPooled(), FreePooled()
  2071.  
  2072. exec.library/Disable                                     exec.library/Disable
  2073.  
  2074.     NAME
  2075.     Disable -- disable interrupt processing.
  2076.  
  2077.     SYNOPSIS
  2078.     Disable();
  2079.  
  2080.     void Disable(void);
  2081.  
  2082.     FUNCTION
  2083.     Prevents interrupts from being handled by the system, until a
  2084.     matching Enable() is executed.  Disable() implies Forbid().
  2085.  
  2086.     DO NOT USE THIS CALL WITHOUT GOOD JUSTIFICATION.  THIS CALL IS
  2087.     VERY DANGEROUS!
  2088.  
  2089.     RESULTS
  2090.     All interrupt processing is deferred until the task executing makes
  2091.     a call to Enable() or is placed in a wait state.  Normal task
  2092.     rescheduling does not occur while interrupts are disabled.  In order
  2093.     to restore normal interrupt processing, the programmer must execute
  2094.     exactly one call to Enable() for every call to Disable().
  2095.  
  2096.     IMPORTANT REMINDER:
  2097.  
  2098.     It is important to remember that there is a danger in using
  2099.     disabled sections.  Disabling interrupts for more than ~250
  2100.     microseconds will prevent vital system functions (especially serial
  2101.     I/0) from operating in a normal fashion.
  2102.  
  2103.     Think twice before using Disable(), then think once more.
  2104.     After all that, think again.  With enough thought, the need
  2105.     for a Disable() can often be eliminated.  For the user of many
  2106.     device drivers, a write to disable *only* the particular interrupt
  2107.     of interest can replace a Disable().  For example:
  2108.             MOVE.W    #INTF_PORTS,_intena
  2109.     Do not use a macro for Disable(), insist on the real thing.
  2110.  
  2111.     This call may be made from interrupts, it will have the effect
  2112.     of locking out all higher-level interrupts (lower-level interrupts
  2113.     are automatically disabled by the CPU).
  2114.  
  2115.         Note: In the event of a task entering a Wait() after disabling
  2116.               interrupts, the system "breaks" the disabled state and runs
  2117.               normally until the task which called Disable() is rescheduled.
  2118.  
  2119.     NOTE
  2120.     This call is guaranteed to preserve all registers.
  2121.  
  2122.     SEE ALSO
  2123.     Forbid, Permit, Enable
  2124.  
  2125. exec.library/DoIO                                           exec.library/DoIO
  2126.  
  2127.    NAME
  2128.     DoIO -- perform an I/O command and wait for completion
  2129.  
  2130.    SYNOPSIS
  2131.     error = DoIO(iORequest)
  2132.     D0         A1
  2133.  
  2134.     BYTE DoIO(struct IORequest *);
  2135.  
  2136.    FUNCTION
  2137.     This function requests a device driver to perform the I/O command
  2138.     specified in the I/O request.  This function will always wait until
  2139.     the I/O request is fully complete.
  2140.  
  2141.     DoIO() handles all the details, including Quick I/O, waiting for
  2142.     the request, and removing the reply message, etc..
  2143.  
  2144.    IMPLEMENTATION
  2145.     This function first tries to complete the IO via the "Quick I/O"
  2146.     mechanism.  The io_Flags field is always set to IOF_QUICK (0x01)
  2147.     before the internal device call.
  2148.  
  2149.     The LN_TYPE field is used internally to flag completion.  Active
  2150.     requests have type NT_MESSAGE.  Requests that have been replied
  2151.     have type NT_REPLYMSG.  It is illegal to start IO using a
  2152.     still active IORequest, or a request with type NT_REPLYMSG.
  2153.  
  2154.    INPUTS
  2155.     iORequest - pointer to an IORequest initialized by OpenDevice()
  2156.  
  2157.    RESULTS
  2158.     error - a sign-extended copy of the io_Error field of the
  2159.         IORequest.  Most device commands require that the error
  2160.         return be checked.
  2161.  
  2162.    SEE ALSO
  2163.     SendIO, CheckIO, WaitIO, AbortIO, amiga.lib/BeginIO
  2164.  
  2165. exec.library/Enable                                       exec.library/Enable
  2166.  
  2167.    NAME
  2168.     Enable -- permit system interrupts to resume.
  2169.  
  2170.    SYNOPSIS
  2171.     Enable();
  2172.  
  2173.     void Enable(void);
  2174.  
  2175.    FUNCTION
  2176.     Allow system interrupts to again occur normally, after a matching
  2177.     Disable() has been executed.
  2178.  
  2179.    RESULTS
  2180.     Interrupt processing is restored to normal operation. The
  2181.     programmer must execute exactly one call to Enable() for every call
  2182.     to Disable().
  2183.  
  2184.     NOTE
  2185.     This call is guaranteed to preserve all registers.
  2186.  
  2187.    SEE ALSO
  2188.     Forbid, Permit, Disable
  2189.  
  2190.  
  2191. exec.library/Enqueue                                     exec.library/Enqueue
  2192.  
  2193.    NAME
  2194.     Enqueue -- insert or append node to a system queue
  2195.  
  2196.    SYNOPSIS
  2197.     Enqueue(list, node)
  2198.         A0    A1
  2199.  
  2200.     void Enqueue(struct List *, struct Node *);
  2201.  
  2202.    FUNCTION
  2203.     Insert or append a node into a system queue.  The insert is
  2204.     performed based on the node priority -- it will keep the list
  2205.     properly sorted.  New nodes will be inserted in front of the first
  2206.     node with a lower priority.   Hence a FIFO queue for nodes of equal
  2207.     priority
  2208.  
  2209.    WARNING
  2210.     This function does not arbitrate for access to the list.  The
  2211.     calling task must be the owner of the involved list.
  2212.  
  2213.    INPUTS
  2214.     list - a pointer to the system queue header
  2215.     node - the node to enqueue.  This must be a full featured node
  2216.            with type, priority and name fields.
  2217.  
  2218.    SEE ALSO
  2219.     AddHead, AddTail, Insert, Remove, RemHead, RemTail
  2220.  
  2221. exec.library/FindName                                   exec.library/FindName
  2222.  
  2223.    NAME
  2224.     FindName -- find a system list node with a given name
  2225.  
  2226.    SYNOPSIS
  2227.     node = FindName(start, name)
  2228.     D0,Z        A0     A1
  2229.  
  2230.     struct Node *FindName(struct List *, STRPTR);
  2231.  
  2232.    FUNCTION
  2233.     Traverse a system list until a node with the given name is found.
  2234.     To find multiple occurrences of a string, this function may be
  2235.     called with a node starting point.
  2236.  
  2237.     No arbitration is done for access to the list!    If multiple tasks
  2238.     access the same list, an arbitration mechanism such as
  2239.     SignalSemaphores must be used.
  2240.  
  2241.    INPUTS
  2242.     start - a list header or a list node to start the search
  2243.         (if node, this one is skipped)
  2244.     name - a pointer to a name string terminated with NULL
  2245.  
  2246.    RESULTS
  2247.     node - a pointer to the node with the same name else
  2248.         zero to indicate that the string was not found.
  2249.  
  2250. exec.library/FindPort                                   exec.library/FindPort
  2251.  
  2252.    NAME
  2253.     FindPort -- find a given system message port
  2254.  
  2255.    SYNOPSIS
  2256.     port = FindPort(name)
  2257.     D0        A1
  2258.  
  2259.     struct MsgPort *FindPort(STRPTR);
  2260.  
  2261.    FUNCTION
  2262.     This function will search the system message port list for a port
  2263.     with the given name.  The first port matching this name will be
  2264.     returned.  No arbitration of the port list is done.  This function
  2265.     MUST be protected with A Forbid()/Permit() pair!
  2266.  
  2267.    EXAMPLE
  2268.     #include <exec/types.h>
  2269.     struct MsgPort *FindPort();
  2270.  
  2271.     ULONG SafePutToPort(message, portname)
  2272.     struct Message *message;
  2273.     STRPTR          portname;
  2274.     {
  2275.     struct MsgPort *port;
  2276.  
  2277.         Forbid();
  2278.         port = FindPort(portname);
  2279.         if (port)
  2280.             PutMsg(port,message);
  2281.         Permit();
  2282.         return((ULONG)port); /* If zero, the port has gone away */
  2283.     }
  2284.  
  2285.    INPUT
  2286.     name - name of the port to find
  2287.  
  2288.    RETURN
  2289.     port - a pointer to the message port, or zero if
  2290.         not found.
  2291.  
  2292.  
  2293. exec.library/FindResident                           exec.library/FindResident
  2294.  
  2295.    NAME
  2296.     FindResident - find a resident module by name
  2297.  
  2298.    SYNOPSIS
  2299.     resident = FindResident(name)
  2300.     D0            A1
  2301.  
  2302.     struct Resident *FindResident(STRPTR);
  2303.  
  2304.    FUNCTION
  2305.     Search the system resident tag list for a resident tag ("ROMTag") with
  2306.     the given name.  If found return a pointer to the resident tag
  2307.     structure, else return zero.
  2308.  
  2309.     Resident modules are used by the system to pull all its parts
  2310.     together at startup.  Resident tags are also found in disk based
  2311.     devices and libraries.
  2312.  
  2313.    INPUTS
  2314.     name - pointer to name string
  2315.  
  2316.    RESULT
  2317.     resident - pointer to the resident tag structure or
  2318.         zero if none found.
  2319.  
  2320.     SEE ALSO
  2321.     exec/resident.h, InitResident
  2322.  
  2323. exec.library/FindSemaphore                         exec.library/FindSemaphore
  2324.  
  2325.    NAME
  2326.     FindSemaphore -- find a given system signal semaphore
  2327.  
  2328.    SYNOPSIS
  2329.     signalSemaphore = FindSemaphore(name)
  2330.     D0                        A1
  2331.  
  2332.     struct SignalSemaphore *FindSemaphore(STRPTR);
  2333.  
  2334.    FUNCTION
  2335.     This function will search the system signal semaphore list for a
  2336.     semaphore with the given name.    The first semaphore matching this
  2337.     name will be returned.
  2338.  
  2339.     This function does not arbitrate for access to the semaphore list,
  2340.     surround the call with a Forbid()/Permit() pair.
  2341.  
  2342.    INPUT
  2343.     name - name of the semaphore to find
  2344.  
  2345.    RESULT
  2346.     semaphore - a pointer to the signal semaphore, or zero if not
  2347.             found.
  2348.  
  2349. exec.library/FindTask                                   exec.library/FindTask
  2350.  
  2351.    NAME
  2352.     FindTask -- find a task with the given name or find oneself
  2353.  
  2354.    SYNOPSIS
  2355.     task = FindTask(name)
  2356.     D0        A1
  2357.  
  2358.     struct Task *FindTask(STRPTR);
  2359.  
  2360.    FUNCTION
  2361.     This function will check all task queues for a task with the given
  2362.     name, and return a pointer to its task control block.  If a NULL
  2363.     name pointer is given a pointer to the current task will be
  2364.     returned.
  2365.  
  2366.     Finding oneself with a NULL for the name is very quick.  Finding a
  2367.     task by name is very system expensive, and will disable interrupts
  2368.     for a long time.  Since a task may remove itself at any time,
  2369.     a Forbid()/Permit() pair may be needed to ensure the pointer
  2370.     returned by FindTask() is still valid when used.
  2371.  
  2372.    INPUT
  2373.     name - pointer to a name string
  2374.  
  2375.    RESULT
  2376.     task - pointer to the task (or Process)
  2377.  
  2378. exec.library/Forbid                                       exec.library/Forbid
  2379.  
  2380.     NAME
  2381.     Forbid -- forbid task rescheduling.
  2382.  
  2383.     SYNOPSIS
  2384.     Forbid()
  2385.  
  2386.     void Forbid(void);
  2387.  
  2388.     FUNCTION
  2389.     Prevents other tasks from being scheduled to run by the dispatcher,
  2390.     until a matching Permit() is executed, or this task is scheduled to
  2391.     Wait().  Interrupts are NOT disabled.
  2392.  
  2393.     DO NOT USE THIS CALL WITHOUT GOOD JUSTIFICATION.  THIS CALL IS
  2394.     DANGEROUS!
  2395.  
  2396.     RESULTS
  2397.     The current task will not be rescheduled as long as it is ready to
  2398.     run.  In the event that the current task enters a wait state, other
  2399.     tasks may be scheduled.  Upon return from the wait state, the original
  2400.     task will continue to run without disturbing the Forbid().
  2401.  
  2402.     Calls to Forbid() nest. In order to restore normal task rescheduling,
  2403.     the programmer must execute exactly one call to Permit() for every
  2404.     call to Forbid().
  2405.  
  2406.     WARNING
  2407.     In the event of a task entering a Wait() after a Forbid(), the system
  2408.     "breaks" the forbidden state and runs normally until the task which
  2409.     called Forbid() is rescheduled.  If caution is not taken, this can
  2410.     cause subtle bugs, since any device or DOS call will (in effect)
  2411.     cause your task to wait.
  2412.  
  2413.     Forbid() is not useful or safe from within interrupt code
  2414.     (All interrupts are always higher priority than tasks, and
  2415.     interrupts are allowed to break a Forbid()).
  2416.  
  2417.     NOTE
  2418.     This call is guaranteed to preserve all registers.
  2419.  
  2420.     SEE ALSO
  2421.     Permit, Disable, ObtainSemaphore, ObtainSemaphoreShared
  2422.  
  2423. exec.library/FreeEntry                                 exec.library/FreeEntry
  2424.  
  2425.    NAME
  2426.     FreeEntry -- free many regions of memory
  2427.  
  2428.    SYNOPSIS
  2429.     FreeEntry(memList)
  2430.           A0
  2431.     void FreeEntry(struct MemList *);
  2432.  
  2433.    FUNCTION
  2434.     This function takes a memList structure (as returned by AllocEntry)
  2435.     and frees all the entries.
  2436.  
  2437.    INPUTS
  2438.     memList -- pointer to structure filled in with MemEntry
  2439.            structures
  2440.  
  2441.    SEE ALSO
  2442.     AllocEntry
  2443.  
  2444. exec.library/FreeMem                                     exec.library/FreeMem
  2445.  
  2446.    NAME
  2447.     FreeMem -- deallocate with knowledge
  2448.  
  2449.    SYNOPSIS
  2450.     FreeMem(memoryBlock, byteSize)
  2451.         A1         D0
  2452.  
  2453.     void FreeMem(void *,ULONG);
  2454.  
  2455.    FUNCTION
  2456.     Free a region of memory, returning it to the system pool from which
  2457.     it came.  Freeing partial blocks back into the system pool is
  2458.     unwise.
  2459.  
  2460.    NOTE
  2461.     If a block of memory is freed twice, the system will Guru. The
  2462.     Alert is AN_FreeTwice ($01000009).   If you pass the wrong pointer,
  2463.     you will probably see AN_MemCorrupt $01000005.  Future versions may
  2464.     add more sanity checks to the memory lists.
  2465.  
  2466.    INPUTS
  2467.     memoryBlock - pointer to the memory block to free
  2468.     byteSize - the size of the desired block in bytes.  (The operating
  2469.         system will automatically round this number to a multiple of
  2470.         the system memory chunk size)
  2471.  
  2472.    SEE ALSO
  2473.     AllocMem
  2474.  
  2475. exec.library/FreePooled                               exec.library/FreePooled
  2476.  
  2477.     NAME
  2478.     FreePooled -- Free pooled memory  (V39)
  2479.  
  2480.     SYNOPSIS
  2481.     FreePooled(poolHeader,memory,memSize)
  2482.            a0         a1     d0
  2483.  
  2484.     void FreePooled(void *,void *,ULONG);
  2485.  
  2486.     FUNCTION
  2487.     Deallocates memory allocated by AllocPooled().  The size of the
  2488.     allocation *MUST* match the size given to AllocPooled().
  2489.     The reason the pool functions do not track individual allocation
  2490.     sizes is because many of the uses of pools have small allocation
  2491.     sizes and the tracking of the size would be a large overhead.
  2492.  
  2493.     Only memory allocated by AllocPooled() may be freed with this
  2494.     function!
  2495.  
  2496.     Doing a DeletePool() on the pool will free all of the puddles
  2497.     and thus all of the allocations done with AllocPooled() in that
  2498.     pool.  (No need to FreePooled() each allocation)
  2499.  
  2500.     INPUTS
  2501.     memory - pointer to memory allocated by AllocPooled.
  2502.     poolHeader - a specific private pool header.
  2503.  
  2504.     NOTES
  2505.     The pool function do not protect an individual pool from
  2506.     multiple accesses.  The reason is that in most cases the pools
  2507.     will be used by a single task.  If your pool is going to
  2508.     be used by more than one task you must Semaphore protect
  2509.     the pool from having more than one task trying to allocate
  2510.     within the same pool at the same time.  Warning:  Forbid()
  2511.     protection *will not work* in the future.  *Do NOT* assume
  2512.     that we will be able to make it work in the future.  FreePooled()
  2513.     may well break a Forbid() and as such can only be protected
  2514.     by a semaphore.
  2515.  
  2516.     To track sizes yourself, the following code can be used:
  2517.     Assumes a6=ExecBase
  2518.  
  2519.     ;
  2520.     ; Function to do AllocVecPooled(Pool,memSize)
  2521.     ;
  2522.     AllocVecPooled:    addq.l    #4,d0        ; Get space for tracking
  2523.             move.l    d0,-(sp)    ; Save the size
  2524.             jsr    _LVOAllocPooled(a6)    ; Call pool...
  2525.             move.l    (sp)+,d1    ; Get size back...
  2526.             tst.l    d0        ; Check for error
  2527.             beq.s    avp_fail    ; If NULL, failed!
  2528.             move.l    d0,a0        ; Get pointer...
  2529.             move.l    d1,(a0)+    ; Store size
  2530.             move.l    a0,d0        ; Get result
  2531.     avp_fail:    rts            ; return
  2532.  
  2533.     ;
  2534.     ; Function to do FreeVecPooled(pool,memory)
  2535.     ;
  2536.     FreeVecPooled:    move.l    -(a1),d0    ; Get size / ajust pointer
  2537.             jmp    _LVOFreePooled(a6)
  2538.  
  2539.     SEE ALSO
  2540.     AllocPooled(), CreatePool(), DeletePool()
  2541.  
  2542. exec.library/FreeSignal                               exec.library/FreeSignal
  2543.  
  2544.    NAME
  2545.     FreeSignal -- free a signal bit
  2546.  
  2547.    SYNOPSIS
  2548.     FreeSignal(signalNum)
  2549.            D0
  2550.  
  2551.     void FreeSignal(BYTE);
  2552.  
  2553.    FUNCTION
  2554.     This function frees a previously allocated signal bit for reuse.
  2555.     This call must be performed while running in the same task in which
  2556.     the signal was allocated.
  2557.  
  2558.    WARNING
  2559.     Signals may not be allocated or freed from exception handling code.
  2560.  
  2561.    NOTE
  2562.     Starting with V37, an attempt to free signal -1 is harmless.
  2563.  
  2564.    INPUTS
  2565.     signalNum - the signal number to free {0..31}.
  2566.  
  2567. exec.library/FreeTrap                                   exec.library/FreeTrap
  2568.  
  2569.    NAME
  2570.     FreeTrap -- free a processor trap
  2571.  
  2572.    SYNOPSIS
  2573.     FreeTrap(trapNum)
  2574.          D0
  2575.  
  2576.     void FreeTrap(ULONG);
  2577.  
  2578.    FUNCTION
  2579.     This function frees a previously allocated trap number for reuse.
  2580.     This call must be performed while running in the same task in which
  2581.     the trap was allocated.
  2582.  
  2583.    WARNING
  2584.     Traps may not be allocated or freed from exception handling code.
  2585.  
  2586.    INPUTS
  2587.     trapNum - the trap number to free {of 0..15}
  2588.  
  2589. exec.library/FreeVec                                     exec.library/FreeVec
  2590.  
  2591.    NAME
  2592.     FreeVec -- return AllocVec() memory to the system  (V36)
  2593.  
  2594.    SYNOPSIS
  2595.     FreeVec(memoryBlock)
  2596.         A1
  2597.  
  2598.     void FreeVec(void *);
  2599.  
  2600.    FUNCTION
  2601.     Free an allocation made by the AllocVec() call.  The memory will
  2602.     be returned to the system pool from which it came.
  2603.  
  2604.    NOTE
  2605.     If a block of memory is freed twice, the system will Guru. The
  2606.     Alert is AN_FreeTwice ($01000009).   If you pass the wrong pointer,
  2607.     you will probably see AN_MemCorrupt $01000005.  Future versions may
  2608.     add more sanity checks to the memory lists.
  2609.  
  2610.    INPUTS
  2611.     memoryBlock - pointer to the memory block to free, or NULL.
  2612.  
  2613.    SEE ALSO
  2614.     AllocVec
  2615.  
  2616. exec.library/GetCC                                         exec.library/GetCC
  2617.  
  2618.    NAME
  2619.     GetCC -- get condition codes in a 68010 compatible way.
  2620.  
  2621.    SYNOPSIS
  2622.     conditions = GetCC()
  2623.       D0
  2624.  
  2625.     UWORD GetCC(void);
  2626.  
  2627.    FUNCTION
  2628.     The 68000 processor has a "MOVE SR,<ea>" instruction which gets a
  2629.     copy of the processor condition codes.
  2630.  
  2631.     On the 68010,20 and 30 CPUs, "MOVE SR,<ea>" is privileged.  User
  2632.     code will trap if it is attempted.  These processors need to use
  2633.     the "MOVE CCR,<ea>" instruction instead.
  2634.  
  2635.     This function provides a means of obtaining the CPU condition codes
  2636.     in a manner that will make upgrades transparent.  This function is
  2637.     VERY short and quick.
  2638.  
  2639.    RESULTS
  2640.     conditions - the 680XX condition codes
  2641.  
  2642.     NOTE
  2643.     This call is guaranteed to preserve all registers.  This function
  2644.     may be implemented as code right in the jump table.
  2645.  
  2646. exec.library/GetMsg                                       exec.library/GetMsg
  2647.  
  2648.    NAME
  2649.     GetMsg -- get next message from a message port
  2650.  
  2651.    SYNOPSIS
  2652.     message = GetMsg(port)
  2653.     D0         A0
  2654.  
  2655.     struct Message *GetMsg(struct MsgPort *);
  2656.  
  2657.    FUNCTION
  2658.     This function receives a message from a given message port. It
  2659.     provides a fast, non-copying message receiving mechanism. The
  2660.     received message is removed from the message port.
  2661.  
  2662.     This function will not wait.  If a message is not present this
  2663.     function will return zero.  If a program must wait for a message,
  2664.     it can Wait() on the signal specified for the port or use the
  2665.     WaitPort() function.  There can only be one task waiting for any
  2666.     given port.
  2667.  
  2668.     Getting a message does not imply to the sender that the message is
  2669.     free to be reused by the sender.  When the receiver is finished
  2670.     with the message, it may ReplyMsg() it back to the sender.
  2671.  
  2672.  
  2673.     Getting a signal does NOT always imply a message is ready.  More
  2674.     than one message may arrive per signal, and signals may show up
  2675.     without messages.  Typically you must loop to GetMsg() until it
  2676.     returns zero, then Wait() or WaitPort().
  2677.  
  2678.    INPUT
  2679.     port - a pointer to the receiver message port
  2680.  
  2681.    RESULT
  2682.     message - a pointer to the first message available.  If
  2683.           there are no messages, return zero.
  2684.           Callers must be prepared for zero at any time.
  2685.  
  2686.    SEE ALSO
  2687.     PutMsg, ReplyMsg, WaitPort, Wait, exec/ports.h
  2688.  
  2689. exec.library/InitCode                                   exec.library/InitCode
  2690.  
  2691.    NAME
  2692.     InitCode - initialize resident code modules (internal function)
  2693.  
  2694.    SYNOPSIS
  2695.     InitCode(startClass, version)
  2696.          D0          D1
  2697.  
  2698.     void InitCode(ULONG,ULONG);
  2699.  
  2700.    FUNCTION
  2701.     (This function may be ignored by application programmers)
  2702.  
  2703.     Call InitResident() for all resident modules in the ResModules array
  2704.     with the given startClass and with versions equal or greater than
  2705.     that specified.  The segList parameter is passed as zero.
  2706.  
  2707.     Resident modules are used by the system to pull all its parts
  2708.     together at startup.  Modules are initialized in a prioritized order.
  2709.  
  2710.     Modules that do not have a startclass should be of priority -120.
  2711.     RTF_AFTERDOS modules should start at -100 (working down).
  2712.  
  2713.    INPUTS
  2714.     startClass - the class of code to be initialized:
  2715.         BITDEF RT,COLDSTART,0
  2716.         BITDEF RT,SINGLETASK,1    ;ExecBase->ThisTask==0 (V36 only)
  2717.         BITDEF RT,AFTERDOS,2    ;(V36 only)
  2718.     version - a major version number
  2719.  
  2720.     SEE ALSO
  2721.     ResidentTag (RT) structure definition (resident.h)
  2722.  
  2723. exec.library/InitResident                           exec.library/InitResident
  2724.  
  2725.    NAME
  2726.     InitResident - initialize resident module
  2727.  
  2728.    SYNOPSIS
  2729.     object = InitResident(resident, segList)
  2730.     D0                   A1        D1
  2731.  
  2732.     APTR InitResident(struct Resident *,ULONG);
  2733.  
  2734.    FUNCTION
  2735.     Initialize a ROMTag.  ROMTags are used to link system modules
  2736.     together.  Each disk based device or library must contain a
  2737.     ROMTag structure in the first code hunk.
  2738.  
  2739.     Once the validity of the ROMTag is verified, the RT_INIT pointer
  2740.     is jumped to  with the following registers:
  2741.         D0 = 0
  2742.         A0 = segList
  2743.          A6 = ExecBase
  2744.  
  2745.    INPUTS
  2746.     resident - Pointer to a ROMTag
  2747.     segList  - SegList of the loaded object, if loaded from disk.
  2748.            Libraries & Devices will cache this value for later
  2749.            return at close or expunge time.  Pass NULL for ROM
  2750.            modules.
  2751.  
  2752.    RESULTS
  2753.     object    - Return value from the init code, usually the library
  2754.           or device base.  NULL for failure.
  2755.  
  2756.    AUTOINIT FEATURE
  2757.     An automatic method of library/device base and vector table
  2758.     initialization is also provided by InitResident().  The initial code
  2759.     hunk of the library or device should contain "MOVEQ #-1,d0; RTS;".
  2760.     Following that must be an initialized Resident structure with
  2761.     RTF_AUTOINIT set in rt_Flags, and an rt_Init pointer which points
  2762.     to four longwords.  These four longwords will be used in a call
  2763.     to MakeLibrary();
  2764.  
  2765.         - The size of your library/device base structure including initial
  2766.           Library or Device structure.
  2767.  
  2768.         - A pointer to a longword table of standard, then library
  2769.           specific function offsets, terminated with -1L.
  2770.           (short format offsets are also acceptable)
  2771.  
  2772.         - Pointer to data table in exec/InitStruct format for
  2773.           initialization of Library or Device structure.
  2774.  
  2775.         - Pointer to library initialization function, or NULL.
  2776.         Calling sequence:
  2777.             D0 = library base
  2778.             A0 = segList
  2779.             A6 = ExecBase
  2780.           This function must return in D0 the library/device base to be
  2781.           linked into the library/device list.  If the initialization
  2782.           function fails, the device memory must be manually deallocated,
  2783.           then NULL returned in D0.
  2784.  
  2785.    SEE ALSO
  2786.     exec/resident.i, FindResident
  2787.  
  2788. exec.library/InitSemaphore                         exec.library/InitSemaphore
  2789.  
  2790.    NAME
  2791.     InitSemaphore -- initialize a signal semaphore
  2792.  
  2793.    SYNOPSIS
  2794.     InitSemaphore(signalSemaphore)
  2795.               A0
  2796.  
  2797.     void InitSemaphore(struct SignalSemaphore *);
  2798.  
  2799.    FUNCTION
  2800.     This function initializes a signal semaphore and prepares it for
  2801.     use.  It does not allocate anything, but does initialize list
  2802.     pointers and the semaphore counters.
  2803.  
  2804.     Semaphores are often used to protect critical data structures
  2805.     or hardware that can only be accessed by one task at a time.
  2806.     After initialization, the address of the SignalSemaphore may be
  2807.     made available to any number of tasks.  Typically a task will
  2808.     try to ObtainSemaphore(), passing this address in.  If no other
  2809.     task owns the semaphore, then the call will lock and return
  2810.     quickly.  If more tasks try to ObtainSemaphore(), they will
  2811.     be put to sleep.  When the owner of the semaphore releases
  2812.     it, the next waiter in turn will be woken up.
  2813.  
  2814.     Semaphores are often preferable to the old-style Forbid()/Permit()
  2815.     type arbitration.  With Forbid()/Permit() *all* other tasks are
  2816.     prevented from running.  With semaphores, only those tasks that
  2817.     need access to whatever the semaphore protects are subject
  2818.     to waiting.
  2819.  
  2820.    INPUT
  2821.     signalSemaphore -- a signal semaphore structure (with all fields
  2822.                set to zero before the call)
  2823.  
  2824.    SEE ALSO
  2825.     ObtainSemaphore, ObtainSemaphoreShared, AttemptSemaphore,
  2826.     ReleaseSemaphore, Procure, Vacate, exec/semaphores.h
  2827.  
  2828. exec.library/InitStruct                               exec.library/InitStruct
  2829.  
  2830.    NAME
  2831.     InitStruct - initialize memory from a table
  2832.  
  2833.    SYNOPSIS
  2834.     InitStruct(initTable, memory, size);
  2835.            A1          A2      D0
  2836.  
  2837.     void InitStruct(struct InitStruct *, APTR, ULONG);
  2838.  
  2839.    FUNCTION
  2840.     Clear a memory area, then set up default values according to
  2841.     the data and offset values in the initTable.  Typically only assembly
  2842.     programs take advantage of this function, and only with the macros
  2843.     defined in "exec/initializers.i".
  2844.  
  2845.     The initialization table has byte commands to
  2846.  
  2847.          |a    ||byte|    |given||byte|          |once        |
  2848.     load |count||word| into |next ||rptr| offset, |repetitively |
  2849.             |long|
  2850.  
  2851.     Not all combinations are supported.  The offset, when specified, is
  2852.     relative to the memory pointer provided (Memory), and is initially
  2853.     zero.  The initialization data (InitTable) contains byte commands
  2854.     whose 8 bits are interpreted as follows:
  2855.  
  2856.     ddssnnnn
  2857.         dd    the destination type (and size):
  2858.         00  no offset, use next destination, nnnn is count
  2859.         01  no offset, use next destination, nnnn is repeat
  2860.         10  destination offset is in the next byte, nnnn is count
  2861.         11  destination offset is in the next 24-bits, nnnn is count
  2862.         ss    the size and location of the source:
  2863.         00  long, from the next two aligned words
  2864.         01  word, from the next aligned word
  2865.         10  byte, from the next byte
  2866.         11  ERROR - will cause an ALERT (see below)
  2867.       nnnn    the count or repeat:
  2868.          count  the (number+1) of source items to copy
  2869.         repeat  the source is copied (number+1) times.
  2870.  
  2871.     initTable commands are always read from the next even byte. Given
  2872.     destination offsets are always relative to the memory pointer (A2).
  2873.  
  2874.     The command %00000000 ends the InitTable stream: use %00010001 if you
  2875.     really want to copy one longword without a new offset.
  2876.  
  2877.     24 bit APTR not supported for 68020 compatibility -- use long.
  2878.  
  2879.    INPUTS
  2880.     initTable - the beginning of the commands and data to init
  2881.         Memory with.  Must be on an even boundary unless only
  2882.         byte initialization is done.  End table with "dc.b 0"
  2883.         or "dc.w 0".
  2884.     memory - the beginning of the memory to initialize.  Must be
  2885.         on an even boundary if size is specified.
  2886.     size - the size of memory, which is used to clear it before
  2887.         initializing it via the initTable.  If Size is zero,
  2888.         memory is not cleared before initializing.
  2889.  
  2890.         size must be an even number.
  2891.  
  2892.     SEE ALSO
  2893.     exec/initializers.i
  2894.  
  2895. exec.library/Insert                                       exec.library/Insert
  2896.  
  2897.    NAME
  2898.     Insert -- insert a node into a list
  2899.  
  2900.    SYNOPSIS
  2901.     Insert(list, node, listNode)
  2902.            A0    A1    A2
  2903.  
  2904.     void Insert(struct List *, struct Node *, struct Node *);
  2905.  
  2906.    FUNCTION
  2907.     Insert a node into a doubly linked list AFTER a given node
  2908.     position.  Insertion at the head of a list is possible by passing a
  2909.     zero value for listNode, though the AddHead function is slightly
  2910.     faster for that special case.
  2911.  
  2912.    WARNING
  2913.     This function does not arbitrate for access to the list.  The
  2914.     calling task must be the owner of the involved list.
  2915.  
  2916.    INPUTS
  2917.     list - a pointer to the target list header
  2918.     node - the node to insert
  2919.     listNode - the node after which to insert
  2920.  
  2921.     SEE ALSO
  2922.     AddHead, AddTail, Enqueue, RemHead, Remove, RemTail
  2923.  
  2924. exec.library/MakeFunctions                         exec.library/MakeFunctions
  2925.  
  2926.    NAME
  2927.     MakeFunctions -- construct a function jump table
  2928.  
  2929.    SYNOPSIS
  2930.     tableSize = MakeFunctions(target, functionArray, funcDispBase)
  2931.     D0              A0      A1         A2
  2932.  
  2933.     ULONG MakeFunctions(APTR,APTR,APTR);
  2934.  
  2935.    FUNCTION
  2936.     A low level function used by MakeLibrary to build jump tables of
  2937.     the type used by libraries, devices and resources.  It allows the
  2938.     table to be built anywhere in memory, and can be used both for
  2939.     initialization and replacement. This function also supports function
  2940.     pointer compression by expanding relative displacements into absolute
  2941.     pointers.
  2942.  
  2943.     The processor instruction cache is cleared after the table building.
  2944.  
  2945.    INPUT
  2946.     destination - the target address for the high memory end of the
  2947.         function jump table.  Typically this will be the library
  2948.         base pointer.
  2949.  
  2950.     functionArray - pointer to an array of function pointers or
  2951.         function displacements.  If funcDispBase is zero, the array
  2952.         is assumed to contain absolute pointers to functions. If
  2953.         funcDispBase is not zero, then the array is assumed to
  2954.         contain word displacements to functions.  In both cases,
  2955.         the array is terminated by a -1 (of the same size as the
  2956.         actual entry.
  2957.  
  2958.     funcDispBase - pointer to the base about which all function
  2959.         displacements are relative.  If zero, then the function
  2960.         array contains absolute pointers.
  2961.  
  2962.    RESULT
  2963.     tableSize - size of the new table in bytes (for LIB_NEGSIZE).
  2964.  
  2965.    SEE ALSO
  2966.     exec/MakeLibrary
  2967.  
  2968. exec.library/MakeLibrary                             exec.library/MakeLibrary
  2969.  
  2970.    NAME
  2971.     MakeLibrary -- construct a library
  2972.  
  2973.    SYNOPSIS
  2974.     library = MakeLibrary(vectors, structure, init, dSize, segList)
  2975.     D0              A0       A1      A2    D0     D1
  2976.  
  2977.     struct Library *MakeLibrary
  2978.                   (APTR,struct InitStruct *,APTR,ULONG,BPTR);
  2979.  
  2980.    FUNCTION
  2981.     This function is used for constructing a library vector and data
  2982.     area.  The same call is used to make devices.  Space for the library
  2983.     is allocated from the system's free memory pool.  The data portion of
  2984.     the library is initialized.  init may point to a library specific
  2985.     entry point.
  2986.  
  2987.    NOTE
  2988.     Starting with V36, the library base is longword adjusted.  The
  2989.     lib_PosSize and lib_NegSize fields of the library structure are
  2990.     adjusted to match.
  2991.  
  2992.    INPUTS
  2993.     vectors - pointer to an array of function pointers or function
  2994.         displacements.    If the first word of the array is -1, then
  2995.         the array contains relative word displacements (based off
  2996.         of vectors); otherwise, the array contains absolute
  2997.         function pointers. The vector list is terminated by a -1
  2998.         (of the same size as the pointers).
  2999.  
  3000.     structure - points to an "InitStruct" data region.  If NULL,
  3001.         then it will not be used.
  3002.  
  3003.     init -    If non-NULL, an entry point that will be called before adding
  3004.         the library to the system.  Registers are as follows:
  3005.             d0 = libAddr     ;Your Library Address
  3006.             a0 = segList    ;Your AmigaDOS segment list
  3007.             a6 = ExecBase    ;Address of exec.library
  3008.         The result of the init function must be the library address,
  3009.         or NULL for failure.   If NULL, the init point must manually
  3010.         deallocate the library base memory (based on the sizes stored
  3011.         in lib_PosSize and lib_NegSize).
  3012.  
  3013.     dSize - the size of the library data area, including the
  3014.         standard library node data.  This must be at leas
  3015.         sizeof(struct Library).
  3016.  
  3017.        segList - pointer to an AmigaDOS SegList (segment list).
  3018.          This is passed to a library's init code, and is used later
  3019.          for removing the library from memory.
  3020.  
  3021.    RESULT
  3022.     library - the reference address of the library.  This is the
  3023.           address used in references to the library, not the
  3024.           beginning of the memory area allocated.  If the library
  3025.           vector table require more system memory than is
  3026.           available, this function will return NULL.
  3027.  
  3028.    SEE ALSO
  3029.     InitStruct, InitResident, exec/initializers.i
  3030.  
  3031. exec.library/ObtainQuickVector                 exec.library/ObtainQuickVector
  3032.  
  3033.    NAME
  3034.     Function to obtain an install a Quick Interrupt vector            (V39)
  3035.  
  3036.    SYNOPSIS
  3037.     vector=ObtainQuickVector(interruptCode)
  3038.     d0                       a0
  3039.  
  3040.     ULONG ObtainQuickVector(APTR);
  3041.  
  3042.    FUNCTION
  3043.     This function will install the code pointer into the quick interrupt
  3044.     vector it allocates and returns to you the interrupt vector that
  3045.     your Quick Interrupt system needs to use.
  3046.  
  3047.     This function may also return 0 if no vectors are available.  Your
  3048.     hardware should be able to then fall back to using the shared
  3049.     interrupt server chain should this happen.
  3050.  
  3051.     The interrupt code is a direct connect to the physical interrupt.
  3052.     This means that it is the responsibility of your code to do all
  3053.     of the context saving/restoring required by interrupt code.
  3054.  
  3055.     Also, due to the performance of the interrupt controller, you may
  3056.     need to also watch for "false" interrupts.  These are interrupts
  3057.     that come in just after a DISABLE.  The reason this happens is
  3058.     because the interrupt may have been posted before the DISABLE
  3059.     hardware access is completed.  For example:
  3060.  
  3061.     myInt:        move.l    d0,-(sp)    ; Save d0...
  3062.             move.w    _intenar,d0    ; Get interrupt enable state
  3063.             btst.l    #INTB_INTEN,d0    ; Check if pending disable
  3064.             bne.s    realInt        ; If not, do real one...
  3065.     exitInt:    move.l    (sp)+,d0    ; Restore d0
  3066.             rte            ; Return from int...
  3067.     ;
  3068.     realInt:    ; Now do your int code...  d0 is already saved
  3069.             ; ALL other registers need to be saved if needed
  3070.             ; This includes a0/a1/d0/d1 as this is an interrupt
  3071.             ; and not a function call...
  3072.             ;
  3073.             bra.s    exitInt        ; Exit interrupt...
  3074.  
  3075.     If your interrupt will not play with system (OS) structures and your
  3076.     own structures are safe to play with you do not need to check for
  3077.     the disable.  It is only needed for when the system is in disable but
  3078.     that "one last interrupt" still got through.
  3079.  
  3080.    NOTE
  3081.     This function was not implemented fully until V39.  Due to a mis-cue
  3082.     it is not safe to call in V37 EXEC.  (Sorry)
  3083.  
  3084.    INPUTS
  3085.     A pointer to your interrupt code.  This code is not an EXEC interrupt
  3086.     but is dirrectly connected to the hardware interrupt.  Thus, the
  3087.     interrupt code must not modify any registers and must return via
  3088.     an RTE.
  3089.  
  3090.    RESULTS
  3091.     The 8-bit vector number used for Zorro-III Quick Interrupts
  3092.     If it returns 0, no quick interrupt was allocatable.  The device
  3093.     should at this point switch to using the shared interrupt server
  3094.     method.
  3095.  
  3096.    SEE ALSO
  3097.  
  3098. exec.library/ObtainSemaphore                     exec.library/ObtainSemaphore
  3099.  
  3100.    NAME
  3101.     ObtainSemaphore -- gain exclusive access to a semaphore
  3102.  
  3103.    SYNOPSIS
  3104.     ObtainSemaphore(signalSemaphore)
  3105.             A0
  3106.  
  3107.     void ObtainSemaphore(struct SignalSemaphore *);
  3108.  
  3109.    FUNCTION
  3110.     Signal semaphores are used to gain exclusive access to an object.
  3111.     ObtainSemaphore is the call used to gain this access.  If another
  3112.     user currently has the semaphore locked the call will block until
  3113.     the object is available.
  3114.  
  3115.     If the current task already has locked the semaphore and attempts to
  3116.     lock it again the call will still succeed.  A "nesting count" is
  3117.     incremented each time the current owning task of the semaphore calls
  3118.     ObtainSemaphore().  This counter is decremented each time
  3119.     ReleaseSemaphore() is called.  When the counter returns to zero the
  3120.     semaphore is actually released, and the next waiting task is called.
  3121.  
  3122.     A queue of waiting tasks is maintained on the stacks of the waiting
  3123.     tasks.    Each will be called in turn as soon as the current task
  3124.     releases the semaphore.
  3125.  
  3126.     Signal Semaphores are different than Procure()/Vacate() semaphores.
  3127.     The former requires less CPU time, especially if the semaphore is
  3128.     not currently locked.  They require very little set up and user
  3129.     thought.  The latter flavor of semaphore make no assumptions about
  3130.     how they are used -- they are completely general.  Unfortunately
  3131.     they are not as efficient as signal semaphores, and require the
  3132.     locker to have done some setup before doing the call.
  3133.  
  3134.    INPUT
  3135.        signalSemaphore -- an initialized signal semaphore structure
  3136.  
  3137.    NOTE
  3138.     This function preserves all registers (see BUGS).
  3139.  
  3140.    BUGS
  3141.     Until V37, this function could destroy A0.
  3142.  
  3143.    SEE ALSO
  3144.     ObtainSemaphoreShared(), InitSemaphore(), ReleaseSemaphore(),
  3145.     AttemptSemaphore(), ObtainSemaphoreList(), Procure(), Vacate()
  3146.  
  3147. exec.library/ObtainSemaphoreList             exec.library/ObtainSemaphoreList
  3148.  
  3149.    NAME
  3150.     ObtainSemaphoreList -- get a list of semaphores.
  3151.  
  3152.    SYNOPSIS
  3153.     ObtainSemaphoreList(list)
  3154.                 A0
  3155.  
  3156.     void ObtainSemaphoreList(struct List *);
  3157.  
  3158.    FUNCTION
  3159.     Signal semaphores may be linked together into a list. This function
  3160.     takes a list of these semaphores and attempts to lock all of them at
  3161.     once. This call is preferable to applying ObtainSemaphore() to each
  3162.     element in the list because it attempts to lock all the elements
  3163.     simultaneously, and won't deadlock if someone is attempting to lock
  3164.     in some other order.
  3165.  
  3166.     This function assumes that only one task at a time will attempt to
  3167.     lock the entire list of semaphores.  In other words, there needs to
  3168.     be a higher level lock (perhaps another signal semaphore...) that is
  3169.     used before someone attempts to lock the semaphore list via
  3170.     ObtainSemaphoreList().
  3171.  
  3172.     Note that deadlocks may result if this call is used AND someone
  3173.     attempts to use ObtainSemaphore() to lock more than one semaphore on
  3174.     the list.  If you wish to lock more than semaphore (but not all of
  3175.     them) then you should obtain the higher level lock (see above)
  3176.  
  3177.    INPUT
  3178.        list -- a list of signal semaphores
  3179.  
  3180.    SEE ALSO
  3181.     ObtainSemaphoreShared(), InitSemaphore(), ReleaseSemaphore(),
  3182.     AttemptSemaphore(), ObtainSemaphoreShared(), Procure(), Vacate()
  3183.  
  3184. exec.library/ObtainSemaphoreShared         exec.library/ObtainSemaphoreShared
  3185.  
  3186.     NAME
  3187.     ObtainSemaphoreShared -- gain shared access to a semaphore (V36)
  3188.  
  3189.     SYNOPSIS
  3190.     ObtainSemaphoreShared(signalSemaphore)
  3191.                           a0
  3192.  
  3193.     void ObtainSemaphoreShared(struct SignalSemaphore *);
  3194.  
  3195.     FUNCTION
  3196.     A lock on a signal semaphore may either be exclusive, or shared.
  3197.     Exclusive locks are granted by the ObtainSemaphore() and
  3198.     AttemptSemaphore() functions.  Shared locks are granted by
  3199.     ObtainSemaphoreShared().  Calls may be nested.
  3200.  
  3201.     Any number of tasks may simultaneously hold a shared lock on a
  3202.     semaphore.  Only one task may hold an exclusive lock.  A typical
  3203.     application is a list that is often read, but only occasionally
  3204.     written to.
  3205.  
  3206.     Any exlusive locker will be held off until all shared lockers
  3207.     release the semaphore.  Likewise, if an exlusive lock is held,
  3208.     all potential shared lockers will block until the exclusive lock
  3209.     is released.  All shared lockers are restarted at the same time.
  3210.  
  3211.     EXAMPLE
  3212.         ObtainSemaphoreShared(ss);
  3213.         /* read data */
  3214.         ReleaseSemaohore(ss);
  3215.  
  3216.         ObtainSemaphore(ss);
  3217.         /* modify data */
  3218.         ReleaseSemaohore(ss);
  3219.  
  3220.     NOTES
  3221.     While this function was added for V36, the feature magically works
  3222.     with all older semaphore structures.
  3223.  
  3224.     A task owning a shared lock must not attempt to get an exclusive
  3225.     lock on the same semaphore.
  3226.  
  3227.     Starting in V39, if the caller already has an exclusive lock on the
  3228.     semaphore it will return with another nesting of the lock.  Pre-V39
  3229.     this would cause a deadlock.  For pre-V39 use, you can use the
  3230.     following workaround:
  3231.  
  3232.         /* Try to get the shared semaphore */
  3233.         if (!AttemptSemaphoreShared(ss))
  3234.         {
  3235.             /* Check if we can get the exclusive version */
  3236.             if (!AttemptSemaphore(ss))
  3237.             {
  3238.                 /* Oh well, wait for the shared lock */
  3239.                 ObtainSemaphoreShared(ss));
  3240.             }
  3241.         }
  3242.         :
  3243.         :
  3244.         ReleaseSemaphore(ss);
  3245.  
  3246.     INPUT
  3247.     signalSemaphore -- an initialized signal semaphore structure
  3248.  
  3249.     NOTE
  3250.     This call is guaranteed to preserve all registers, starting with
  3251.     V37 exec.
  3252.  
  3253.     RESULT
  3254.  
  3255.     SEE ALSO
  3256.     ObtainSemaphore(), InitSemaphore(), ReleaseSemaphore(),
  3257.     AttemptSemaphore(), ObtainSemaphoreList(), Procure(), Vacate()
  3258.  
  3259. exec.library/OldOpenLibrary                       exec.library/OldOpenLibrary
  3260.  
  3261.    NAME
  3262.     OldOpenLibrary -- obsolete OpenLibrary
  3263.  
  3264.    SYNOPSIS
  3265.     library = OldOpenLibrary(libName)
  3266.     D0             A1
  3267.  
  3268.     struct Library *OldOpenLibrary(APTR);
  3269.  
  3270.    FUNCTION
  3271.     The 1.0 release of the Amiga system had an incorrect version of
  3272.     OpenLibrary that did not check the version number during the
  3273.     library open.  This obsolete function is provided so that object
  3274.     code compiled using a 1.0 system will still run.
  3275.  
  3276.     This exactly the same as "OpenLibrary(libName,0L);"
  3277.  
  3278.    INPUTS
  3279.     libName - the name of the library to open
  3280.  
  3281.    RESULTS
  3282.     library - a library pointer for a successful open, else zero
  3283.  
  3284.    SEE ALSO
  3285.     CloseLibrary
  3286.  
  3287. exec.library/OpenDevice                               exec.library/OpenDevice
  3288.  
  3289.    NAME
  3290.     OpenDevice -- gain access to a device
  3291.  
  3292.    SYNOPSIS
  3293.     error = OpenDevice(devName, unitNumber, iORequest, flags)
  3294.     D0           A0        D0        A1       D1
  3295.  
  3296.     BYTE OpenDevice(STRPTR,ULONG,struct IORequest *,ULONG);
  3297.  
  3298.    FUNCTION
  3299.     This function opens the named device/unit and initializes the given
  3300.     I/O request block.  Specific documentation on opening procedures
  3301.     may come with certain devices.
  3302.  
  3303.     The device may exist in memory, or on disk; this is transparent to
  3304.     the OpenDevice caller.
  3305.  
  3306.     A full path name for the device name is legitimate.  For example
  3307.     "test:devs/fred.device".  This allows the use of custom devices
  3308.     without requiring the user to copy the device into the system's
  3309.     DEVS: directory.
  3310.  
  3311.    NOTES
  3312.     All calls to OpenDevice should have matching calls to CloseDevice!
  3313.  
  3314.     Devices on disk cannot be opened until after DOS has been
  3315.     started.
  3316.  
  3317.     As of V36 tasks can safely call OpenDevice, though DOS may open
  3318.     system requesters (e.g., asking the user to insert the Workbench
  3319.     disk if DEVS: is not online).  You must call this function from a
  3320.     DOS Process if you want to turn off DOS requesters.
  3321.  
  3322.    INPUTS
  3323.     devName - requested device name
  3324.  
  3325.     unitNumber - the unit number to open on that device.  The format of
  3326.         the unit number is device specific.  If the device does
  3327.         not have separate units, send a zero.
  3328.  
  3329.     iORequest - the I/O request block to be returned with
  3330.         appropriate fields initialized.
  3331.  
  3332.     flags - additional driver specific information.  This is sometimes
  3333.         used to request opening a device with exclusive access.
  3334.  
  3335.    RESULTS
  3336.     error - Returns a sign-extended copy of the io_Error field
  3337.         of the IORequest.  Zero if successful, else an error code
  3338.         is returned.
  3339.  
  3340.    BUGS
  3341.     AmigaDOS file names are not case sensitive, but Exec lists are.  If
  3342.     the library name is specified in a different case than it exists on
  3343.     disk, unexpected results may occur.
  3344.  
  3345.     Prior to V36, tasks could not make OpenDevice calls requiring disk
  3346.     access (since tasks are not allowed to make dos.library calls).
  3347.     Now OpenDevice is protected from tasks.
  3348.  
  3349.    SEE ALSO
  3350.     CloseDevice, DoIO, SendIO, CheckIO, AbortIO, WaitIO
  3351.  
  3352. exec.library/OpenLibrary                             exec.library/OpenLibrary
  3353.  
  3354.    NAME
  3355.     OpenLibrary -- gain access to a library
  3356.  
  3357.    SYNOPSIS
  3358.     library = OpenLibrary(libName, version)
  3359.     D0              A1       D0
  3360.  
  3361.     struct Library *OpenLibrary(STRPTR, ULONG);
  3362.  
  3363.    FUNCTION
  3364.     This function returns a pointer to a library that was previously
  3365.     installed into the system.  If the requested library is exists, and
  3366.     if the library version is greater than or equal to the requested
  3367.     version, then the open will succeed.
  3368.  
  3369.     The library may exist in memory, or on disk; this is transparent to
  3370.     the OpenLibrary caller.  Only Processes are allowed to call
  3371.     OpenLibrary (since OpenLibrary may in turn call dos.library).
  3372.  
  3373.     A full path name for the library name is legitimate.  For example
  3374.     "wp:libs/wp.library".  This allows the use of custom libraries
  3375.     without requiring the user to copy the library into the system's
  3376.     LIBS: directory.
  3377.  
  3378.    NOTES
  3379.     All calls to OpenLibrary should have matching calls to CloseLibrary!
  3380.  
  3381.     Libraries on disk cannot be opened until after DOS has been
  3382.     started.
  3383.  
  3384.     As of V36 tasks can safely call OpenLibrary, though DOS may open
  3385.     system requesters (e.g., asking the user to insert the Workbench
  3386.     disk if LIBS: is not online).  You must call this function from a
  3387.     DOS Process if you want to turn off DOS requesters.
  3388.  
  3389.    INPUTS
  3390.     libName - the name of the library to open
  3391.  
  3392.     version - the version of the library required.
  3393.  
  3394.    RESULTS
  3395.     library - a library pointer for a successful open, else zero
  3396.  
  3397.    BUGS
  3398.     AmigaDOS file names are not case sensitive, but Exec lists are. If
  3399.     the library name is specified in a different case than it exists on
  3400.     disk, unexpected results may occur.
  3401.  
  3402.     Prior to V36, tasks could not make OpenLibrary calls requiring disk
  3403.     access (since tasks are not allowed to make dos.library calls).
  3404.     Now OpenLibrary is protected from tasks.
  3405.  
  3406.     The version number of the resident tag in disk based library must
  3407.     match the version number of the library, or V36 may fail to load it.
  3408.  
  3409.    SEE ALSO
  3410.     CloseLibrary
  3411.  
  3412. exec.library/OpenResource                           exec.library/OpenResource
  3413.  
  3414.    NAME
  3415.     OpenResource -- gain access to a resource
  3416.  
  3417.    SYNOPSIS
  3418.     resource = OpenResource(resName)
  3419.     D0            A1
  3420.  
  3421.     APTR OpenResource(STRPTR);
  3422.  
  3423.    FUNCTION
  3424.     This function returns a pointer to a resource that was previously
  3425.     installed into the system.
  3426.  
  3427.     There is no CloseResource() function.
  3428.  
  3429.    INPUTS
  3430.        resName - the name of the resource requested.
  3431.  
  3432.    RESULTS
  3433.     resource - if successful, a resource pointer, else NULL
  3434.  
  3435. exec.library/Permit                                       exec.library/Permit
  3436.  
  3437.     NAME
  3438.     Permit -- permit task rescheduling.
  3439.  
  3440.     SYNOPSIS
  3441.     Permit()
  3442.  
  3443.     void Permit(void);
  3444.  
  3445.     FUNCTION
  3446.     Allow other tasks to be scheduled to run by the dispatcher, after a
  3447.     matching Forbid() has been executed.
  3448.  
  3449.     RESULTS
  3450.     Other tasks will be rescheduled as they are ready to run. In order
  3451.     to restore normal task rescheduling, the programmer must execute
  3452.     exactly one call to Permit() for every call to Forbid().
  3453.  
  3454.     NOTE
  3455.     This call is guaranteed to preserve all registers.
  3456.  
  3457.     SEE ALSO
  3458.     Forbid, Disable, Enable
  3459.  
  3460. exec.library/Procure                                     exec.library/Procure
  3461.  
  3462.    NAME
  3463.     Procure -- bid for a semaphore                                   (V39)
  3464.  
  3465.    SYNOPSIS
  3466.     Procure(semaphore, bidMessage)
  3467.         A0        A1
  3468.  
  3469.     VOID Procure(struct SignalSemaphore *, struct SemaphoreMessage *);
  3470.  
  3471.    FUNCTION
  3472.     This function is used to obtain a semaphore in an async manner.
  3473.     Like ObtainSemaphore(), it will obtain a SignalSemaphore for you
  3474.     but unlike ObtainSemaphore(), you will not block until you get
  3475.     the semaphore.  Procure() will just post a request for the semaphore
  3476.     and will return.  When the semaphore is available (which could
  3477.     be at any time) the bidMessage will ReplyMsg() and you will own
  3478.     the semaphore.  This lets you wait on multiple semaphores at once
  3479.     and to continue processing while waiting for the semaphore.
  3480.  
  3481.     NOTE:  Pre-V39, Procure() and Vacate() did not work correctly.
  3482.     They also did not operate on SignalSemaphore semaphores.
  3483.     Old (and broken) MessageSemaphore use as of V39 will no longer work.
  3484.  
  3485.    INPUT
  3486.     semaphore - The SignalSemaphore that you wish to Procure()
  3487.     bidMessage- The SemaphoreMessage that you wish replied when
  3488.         you obtain access to the semaphore.  The message's
  3489.         ssm_Semaphore field will point at the semaphore that
  3490.         was obtained.  If the ssm_Semaphore field is NULL,
  3491.         the Procure() was aborted via Vacate().
  3492.         The mn_ReplyPort field of the message must point to
  3493.         a valid message port.
  3494.         To obtain a shared semaphore, the ln_Name field
  3495.         must be set to 1.  For an exclusive lock, the ln_Name
  3496.         field must be 0.  No other values are valid.
  3497.  
  3498.    BUGS
  3499.     Before V39, Procure() and Vacate() used a different semaphore
  3500.     system that was very broken.  This new system is only available
  3501.     as of V39 even though the LVOs are the same.
  3502.  
  3503.    SEE ALSO
  3504.     ObtainSemaphoreShared(), InitSemaphore(), ReleaseSemaphore(),
  3505.     AttemptSemaphore(), ObtainSemaphoreList(), Vacate(), ObtainSemaphore()
  3506.  
  3507. exec.library/PutMsg                                       exec.library/PutMsg
  3508.  
  3509.    NAME
  3510.     PutMsg -- put a message to a message port
  3511.  
  3512.    SYNOPSIS
  3513.     PutMsg(port, message)
  3514.            A0    A1
  3515.  
  3516.     void PutMsg(struct MsgPort *, struct Message *);
  3517.  
  3518.    FUNCTION
  3519.     This function attaches a message to the end of a given message port.
  3520.     It provides a fast, non-copying message sending mechanism.
  3521.  
  3522.     Messages can be attached to only one port at a time.  The message
  3523.     body can be of any size or form.  Because messages are not copied,
  3524.     cooperating tasks share the same message memory.  The sender task
  3525.     must not recycle the message until it has been replied by the
  3526.     receiver.  Of course this depends on the message handling conventions
  3527.     setup by the involved tasks.  If the ReplyPort field is non-zero,
  3528.     when the message is replied by the receiver, it will be sent back to
  3529.     that port.
  3530.  
  3531.     Any one of the following actions can be set to occur when a message
  3532.     is put:
  3533.  
  3534.         1. no special action
  3535.         2. signal a given task (specified by MP_SIGTASK)
  3536.         3. cause a software interrupt (specified by MP_SIGTASK)
  3537.  
  3538.     The action is selected depending on the value found in the MP_FLAGS
  3539.     of the destination port.
  3540.  
  3541.    IMPLEMENTATION
  3542.     1.  Sets the LN_TYPE field to "NT_MESSAGE".
  3543.     2.  Attaches the message to the destination port.
  3544.     3.  Performs the specified arrival action at the destination.
  3545.  
  3546.    INPUT
  3547.     port - pointer to a message port
  3548.     message - pointer to a message
  3549.  
  3550.    SEE ALSO
  3551.     GetMsg, ReplyMsg, exec/ports.h
  3552.  
  3553. exec.library/RawDoFmt                                   exec.library/RawDoFmt
  3554.  
  3555.    NAME
  3556.     RawDoFmt -- format data into a character stream.
  3557.  
  3558.    SYNOPSIS
  3559.     NextData = RawDoFmt(FormatString, DataStream, PutChProc, PutChData);
  3560.        d0                  a0            a1          a2         a3
  3561.  
  3562.     APTR RawDoFmt(STRPTR,APTR,void (*)(),APTR);
  3563.  
  3564.    FUNCTION
  3565.     perform "C"-language-like formatting of a data stream, outputting
  3566.     the result a character at a time.  Where % formatting commands are
  3567.     found in the FormatString, they will be replaced with the
  3568.     corresponding element in the DataStream.  %% must be used in the
  3569.     string if a % is desired in the output.
  3570.  
  3571.     Under V36, RawDoFmt() returns a pointer to the end of the DataStream
  3572.     (The next argument that would have been processed).  This allows
  3573.     multiple formatting passes to be made using the same data.
  3574.  
  3575.    INPUTS
  3576.     FormatString - a "C"-language-like NULL terminated format string,
  3577.     with the following supported % options:
  3578.  
  3579.      %[flags][width.limit][length]type
  3580.  
  3581.     flags  - only one allowed. '-' specifies left justification.
  3582.     width  - field width.  If the first character is a '0', the
  3583.          field will be padded with leading 0's.
  3584.       .    - must follow the field width, if specified
  3585.     limit  - maximum number of characters to output from a string.
  3586.          (only valid for %s).
  3587.     length - size of input data defaults to WORD for types d, x,
  3588.          and c, 'l' changes this to long (32-bit).
  3589.     type   - supported types are:
  3590.             b - BSTR, data is 32-bit BPTR to byte count followed
  3591.                 by a byte string, or NULL terminated byte string.
  3592.                 A NULL BPTR is treated as an empty string.
  3593.                 (Added in V36 exec)
  3594.             d - decimal
  3595.             u - unsigned decimal (Added in V37 exec)
  3596.             x - hexadecimal
  3597.             s - string, a 32-bit pointer to a NULL terminated
  3598.                 byte string.  In V36, a NULL pointer is treated
  3599.                 as an empty string
  3600.             c - character
  3601.  
  3602.     DataStream - a stream of data that is interpreted according to
  3603.          the format string.  Often this is a pointer into
  3604.          the task's stack.
  3605.     PutChProc  - the procedure to call with each character to be
  3606.          output, called as:
  3607.  
  3608.     PutChProc(Char,  PutChData);
  3609.           D0-0:8 A3
  3610.  
  3611.         the procedure is called with a NULL Char at the end of
  3612.         the format string.
  3613.  
  3614.     PutChData - a value that is passed through to the PutChProc
  3615.         procedure.  This is untouched by RawDoFmt, and may be
  3616.         modified by the PutChProc.
  3617.  
  3618.    EXAMPLE
  3619.     ;
  3620.     ; Simple version of the C "sprintf" function.  Assumes C-style
  3621.     ; stack-based function conventions.
  3622.     ;
  3623.     ;   long eyecount;
  3624.     ;   eyecount=2;
  3625.     ;   sprintf(string,"%s have %ld eyes.","Fish",eyecount);
  3626.     ;
  3627.     ; would produce "Fish have 2 eyes." in the string buffer.
  3628.     ;
  3629.         XDEF _sprintf
  3630.         XREF _AbsExecBase
  3631.         XREF _LVORawDoFmt
  3632.     _sprintf:    ; ( ostring, format, {values} )
  3633.         movem.l a2/a3/a6,-(sp)
  3634.  
  3635.         move.l    4*4(sp),a3       ;Get the output string pointer
  3636.         move.l    5*4(sp),a0       ;Get the FormatString pointer
  3637.         lea.l    6*4(sp),a1       ;Get the pointer to the DataStream
  3638.         lea.l    stuffChar(pc),a2
  3639.         move.l    _AbsExecBase,a6
  3640.         jsr    _LVORawDoFmt(a6)
  3641.  
  3642.         movem.l (sp)+,a2/a3/a6
  3643.         rts
  3644.  
  3645.     ;------ PutChProc function used by RawDoFmt -----------
  3646.     stuffChar:
  3647.         move.b    d0,(a3)+        ;Put data to output string
  3648.         rts
  3649.  
  3650.    WARNING
  3651.     This Amiga ROM function formats word values in the data stream.  If
  3652.     your compiler defaults to longs, you must add an "l" to your
  3653.     % specifications.  This can get strange for characters, which might
  3654.     look like "%lc".
  3655.  
  3656.     The result of RawDoFmt() is *ONLY* valid in V36 and later releases
  3657.     of EXEC.  Pre-V36 versions of EXEC have "random" return values.
  3658.  
  3659.    SEE ALSO
  3660.     Documentation on the C language "printf" call in any C language
  3661.     reference book.
  3662.  
  3663. exec.library/ReleaseSemaphore                   exec.library/ReleaseSemaphore
  3664.  
  3665.    NAME
  3666.     ReleaseSemaphore -- make signal semaphore available to others
  3667.  
  3668.    SYNOPSIS
  3669.     ReleaseSemaphore(signalSemaphore)
  3670.              A0
  3671.  
  3672.     void ReleaseSemaphore(struct SignalSemaphore *);
  3673.  
  3674.    FUNCTION
  3675.     ReleaseSemaphore() is the inverse of ObtainSemaphore(). It makes
  3676.     the semaphore lockable to other users.    If tasks are waiting for
  3677.     the semaphore and this this task is done with the semaphore then
  3678.     the next waiting task is signalled.
  3679.  
  3680.     Each ObtainSemaphore() call must be balanced by exactly one
  3681.     ReleaseSemaphore() call.  This is because there is a nesting count
  3682.     maintained in the semaphore of the number of times that the current
  3683.     task has locked the semaphore. The semaphore is not released to
  3684.     other tasks until the number of releases matches the number of
  3685.     obtains.
  3686.  
  3687.     Needless to say, havoc breaks out if the task releases more times
  3688.     than it has obtained.
  3689.  
  3690.    INPUT
  3691.        signalSemaphore -- an initialized signal semaphore structure
  3692.  
  3693.    NOTE
  3694.     This call is guaranteed to preserve all registers.
  3695.  
  3696.    SEE ALSO
  3697.     InitSemaphore(), ObtainSemaphore(), ObtainSemaphoreShared()
  3698.  
  3699. exec.library/ReleaseSemaphoreList           exec.library/ReleaseSemaphoreList
  3700.  
  3701.    NAME
  3702.     ReleaseSemaphoreList -- make a list of semaphores available
  3703.  
  3704.    SYNOPSIS
  3705.     ReleaseSemaphoreList(list)
  3706.                  A0
  3707.  
  3708.     void ReleaseSemaphoreList(struct List *);
  3709.  
  3710.    FUNCTION
  3711.     ReleaseSemaphoreList() is the inverse of ObtainSemaphoreList(). It
  3712.     releases each element in the semaphore list.
  3713.  
  3714.     Needless to say, havoc breaks out if the task releases more times
  3715.     than it has obtained.
  3716.  
  3717.    INPUT
  3718.        list -- a list of signal semaphores
  3719.  
  3720.    SEE ALSO
  3721.     ObtainSemaphoreList()
  3722.  
  3723. exec.library/RemDevice                                 exec.library/RemDevice
  3724.  
  3725.    NAME
  3726.     RemDevice -- remove a device from the system
  3727.  
  3728.    SYNOPSIS
  3729.     RemDevice(device)
  3730.               A1
  3731.  
  3732.     void RemDevice(struct Device *);
  3733.  
  3734.    FUNCTION
  3735.     This function calls the device's EXPUNGE vector, which requests
  3736.     that a device delete itself.  The device may refuse to do this if
  3737.     it is busy or currently open. This is not typically called by user
  3738.     code.
  3739.  
  3740.     There are certain, limited circumstances where it may be
  3741.     appropriate to attempt to specifically flush a certain device.
  3742.     Example:
  3743.  
  3744.      /* Attempts to flush the named device out of memory. */
  3745.      #include <exec/types.h>
  3746.      #include <exec/execbase.h>
  3747.  
  3748.      void FlushDevice(name)
  3749.      STRPTR name;
  3750.      {
  3751.      struct Device *result;
  3752.  
  3753.         Forbid();
  3754.         if(result=(struct Device *)FindName(&SysBase->DeviceList,name))
  3755.         RemDevice(result);
  3756.         Permit();
  3757.      }
  3758.  
  3759.    INPUTS
  3760.     device - pointer to a device node
  3761.  
  3762.    SEE ALSO
  3763.     AddLibrary
  3764.  
  3765. exec.library/RemHead                                     exec.library/RemHead
  3766.  
  3767.    NAME
  3768.     RemHead -- remove the head node from a list
  3769.  
  3770.    SYNOPSIS
  3771.     node = RemHead(list)
  3772.     D0           A0
  3773.  
  3774.     struct Node *RemHead(struct List *);
  3775.  
  3776.    FUNCTION
  3777.     Get a pointer to the head node and remove it from the list.
  3778.     Assembly programmers may prefer to use the REMHEAD macro from
  3779.     "exec/lists.i".
  3780.  
  3781.    WARNING
  3782.     This function does not arbitrate for access to the list.  The
  3783.     calling task must be the owner of the involved list.
  3784.  
  3785.    INPUTS
  3786.     list - a pointer to the target list header
  3787.  
  3788.    RESULT
  3789.     node - the node removed or zero when empty list
  3790.  
  3791.    SEE ALSO
  3792.     AddHead, AddTail, Enqueue, Insert, Remove, RemTail
  3793.  
  3794. exec.library/RemIntServer                           exec.library/RemIntServer
  3795.  
  3796.    NAME
  3797.     RemIntServer -- remove an interrupt server from a server chain
  3798.  
  3799.    SYNOPSIS
  3800.     RemIntServer(intNum, interrupt)
  3801.              D0      A1
  3802.  
  3803.     void RemIntServer(ULONG,struct Interrupt *);
  3804.  
  3805.    FUNCTION
  3806.     This function removes an interrupt server node from the given
  3807.     server chain.
  3808.  
  3809.     If this server was the last one on this chain, interrupts for this
  3810.     chain are disabled.
  3811.  
  3812.    INPUTS
  3813.     intNum - the Paula interrupt bit (0..14)
  3814.     interrupt - pointer to an interrupt server node
  3815.  
  3816.    BUGS
  3817.     Before V36 Kickstart, the feature that disables the interrupt
  3818.     would not function.  For most server chains this does not
  3819.     cause a problem.
  3820.  
  3821.    SEE ALSO
  3822.     AddIntServer, hardware/intbits.h
  3823.  
  3824. exec.library/RemLibrary                               exec.library/RemLibrary
  3825.  
  3826.    NAME
  3827.     RemLibrary -- remove a library from the system
  3828.  
  3829.    SYNOPSIS
  3830.     RemLibrary(library)
  3831.                A1
  3832.  
  3833.     void RemLibrary(struct Library *);
  3834.  
  3835.    FUNCTION
  3836.     This function calls the library's EXPUNGE vector, which requests
  3837.     that a library delete itself.  The library may refuse to do this if
  3838.     it is busy or currently open. This is not typically called by user
  3839.     code.
  3840.  
  3841.     There are certain, limited circumstances where it may be
  3842.     appropriate to attempt to specifically flush a certain Library.
  3843.     Example:
  3844.  
  3845.      /* Attempts to flush the named library out of memory. */
  3846.      #include <exec/types.h>
  3847.      #include <exec/execbase.h>
  3848.  
  3849.      void FlushLibrary(name)
  3850.      STRPTR name;
  3851.      {
  3852.      struct Library *result;
  3853.  
  3854.         Forbid();
  3855.         if(result=(struct Library *)FindName(&SysBase->LibList,name))
  3856.         RemLibrary(result);
  3857.         Permit();
  3858.      }
  3859.  
  3860.    INPUTS
  3861.     library - pointer to a library node structure
  3862.  
  3863. exec.library/RemMemHandler                         exec.library/RemMemHandler
  3864.  
  3865.    NAME
  3866.     RemMemHandler - Remove low memory handler from exec              (V39)
  3867.  
  3868.    SYNOPSIS
  3869.     RemMemHandler(memHandler)
  3870.                   A1
  3871.  
  3872.     VOID RemMemHandler(struct Interrupt *);
  3873.  
  3874.    FUNCTION
  3875.     This function removes the low memory handler from the system.
  3876.     This function can be called from within a handler.  If removing
  3877.     oneself, it is important that the handler returns MEM_ALL_DONE.
  3878.  
  3879.    NOTE
  3880.     When removing a handler, the handler may be called until this
  3881.     function returns.  Thus, the handler must still be valid until
  3882.     then.
  3883.  
  3884.    INPUTS
  3885.     memHandler - Pointer to a handler added with AddMemHandler()
  3886.  
  3887.    SEE ALSO
  3888.     AddMemHandler, exec/interrupts.i
  3889.  
  3890. exec.library/Remove                                       exec.library/Remove
  3891.  
  3892.    NAME
  3893.     Remove -- remove a node from a list
  3894.  
  3895.    SYNOPSIS
  3896.     Remove(node)
  3897.            A1
  3898.  
  3899.     void Remove(struct Node *);
  3900.  
  3901.    FUNCTION
  3902.     Unlink a node from whatever list it is in.  Nodes that are not part
  3903.     of a list must not be passed to this function!  Assembly programmers
  3904.     may prefer to use the REMOVE macro from "exec/lists.i".
  3905.  
  3906.    WARNING
  3907.     This function does not arbitrate for access to the list.  The
  3908.     calling task must be the owner of the involved list.
  3909.  
  3910.    INPUTS
  3911.     node - the node to remove
  3912.  
  3913.    SEE ALSO
  3914.     AddHead, AddTail, Enqueue, Insert, RemHead, RemTail
  3915.  
  3916. exec.library/RemPort                                     exec.library/RemPort
  3917.  
  3918.    NAME
  3919.     RemPort -- remove a message port from the system
  3920.  
  3921.    SYNOPSIS
  3922.     RemPort(port)
  3923.         A1
  3924.  
  3925.     void RemPort(struct MsgPort *);
  3926.  
  3927.    FUNCTION
  3928.     This function removes a message port structure from the system's
  3929.     message port list.  Subsequent attempts to rendezvous by name with
  3930.     this port will fail.
  3931.  
  3932.    INPUTS
  3933.     port - pointer to a message port
  3934.  
  3935.    SEE ALSO
  3936.     AddPort, FindPort
  3937.  
  3938. exec.library/RemResource                             exec.library/RemResource
  3939.  
  3940.    NAME
  3941.     RemResource -- remove a resource from the system
  3942.  
  3943.    SYNOPSIS
  3944.     RemResource(resource)
  3945.            A1
  3946.  
  3947.     void RemResource(APTR);
  3948.  
  3949.    FUNCTION
  3950.     This function removes an existing resource from the system resource
  3951.     list.  There must be no outstanding users of the resource.
  3952.  
  3953.    INPUTS
  3954.     resource - pointer to a resource node
  3955.  
  3956.    SEE ALSO
  3957.     AddResource
  3958.  
  3959. exec.library/RemSemaphore                           exec.library/RemSemaphore
  3960.  
  3961.    NAME
  3962.     RemSemaphore -- remove a signal semaphore from the system
  3963.  
  3964.    SYNOPSIS
  3965.     RemSemaphore(signalSemaphore)
  3966.              A1
  3967.  
  3968.     void RemSemaphore(struct SignalSemaphore *);
  3969.  
  3970.    FUNCTION
  3971.     This function removes a signal semaphore structure from the
  3972.     system's signal semaphore list.  Subsequent attempts to
  3973.     rendezvous by name with this semaphore will fail.
  3974.  
  3975.    INPUTS
  3976.        signalSemaphore -- an initialized signal semaphore structure
  3977.  
  3978.    SEE ALSO
  3979.     AddSemaphore, FindSemaphore
  3980.  
  3981.  
  3982. exec.library/RemTail                                     exec.library/RemTail
  3983.  
  3984.    NAME
  3985.     RemTail -- remove the tail node from a list
  3986.  
  3987.    SYNOPSIS
  3988.     node = RemTail(list)
  3989.     D0           A0
  3990.  
  3991.     struct Node *RemTail(struct List *);
  3992.  
  3993.    FUNCTION
  3994.     Remove the last node from a list, and return a pointer to it. If
  3995.     the list is empty, return zero. Assembly programmers may prefer to
  3996.     use the REMTAIL macro from "exec/lists.i".
  3997.  
  3998.    WARNING
  3999.     This function does not arbitrate for access to the list.  The
  4000.     calling task must be the owner of the involved list.
  4001.  
  4002.    INPUTS
  4003.     list - a pointer to the target list header
  4004.  
  4005.    RESULT
  4006.     node - the node removed or zero when empty list
  4007.  
  4008.    SEE ALSO
  4009.     AddHead, AddTail, Enqueue, Insert, Remove, RemHead, RemTail
  4010.  
  4011. exec.library/RemTask                                     exec.library/RemTask
  4012.  
  4013.    NAME
  4014.     RemTask -- remove a task from the system
  4015.  
  4016.    SYNOPSIS
  4017.     RemTask(task)
  4018.         A1
  4019.  
  4020.     void RemTask(struct Task *);
  4021.  
  4022.    FUNCTION
  4023.     This function removes a task from the system.  Deallocation of
  4024.     resources should have been performed prior to calling this
  4025.     function.  Removing some other task is very dangerous.    Generally
  4026.     is is best to arrange for tasks to call RemTask(0L) on themselves.
  4027.  
  4028.     RemTask will automagically free any memory lists attached to the
  4029.     task's TC_MEMENTRY list.
  4030.  
  4031.    INPUTS
  4032.     task - pointer to the task node representing the task to be
  4033.            removed.  A zero value indicates self removal, and will
  4034.            cause the next ready task to begin execution.
  4035.  
  4036.    BUGS
  4037.     Before V36 if RemTask() was called on a task other than the current
  4038.     task, and that task was created with amiga.lib/CreateTask, there was
  4039.     a slight chance of a crash.  The problem can be hidden by bracketing
  4040.     RemTask() with Forbid()/Permit().
  4041.  
  4042.    SEE ALSO
  4043.     AddTask, exec/AllocEntry, amiga.lib/DeleteTask
  4044.  
  4045. exec.library/ReplyMsg                                   exec.library/ReplyMsg
  4046.  
  4047.    NAME
  4048.     ReplyMsg -- put a message to its reply port
  4049.  
  4050.    SYNOPSIS
  4051.     ReplyMsg(message)
  4052.          A1
  4053.  
  4054.     void ReplyMsg(struct Message *);
  4055.  
  4056.    FUNCTION
  4057.     This function sends a message to its reply port.  This is usually
  4058.     done when the receiver of a message has finished and wants to
  4059.     return it to the sender (so that it can be re-used or deallocated,
  4060.     whatever).
  4061.  
  4062.     This call may be made from interrupts.
  4063.  
  4064.    INPUT
  4065.     message - a pointer to the message
  4066.  
  4067.    IMPLEMENTATION
  4068.     1> Places "NT_REPLYMSG" into LN_TYPE.
  4069.     2> Puts the message to the port specified by MN_REPLYPORT
  4070.        If there is no replyport, sets LN_TYPE to "NT_FREEMSG" (use this
  4071.        feature only with extreme care).
  4072.  
  4073.    SEE ALSO
  4074.     GetMsg, PutMsg, exec/ports.h
  4075.  
  4076. exec.library/SendIO                                       exec.library/SendIO
  4077.  
  4078.    NAME
  4079.     SendIO -- initiate an I/O command
  4080.  
  4081.    SYNOPSIS
  4082.     SendIO(iORequest)
  4083.            A1
  4084.  
  4085.     void SendIO(struct IORequest *);
  4086.  
  4087.    FUNCTION
  4088.     This function requests the device driver start processing the given
  4089.     I/O request.  The device will return control without waiting for
  4090.     the I/O to complete.
  4091.  
  4092.     The io_Flags field of the IORequest will be set to zero before the
  4093.     request is sent.  See BeginIO() for more details.
  4094.  
  4095.    INPUTS
  4096.     iORequest - pointer to an I/O request, or a device specific
  4097.             extended IORequest.
  4098.  
  4099.    SEE ALSO
  4100.     DoIO, CheckIO, WaitIO, AbortIO
  4101.  
  4102. exec.library/SetExcept                                 exec.library/SetExcept
  4103.  
  4104.    NAME
  4105.     SetExcept -- define certain signals to cause exceptions
  4106.  
  4107.    SYNOPSIS
  4108.     oldSignals = SetExcept(newSignals, signalMask)
  4109.     D0               D0       D1
  4110.  
  4111.     ULONG SetExcept(ULONG,ULONG);
  4112.  
  4113.    FUNCTION
  4114.     This function defines which of the task's signals will cause a
  4115.     private task exception.  When any of the signals occurs the task's
  4116.     exception handler will be dispatched.  If the signal occurred prior
  4117.     to calling SetExcept, the exception will happen immediately.
  4118.  
  4119.     The user function pointed to by the task's tc_ExceptCode gets
  4120.     called as:
  4121.  
  4122.         newExcptSet = <exceptCode>(signals, exceptData),SysBase
  4123.         D0                   D0    A1        A6
  4124.  
  4125.         signals - The set of signals that caused this exception.  These
  4126.         Signals have been disabled from the current set of signals
  4127.         that can cause an exception.
  4128.  
  4129.         exceptData - A copy of the task structure tc_ExceptData field.
  4130.  
  4131.         newExcptSet - The set of signals in NewExceptSet will be re-
  4132.         enabled for exception generation.  Usually this will be the
  4133.         same as the Signals that caused the exception.
  4134.  
  4135.    INPUTS
  4136.     newSignals - the new values for the signals specified in
  4137.         signalMask.
  4138.     signalMask - the set of signals to be effected
  4139.  
  4140.    RESULTS
  4141.     oldSignals - the prior exception signals
  4142.  
  4143.    EXAMPLE
  4144.     Get the current state of all exception signals:
  4145.         SetExcept(0,0)
  4146.     Change a few exception signals:
  4147.         SetExcept($1374,$1074)
  4148.  
  4149.    SEE ALSO
  4150.     Signal, SetSignal
  4151.  
  4152. exec.library/SetFunction                             exec.library/SetFunction
  4153.  
  4154.    NAME
  4155.     SetFunction -- change a function vector in a library
  4156.  
  4157.    SYNOPSIS
  4158.     oldFunc = SetFunction(library, funcOffset, funcEntry)
  4159.     D0              A1       A0.W       D0
  4160.  
  4161.     APTR SetFunction(struct Library *,LONG,APTR);
  4162.  
  4163.    FUNCTION
  4164.     SetFunction is a functional way of changing where vectors in a
  4165.     library point.    They are changed in such a way that the
  4166.     checksumming process will never falsely declare a library to be
  4167.     invalid.
  4168.  
  4169.    WARNING
  4170.     If you use SetFunction on a function that can be called from
  4171.     interrupts, you are obligated to provide your own arbitration.
  4172.  
  4173.    NOTE
  4174.     SetFunction cannot be used on non-standard libraries like pre-V36
  4175.     dos.library.  Here you must manually Forbid(), preserve all 6
  4176.     original bytes, set the new vector, SumLibrary(), then Permit().
  4177.  
  4178.    INPUTS
  4179.     library    - a pointer to the library to be changed
  4180.     funcOffset - the offset of the function to be replaced
  4181.     funcEntry  - pointer to new function
  4182.  
  4183.    RESULTS
  4184.     oldFunc    - pointer to the old function that was just replaced
  4185.  
  4186. exec.library/SetIntVector                           exec.library/SetIntVector
  4187.  
  4188.    NAME
  4189.     SetIntVector -- set a new handler for a system interrupt vector
  4190.  
  4191.    SYNOPSIS
  4192.     oldInterrupt = SetIntVector(intNumber, interrupt)
  4193.     D0                D0         A1
  4194.  
  4195.     struct Interrupt *SetIntVector(ULONG, struct Interrupt *);
  4196.  
  4197.    FUNCTION
  4198.     This function provides a mechanism for setting the system interrupt
  4199.     vectors.  These are non-sharable; setting a new interrupt handler
  4200.     disconnects the old one.  Installed handlers are responsible for
  4201.     processing, enabling and clearing the interrupt.  Note that interrupts
  4202.     may have been left in any state by the previous code.
  4203.  
  4204.     The IS_CODE and IS_DATA pointers of the Interrupt structure will
  4205.     be copied into a private place by Exec.  A pointer to the previously
  4206.     installed Interrupt structure is returned.
  4207.  
  4208.     When the system calls the specified interrupt code, the registers are
  4209.     setup as follows:
  4210.  
  4211.         D0 - scratch
  4212.         D1 - scratch (on entry: active
  4213.               interrupts -> equals INTENA & INTREQ)
  4214.  
  4215.         A0 - scratch (on entry: pointer to base of custom chips
  4216.               for fast indexing)
  4217.         A1 - scratch (on entry: Interrupt's IS_DATA pointer)
  4218.  
  4219.         A5 - jump vector register (scratch on call)
  4220.         A6 - Exec library base pointer (scratch on call)
  4221.  
  4222.         all other registers must be preserved
  4223.  
  4224.    INPUTS
  4225.     intNum - the Paula interrupt bit number (0..14).  Only non-chained
  4226.          interrupts should be set.  Use AddIntServer() for server
  4227.          chains.
  4228.     interrupt - a pointer to an Interrupt structure containing the
  4229.          handler's entry point and data segment pointer.  A NULL
  4230.          interrupt pointer will remove the current interrupt and
  4231.          set illegal values for IS_CODE and IS_DATA.
  4232.  
  4233.          By convention, the LN_NAME of the interrupt structure must
  4234.          point a descriptive string so that other users may
  4235.          identify who currently has control of the interrupt.
  4236.  
  4237.    RESULT
  4238.     A pointer to the prior interrupt structure which had control
  4239.     of this interrupt.
  4240.  
  4241.    SEE ALSO
  4242.     AddIntServer(),exec/interrupts.i,hardware/intbits.i
  4243.  
  4244. exec.library/SetSignal                                 exec.library/SetSignal
  4245.  
  4246.    NAME
  4247.     SetSignal -- define the state of this task's signals
  4248.  
  4249.    SYNOPSIS
  4250.     oldSignals = SetSignal(newSignals, signalMask)
  4251.     D0               D0       D1
  4252.  
  4253.     ULONG SetSignal(ULONG,ULONG);
  4254.  
  4255.    FUNCTION
  4256.     This function can query or modify the state of the current task's
  4257.     received signal mask.  Setting the state of signals is considered
  4258.     dangerous.  Reading the state of signals is safe.
  4259.  
  4260.    INPUTS
  4261.     newSignals - the new values for the signals specified in
  4262.              signalSet.
  4263.     signalMask - the set of signals to be affected.
  4264.  
  4265.    RESULTS
  4266.     oldSignals - the prior values for all signals
  4267.  
  4268.    EXAMPLES
  4269.     Get the current state of all signals:
  4270.         SetSignal(0L,0L);
  4271.     Clear the CTRL-C signal:
  4272.         SetSignal(0L,SIGBREAKF_CTRL_C);
  4273.  
  4274.  
  4275.     Check if the CTRL-C signal was pressed:
  4276.  
  4277.         #include <libraries/dos.h>
  4278.  
  4279.         /* Check & clear CTRL_C signal */
  4280.         if(SetSignal(0L,SIGBREAKF_CTRL_C) & SIGBREAKF_CTRL_C)
  4281.         {
  4282.         printf("CTRL-C pressed!\n");
  4283.         }
  4284.  
  4285.    SEE ALSO
  4286.     Signal, Wait
  4287.  
  4288. exec.library/SetSR                                         exec.library/SetSR
  4289.  
  4290.    NAME
  4291.     SetSR -- get and/or set processor status register
  4292.  
  4293.    SYNOPSIS
  4294.     oldSR = SetSR(newSR, mask)
  4295.     D0          D0     D1
  4296.  
  4297.     ULONG SetSR(ULONG, ULONG);
  4298.  
  4299.    FUNCTION
  4300.     This function provides a means of modifying the CPU status register
  4301.     in a "safe" way (well, how safe can a function like this be
  4302.     anyway?).  This function will only affect the status register bits
  4303.     specified in the mask parameter.  The prior content of the entire
  4304.     status register is returned.
  4305.  
  4306.    INPUTS
  4307.     newSR - new values for bits specified in the mask.
  4308.         All other bits are not effected.
  4309.     mask - bits to be changed
  4310.  
  4311.    RESULTS
  4312.     oldSR - the entire status register before new bits
  4313.  
  4314.    EXAMPLES
  4315.     To get the current SR:
  4316.         currentSR = SetSR(0,0);
  4317.     To change the processor interrupt level to 3:
  4318.         oldSR = SetSR($0300,$0700);
  4319.     Set processor interrupts back to prior level:
  4320.         SetSR(oldSR,$0700);
  4321.  
  4322. exec.library/SetTaskPri                               exec.library/SetTaskPri
  4323.  
  4324.    NAME
  4325.     SetTaskPri -- get and set the priority of a task
  4326.  
  4327.    SYNOPSIS
  4328.     oldPriority = SetTaskPri(task, priority)
  4329.     D0-0:8             A1    D0-0:8
  4330.  
  4331.     BYTE SetTaskPri(struct Task *,LONG);
  4332.  
  4333.    FUNCTION
  4334.     This function changes the priority of a task regardless of its
  4335.     state.    The old priority of the task is returned.  A reschedule is
  4336.     performed, and a context switch may result.
  4337.  
  4338.     To change the priority of the currently running task, pass the
  4339.     result of FindTask(0); as the task pointer.
  4340.  
  4341.    INPUTS
  4342.     task - task to be affected
  4343.     priority - the new priority for the task
  4344.  
  4345.    RESULT
  4346.     oldPriority - the tasks previous priority
  4347.  
  4348. exec.library/Signal                                       exec.library/Signal
  4349.  
  4350.    NAME
  4351.     Signal -- signal a task
  4352.  
  4353.    SYNOPSIS
  4354.     Signal(task, signals)
  4355.            A1    D0
  4356.  
  4357.     void Signal(struct Task *,ULONG);
  4358.  
  4359.    FUNCTION
  4360.     This function signals a task with the given signals.  If the task
  4361.     is currently waiting for one or more of these signals, it will be
  4362.     made ready and a reschedule will occur. If the task is not waiting
  4363.     for any of these signals, the signals will be posted to the task
  4364.     for possible later use. A signal may be sent to a task regardless
  4365.     of whether it is running, ready, or waiting.
  4366.  
  4367.     This function is considered "low level".  Its main purpose is to
  4368.     support multiple higher level functions like PutMsg.
  4369.  
  4370.     This function is safe to call from interrupts.
  4371.  
  4372.    INPUT
  4373.     task - the task to be signalled
  4374.     signals - the signals to be sent
  4375.  
  4376.    SEE ALSO
  4377.     Wait, SetSignal
  4378.  
  4379. exec.library/StackSwap                                 exec.library/StackSwap
  4380.  
  4381.    NAME
  4382.     StackSwap - EXEC supported method of replacing task's stack      (V37)
  4383.  
  4384.    SYNOPSIS
  4385.     StackSwap(newStack)
  4386.               A0
  4387.  
  4388.     VOID StackSwap(struct StackSwapStruct *);
  4389.  
  4390.    FUNCTION
  4391.     This function will, in an EXEC supported manner, swap the
  4392.     stack of your task with the given values in StackSwap.
  4393.     The StackSwapStruct structure will then contain the values
  4394.     of the old stack such that the old stack can be restored.
  4395.     This function is new in V37.
  4396.  
  4397.    NOTE
  4398.     If you do a stack swap, only the new stack is set up.
  4399.     This function does not copy the stack or do anything else
  4400.     other than set up the new stack for the task.  It is
  4401.     generally required that you restore your stack before
  4402.     exiting.
  4403.  
  4404.    INPUTS
  4405.     newStack - A structure that contains the values for the
  4406.         new upper and lower stack bounds and the new stack
  4407.         pointer.  This structure will have its values
  4408.         replaced by those in you task such that you can
  4409.         restore the stack later.
  4410.  
  4411.    RESULTS
  4412.     newStack - The structure will now contain the old stack.
  4413.         This means that StackSwap(foo); StackSwap(foo);
  4414.         will effectively do nothing.
  4415.  
  4416.    SEE ALSO
  4417.     AddTask, RemTask, exec/tasks.h
  4418.  
  4419. exec.library/SumKickData                             exec.library/SumKickData
  4420.  
  4421.    NAME
  4422.     SumKickData -- compute the checksum for the Kickstart delta list
  4423.  
  4424.    SYNOPSIS
  4425.     checksum = SumKickData()
  4426.     D0
  4427.  
  4428.     ULONG SumKickData(void);
  4429.  
  4430.    FUNCTION
  4431.     The Amiga system has some ROM (or Kickstart) resident code that
  4432.     provides the basic functions for the machine.  This code is
  4433.     unchangeable by the system software.  This function is part of a
  4434.     support system to modify parts of the ROM.
  4435.  
  4436.     The ROM code is linked together at run time via ROMTags (also known
  4437.     as Resident structures, defined in exec/resident.h).  These tags tell
  4438.     Exec's low level boot code what subsystems exist in which regions of
  4439.     memory.  The current list of ROMTags is contained in the ResModules
  4440.     field of ExecBase.  By default this list contains any ROMTags found
  4441.     in the address ranges $F80000-$FFFFFF and $F00000-$F7FFFF.
  4442.  
  4443.     There is also a facility to selectively add or replace modules to the
  4444.     ROMTag list.  These modules can exist in RAM, and the memory they
  4445.     occupy will be deleted from the memory free list during the boot
  4446.     process.  SumKickData() plays an important role in this run-time
  4447.     modification of the ROMTag array.
  4448.  
  4449.     Three variables in ExecBase are used in changing the ROMTag array:
  4450.     KickMemPtr, KickTagPtr, and KickCheckSum. KickMemPtr points to a
  4451.     linked list of MemEntry structures. The memory that these MemEntry
  4452.     structures reference will be allocated (via AllocAbs) at boot time.
  4453.     The MemEntry structure itself must also be in the list.
  4454.  
  4455.     KickTagPtr points to a long-word array of the same format as the
  4456.     ResModules array.  The array has a series of pointers to ROMTag
  4457.     structures.  The array is either NULL terminated, or will have an
  4458.     entry with the most significant bit (bit 31) set.  The most
  4459.     significant bit being set says that this is a link to another
  4460.     long-word array of ROMTag entries.  This new array's address can be
  4461.     found by clearing bit 31.
  4462.  
  4463.     KickCheckSum has the result of SumKickData().  It is the checksum of
  4464.     both the KickMemPtr structure and the KickTagPtr arrays.  If the
  4465.     checksum does not compute correctly then both KickMemPtr and
  4466.     KickTagPtr will be ignored.
  4467.  
  4468.     If all the memory referenced by KickMemPtr can't be allocated then
  4469.     KickTagPtr will be ignored.
  4470.  
  4471.     There is one more important caveat about adding ROMTags. All this
  4472.     ROMTag magic is run very early on in the system -- before expansion
  4473.     memory is added to the system. Therefore any memory in this
  4474.     additional ROMTag area must be addressable at this time. This means
  4475.     that your ROMTag code, MemEntry structures, and resident arrays
  4476.     cannot be in expansion memory.  There are two regions of memory that
  4477.     are acceptable:  one is chip memory, and the other is "Ranger" memory
  4478.     (memory in the range between $C00000-$D80000).
  4479.  
  4480.     Remember that changing an existing ROMTag entry falls into the
  4481.     "heavy magic" category -- be very careful when doing it.  The odd are
  4482.     that you will blow yourself out of the water.
  4483.  
  4484.    NOTE
  4485.     SumKickData was introduced in the 1.2 release
  4486.  
  4487.    RESULT
  4488.     Value to be stuffed into ExecBase->KickCheckSum.
  4489.  
  4490.    WARNING
  4491.     After writing to KickCheckSum, you should push the data cache.
  4492.     This prevents potential problems with large copyback style caches.
  4493.     A call to CacheClearU will do fine.
  4494.  
  4495.    SEE ALSO
  4496.     InitResident, FindResident
  4497.  
  4498. exec.library/SumLibrary                               exec.library/SumLibrary
  4499.  
  4500.    NAME
  4501.     SumLibrary -- compute and check the checksum on a library
  4502.  
  4503.    SYNOPSIS
  4504.     SumLibrary(library)
  4505.            A1
  4506.  
  4507.     void SumLibrary(struct Library *);
  4508.  
  4509.    FUNCTION
  4510.     SumLibrary computes a new checksum on a library.  It can also be
  4511.     used to check an old checksum.    If an old checksum does not match,
  4512.     and the library has not been marked as changed, then the system
  4513.     will call Alert().
  4514.  
  4515.     This call could also be periodically made by some future
  4516.     system-checking task.
  4517.  
  4518.    INPUTS
  4519.     library - a pointer to the library to be changed
  4520.  
  4521.    NOTE
  4522.     An alert will occur if the checksum fails.
  4523.  
  4524.    SEE ALSO
  4525.     SetFunction
  4526.  
  4527. exec.library/SuperState                               exec.library/SuperState
  4528.  
  4529.    NAME
  4530.     SuperState -- enter supervisor state with user stack
  4531.  
  4532.    SYNOPSIS
  4533.     oldSysStack = SuperState()
  4534.     D0
  4535.  
  4536.     APTR SuperState(void);
  4537.  
  4538.    FUNCTION
  4539.     Enter supervisor mode while running on the user's stack. The user
  4540.     still has access to user stack variables.  Be careful though, the
  4541.     user stack must be large enough to accommodate space for all
  4542.     interrupt data -- this includes all possible nesting of interrupts.
  4543.     This function does nothing when called from supervisor state.
  4544.  
  4545.    RESULTS
  4546.     oldSysStack - system stack pointer; save this.    It will come in
  4547.               handy when you return to user state.  If the system
  4548.               is already in supervisor mode, oldSysStack is zero.
  4549.  
  4550.    SEE ALSO
  4551.     UserState/Supervisor
  4552.  
  4553.  
  4554. exec.library/Supervisor                               exec.library/Supervisor
  4555.  
  4556.    NAME
  4557.     Supervisor -- trap to a short supervisor mode function
  4558.  
  4559.    SYNOPSIS
  4560.     result = Supervisor(userFunc)
  4561.     Rx                   A5
  4562.  
  4563.     ULONG Supervisor(void *);
  4564.  
  4565.    FUNCTION
  4566.     Allow a normal user-mode program to execute a short assembly language
  4567.     function in the supervisor mode of the processor.  Supervisor() does
  4568.     not modify or save registers; the user function has full access to the
  4569.     register set.   All rules that apply to interrupt code must be
  4570.     followed.  In addition, no system calls are permitted.  The function
  4571.     must end with an RTE instruction.
  4572.  
  4573.    EXAMPLE
  4574.         ;Obtain the Exception Vector base.  68010 or greater only!
  4575.         MOVECtrap:    movec.l    VBR,d0    ;$4e7a,$0801
  4576.                 rte
  4577.  
  4578.    INPUTS
  4579.     userFunc - A pointer to a short assembly language function ending
  4580.            in RTE.  The function has full access to the register set.
  4581.  
  4582.    RESULTS
  4583.     result   - Whatever values the userFunc left in the registers.
  4584.  
  4585.    SEE ALSO
  4586.     SuperState,UserState
  4587.  
  4588. exec.library/TypeOfMem                                 exec.library/TypeOfMem
  4589.  
  4590.    NAME
  4591.     TypeOfMem -- determine attributes of a given memory address
  4592.  
  4593.    SYNOPSIS
  4594.     attributes = TypeOfMem(address)
  4595.     D0               A1
  4596.  
  4597.     ULONG TypeOfMem(void *);
  4598.  
  4599.    FUNCTION
  4600.     Given a RAM memory address, search the system memory lists and
  4601.     return its memory attributes.  The memory attributes are similar to
  4602.     those specified when the memory was first allocated: (eg. MEMF_CHIP
  4603.     and MEMF_FAST).
  4604.  
  4605.     This function is usually used to determine if a particular block of
  4606.     memory is within CHIP space.
  4607.  
  4608.     If the address is not in known-space, a zero will be returned.
  4609.     (Anything that is not RAM, like the ROM or expansion area, will
  4610.     return zero.  Also the first few bytes of a memory area are used up
  4611.     by the MemHeader.)
  4612.  
  4613.    INPUT
  4614.     address - a memory address
  4615.  
  4616.    RESULT
  4617.     attributes - a long word of memory attribute flags.
  4618.     If the address is not in known RAM, zero is returned.
  4619.  
  4620.    SEE ALSO
  4621.     AllocMem()
  4622.  
  4623. exec.library/UserState                                 exec.library/UserState
  4624.  
  4625.    NAME
  4626.     UserState -- return to user state with user stack
  4627.  
  4628.    SYNOPSIS
  4629.     UserState(sysStack)
  4630.           D0
  4631.  
  4632.     void UserState(APTR);
  4633.  
  4634.    FUNCTION
  4635.     Return to user state with user stack, from supervisor state with
  4636.     user stack.  This function is normally used in conjunction with the
  4637.     SuperState function above.
  4638.  
  4639.     This function must not be called from the user state.
  4640.  
  4641.    INPUT
  4642.     sysStack - supervisor stack pointer
  4643.  
  4644.    BUGS
  4645.     This function is broken in V33/34 Kickstart.  Fixed in V1.31 setpatch.
  4646.  
  4647.    SEE ALSO
  4648.     SuperState/Supervisor
  4649.  
  4650. exec.library/Vacate                                       exec.library/Vacate
  4651.  
  4652.    NAME
  4653.     Vacate -- release a bitMessage from Procure()                    (V39)
  4654.  
  4655.    SYNOPSIS
  4656.     Vacate(semaphore, bidMessage)
  4657.            A0         A1
  4658.  
  4659.     void Vacate(struct SignalSemaphore *,struct SemaphoreMessage *);
  4660.  
  4661.    FUNCTION
  4662.     This function can be used to release a semaphore obtained via
  4663.     Procure().  However, the main purpose for this call is to be
  4664.     able to remove a bid for a semaphore that has not yet responded.
  4665.     This is required when a Procure() was issued and the program
  4666.     no longer needs to get the semaphore and wishes to cancel the
  4667.     Procure() request.  The canceled request will be replied with
  4668.     the ssm_Semaphore field set to NULL.  If you own the semaphore,
  4669.     the message was already replied and only the ssm_Semaphore field
  4670.     will be cleared.
  4671.  
  4672.     NOTE:  Pre-V39, Procure() and Vacate() did not work correctly.
  4673.     They also did not operate on SignalSemaphore semaphores.
  4674.     Old (and broken) MessageSemaphore use as of V39 will no longer work.
  4675.  
  4676.    INPUT
  4677.     semaphore - The SignalSemaphore that you wish to Vacate()
  4678.     bidMessage- The SemaphoreMessage that you wish to abort.
  4679.         The message's ssm_Semaphore field will be cleared.
  4680.         The message will be replied if it is still on the waiting
  4681.         list.  If it is not on the waiting list, it is assumed
  4682.         that the semaphore is owned and it will be released.
  4683.  
  4684.    BUGS
  4685.     Before V39, Procure() and Vacate() used a different semaphore
  4686.     system that was very broken.  This new system is only available
  4687.     as of V39 even though the LVOs are the same.
  4688.  
  4689.    SEE ALSO
  4690.     ObtainSemaphoreShared(), InitSemaphore(), ReleaseSemaphore(),
  4691.     AttemptSemaphore(), ObtainSemaphoreList(), Procure(), ObtainSemaphore()
  4692.  
  4693. exec.library/Wait                                           exec.library/Wait
  4694.  
  4695.    NAME
  4696.     Wait -- wait for one or more signals
  4697.  
  4698.    SYNOPSIS
  4699.     signals = Wait(signalSet)
  4700.     D0           D0
  4701.  
  4702.     ULONG Wait(ULONG);
  4703.  
  4704.    FUNCTION
  4705.     This function will cause the current task to suspend waiting for
  4706.     one or more signals.  When one or more of the specified signals
  4707.     occurs, the task will return to the ready state, and those signals
  4708.     will be cleared.
  4709.  
  4710.     If a signal occurred prior to calling Wait(), the wait condition will
  4711.     be immediately satisfied, and the task will continue to run without
  4712.     delay.
  4713.  
  4714.    CAUTION
  4715.     This function cannot be called while in supervisor mode or
  4716.     interrupts!  This function will break the action of a Forbid() or
  4717.     Disable() call.
  4718.  
  4719.    INPUT
  4720.     signalSet - The set of signals for which to wait.
  4721.             Each bit represents a particular signal.
  4722.  
  4723.    RESULTS
  4724.     signals - the set of signals that were active
  4725.  
  4726. exec.library/WaitIO                                       exec.library/WaitIO
  4727.  
  4728.    NAME
  4729.     WaitIO -- wait for completion of an I/O request
  4730.  
  4731.    SYNOPSIS
  4732.     error = WaitIO(iORequest)
  4733.     D0           A1
  4734.  
  4735.     BYTE WaitIO(struct IORequest *);
  4736.  
  4737.    FUNCTION
  4738.     This function waits for the specified I/O request to complete, then
  4739.     removes it from the replyport.    If the I/O has already completed,
  4740.     this function will return immediately.
  4741.  
  4742.     This function should be used with care, as it does not return until
  4743.     the I/O request completes; if the I/O never completes, this
  4744.     function will never return, and your task will hang.  If this
  4745.     situation is a possibility, it is safer to use the Wait() function.
  4746.     Wait() will return return when any of a specified set of signal is
  4747.     received.  This is how I/O timeouts can be properly handled.
  4748.  
  4749.    WARNING
  4750.     If this IORequest was "Quick" or otherwise finished BEFORE this
  4751.     call, this function drops though immediately, with no call to
  4752.     Wait().  A side effect is that the signal bit related the port may
  4753.     remain set.  Expect this.
  4754.  
  4755.     When removing a known complete IORequest from a port, WaitIO() is the
  4756.     preferred method.  A simple Remove() would require a Disable/Enable
  4757.     pair!
  4758.  
  4759.    INPUTS
  4760.     iORequest - pointer to an I/O request block
  4761.  
  4762.    RESULTS
  4763.     error - zero if successful, else an error is returned
  4764.         (a sign extended copy of io_Error).
  4765.  
  4766.    SEE ALSO
  4767.     DoIO, SendIO, CheckIO, AbortIO
  4768.  
  4769. exec.library/WaitPort                                   exec.library/WaitPort
  4770.  
  4771.    NAME
  4772.     WaitPort -- wait for a given port to be non-empty
  4773.  
  4774.    SYNOPSIS
  4775.     message = WaitPort(port)
  4776.     D0           A0
  4777.  
  4778.     struct Message *WaitPort(struct MsgPort *);
  4779.  
  4780.    FUNCTION
  4781.     This function waits for the given port to become non-empty.  If
  4782.     necessary, the Wait() function will be called to wait for the port
  4783.     signal.  If a message is already present at the port, this function
  4784.     will return immediately.  The return value is always a pointer to
  4785.     the first message queued (but it is not removed from the queue).
  4786.  
  4787.    CAUTION
  4788.     More than one message may be at the port when this returns.  It is
  4789.     proper to call the GetMsg() function in a loop until all messages
  4790.     have been handled, then wait for more to arrive.
  4791.  
  4792.     To wait for more than one port, combine the signal bits from each
  4793.     port into one call to the Wait() function, then use a GetMsg() loop
  4794.     to collect any and all messages.  It is possible to get a signal
  4795.     for a port WITHOUT a message showing up.  Plan for this.
  4796.  
  4797.    INPUT
  4798.     port - a pointer to the message port
  4799.  
  4800.    RETURN
  4801.     message - a pointer to the first available message
  4802.  
  4803.    SEE ALSO
  4804.     GetMsg
  4805.  
  4806. SAD/--Overview--                                             SAD/--Overview--
  4807.  
  4808.     Simple Amiga Debugging Kernel, known as "SAD"
  4809.     It is in EXEC starting in V39
  4810.  
  4811.  
  4812.         -- General description --
  4813.  
  4814.  The Simple Amiga Debugging Kernel (SAD) is a set of very simple control
  4815.  routines stored in the Kickstart ROM that would let debuggers control the
  4816.  Amiga's development enviroment from the outside.  These tools would make
  4817.  it possible to do remote machine development/debugging via just the
  4818.  on-board serial port.
  4819.  
  4820.  This set of control routines is very simple and yet completely flexible,
  4821.  thus making it possible to control the whole machine.
  4822.  
  4823.  
  4824.         -- Technical Issues --
  4825.  
  4826.  SAD will make use of the motherboard serial port that exists in all
  4827.  Amiga systems.  The connection via the serial port lets the system be
  4828.  able to execute SAD without needing any of the system software up and
  4829.  running. (SAD will play with the serial port directly)
  4830.  
  4831.  With some minor changes to the Amiga hardware, an NMI-like line could
  4832.  be hooked up to a pin on the serial port.  This would let external
  4833.  control of the machine and would let the external controller stop the
  4834.  machine no matter what state it is in.  (NMI is that way)
  4835.  
  4836.  In order to function correctly, SAD requires the some of the EXEC
  4837.  CPU control functions work and that ExecBase be valid.  Beyond that,
  4838.  SAD does not require the OS to be running.
  4839.  
  4840.  
  4841.         -- Command Overview --
  4842.  
  4843.  The basic commands needed to operate SAD are as follows:
  4844.  
  4845.  Read and Write memory as byte, word, and longword.
  4846.  Get the register frame address (contains all registers)
  4847.  JSR to Address
  4848.  Return to system operation  (return from interrupt)
  4849.  
  4850.  These basic routines will let the system do whatever is needed.
  4851.  Since the JSR to address and memory read/write routines can be used
  4852.  to download small sections of code that could be used to do more
  4853.  complex things, this basic command set is thus flexible enough
  4854.  to even replace itself.
  4855.  
  4856.  Caches will automatically be flushed as needed after each write.
  4857.  (A call to CacheClearU() will be made after the write and before
  4858.  the command done sequence)
  4859.  
  4860.  
  4861.         -- Technical Command Descriptions --
  4862.  
  4863.  Since the communications with SAD is via a serial port, data formats
  4864.  have been defined for minimum overhead while still giving reasonable data
  4865.  reliability.  SAD will use the serial port at default 9600 baud but the
  4866.  external tools can change the serial port's data rate if it wishes.  It
  4867.  would need to make sure that it will be able to reconnect.  SAD sets
  4868.  the baud rate to 9600 each time it is entered.  However, while within
  4869.  SAD, a simple command to write a WORD to the SERPER register would
  4870.  change the baud rate.  This will remain in effect until you exit and
  4871.  re-enter SAD or until you change the register again.  (This can be usefull
  4872.  if you need to transfer a large amount of data)
  4873.  
  4874.  All commands have a basic format that they will follow.  All commands have
  4875.  both an ACK and a completion message.
  4876.  
  4877.  Basic command format is:
  4878.  
  4879.  SENDER:    $AF <command byte> [<data bytes as needed by command>]
  4880.  
  4881.  Receive:
  4882.  Command ACK:  $00 <command byte>
  4883.  
  4884.  Command Done: $1F <command byte> [<data if needed>]
  4885.  
  4886.  Waiting: $53 $41 $44 $BF
  4887.  
  4888.  Waiting when called from Debug():    $53 $41 $44 $3F
  4889.  
  4890.  Waiting when in dead-end crash:    $53 $41 $44 $21
  4891.  
  4892.  The data sequence will be that SAD will emit a $BF and then wait for a
  4893.  command. If no command is received within <2> seconds, it will emit $BF
  4894.  again and loop back.  (This is the "heart beat" of SAD)  When called from
  4895.  Debug() and not the NMI hook, SAD will use $3F as the "heart beat"
  4896.  
  4897.  If SAD does not get a responce after <10> heartbeats, it will return to
  4898.  the system.  (Execute an RTS or RTE as needed)  This is to prevent a full
  4899.  hang.  The debugger at the other end can keep SAD happy by sending a
  4900.  NO-OP command.
  4901.  
  4902.  All I/O in SAD times out.  During the transmition of a command, if
  4903.  more than 2 seconds pass between bytes of data SAD will time out
  4904.  and return to the prompt.  This is mainly to help make sure that
  4905.  SAD can never get into an i-loop situation.
  4906.  
  4907.  
  4908.         -- Data Structure Issues --
  4909.  
  4910.  While executing in SAD, you may have full access to machine from the CPU
  4911.  standpoint.  However, this could also be a problem.  It is important to
  4912.  understand that when entered via NMI that many system lists may be in
  4913.  unstable state.  (NMI can happen in the middle of the AllocMem routine
  4914.  or task switch, etc)
  4915.  
  4916.  Also, since you are doing debugging, it is up to you to determin what
  4917.  operations can be done and what can not be done.  A good example is
  4918.  that if you want to write a WORD or LONG that the address will need to
  4919.  be even on 68000 processors.  Also, if you read or write memory that does
  4920.  not exist, you may get a bus error.  Following system structures may
  4921.  require that you check the pointers at each step.
  4922.  
  4923.  When entered via Debug(), you are now running as a "task" so you will
  4924.  be able to assume some things about system structures.  This means that
  4925.  you are in supervisor state and that you can assume that the
  4926.  system is at least not between states.  However, remember that since
  4927.  you are debugging the system, some bad code could cause data structures
  4928.  to be invalid.  Again, standard debugging issues are in play.  SAD just
  4929.  gives you the hooks to do whatever you need.
  4930.  
  4931.  Note:  When SAD prompts with $BF you will be in full disable/forbid
  4932.  state.  When $3F prompting, SAD will only do a Forbid().  It is possible
  4933.  for you to then disable interrupts as needed.  This is done such that it
  4934.  is possible to "run" the system from SAD when called with Debug().
  4935.  
  4936.  
  4937.         -- Data Frames and the Registers --
  4938.  
  4939.  SAD generates a special data frame that can be used to read what
  4940.  registers contain and to change the contents of the registers.
  4941.  See the entry for GET_CONTEXT_FRAME for more details
  4942.  
  4943.  ----------------------------------------------------------------------------
  4944. -
  4945.  
  4946.  BUGS
  4947.     In V39 EXEC, the WRITE_BYTE command was not connected and this
  4948.     caused all of the command numbers to be off-by-one.  For example,
  4949.     the READ_WORD command is listed as command $05 but in V39 is $04.
  4950.     However, the ACK of the commands are still correct.
  4951.  
  4952.     Also, in V39 EXEC, the READ_WORD command would return the wrong
  4953.     data.
  4954.  
  4955.     To determin if you are in V39 or V40 SAD, you can issue a simple
  4956.     SAD command at the start of the session.  By sending a READ_WORD
  4957.     command, you may either get a READ_WORD (V40) or a READ_LONG (V39)
  4958.     ACK'ed back.  So the data stream for a safe test would be:
  4959.  
  4960.     Send: $AF $05 $00 $F8 $00 $00               ; Read start of ROM...
  4961.     Recv: $00 $05 ....   You have V40 SAD
  4962.     Recv: $00 $06 ....   You have V39 SAD
  4963.  
  4964.     Note that you should be ready to read either 2 or 4 bytes of
  4965.     result depending on the ACK sent by the system.
  4966.  
  4967. SAD/ALLOCATE_MEMORY                                       SAD/ALLOCATE_MEMORY
  4968.  
  4969.  ALLOCATE MEMORY
  4970.  
  4971.  Command:    $AF $0A
  4972.  Data:        $qq $rr $ss $tt $hh $ii $jj $kk
  4973.  
  4974.  Allocate a chunk of memory that is <$qqrrsstt> bytes in size.  Note
  4975.  that this call is only safe when SAD is in $3F prompting mode (called
  4976.  from Debug()) and even then may be unsafe if the system is in bad shape.
  4977.  (You are debugging after all)  The returned address will be available to
  4978.  you until you release it.  (It is obtained via a call to AllocVec())  The
  4979.  type of memory allocated is <$hhiijjkk>.  Note that the allocation may
  4980.  fail. In that case, the address returned will be $00000000.
  4981.  
  4982.  Command ACK:    $00 $0A
  4983.  Command DONE:    $1F $0A $ww $xx $yy $zz
  4984.  
  4985.  
  4986. SAD/CALL_ADDRESS                                             SAD/CALL_ADDRESS
  4987.  
  4988.  CALL ADDRESS - JSR to the given address.
  4989.  
  4990.  Command:    $AF $07
  4991.  Data:        $ww $xx $yy $zz
  4992.  
  4993.  Call the following address as a subroutine.  No registers will be
  4994.  set up but the context frame will exist.  Standard calling
  4995.  conventions apply (d0/d1/a0/a1 are available, rest must be saved)
  4996.  The command will be ACK'ed when received.
  4997.  Command ACK:    $00 $07
  4998.  Command DONE:    $1F $07
  4999.  
  5000.  
  5001. SAD/FREE_MEMORY                                               SAD/FREE_MEMORY
  5002.  
  5003.  FREE MEMORY
  5004.  
  5005.  Command:    $AF $0B
  5006.  Data:        $ww $xx $yy $zz
  5007.  
  5008.  Free the memory allocated with the ALLOCATE MEMORY command.  This command
  5009.  has the same restrictions as ALLOCATE MEMORY.  Memory is released by
  5010.  calling FreeVec() on the address <$wwxxyyzz>
  5011.  
  5012.  Command ACK:    $00 $0B
  5013.  Command DONE:    $1F $0B
  5014.  
  5015.  
  5016. SAD/GET_CONTEXT_FRAME                                   SAD/GET_CONTEXT_FRAME
  5017.  
  5018.  GET CONTEXT FRAME
  5019.  
  5020.  Command:    $AF $09
  5021.  Data:        <none>
  5022.  
  5023.  This command will return a pointer to the saved context.  This will be
  5024.  a pointer to all of the registers that were saved on the stack along
  5025.  with some other details.  Returns frame address <$wwxxyyzz>
  5026.  
  5027.  The pointer returned is to the following structure:
  5028.  
  5029.  STRUCTURE    SAD_FRAME,0
  5030.     ; The first three are READ-ONLY...  Mainly used to make it
  5031.     ; easier to understand what is going on in the system.
  5032.     ULONG    SAD_VBR        ; Current VBR (always 0 on 68000 CPUs)
  5033.     ULONG    SAD_AttnFlags    ; ULONG copy of the flags (UPPER WORD==0)
  5034.     ULONG    SAD_ExecBase    ; ExecBase
  5035.     ; These fields are the user registers...  The registers are
  5036.     ; restored from these fields on exit from SAD...
  5037.     ; Note that USP is only valid if SR was *NOT* supervisor...
  5038.     ULONG    SAD_USP        ; User stack pointer
  5039.     ULONG    SAD_D0        ; User register d0
  5040.     ULONG    SAD_D1        ; User register d1
  5041.     ULONG    SAD_D2        ; User register d2
  5042.     ULONG    SAD_D3        ; User register d3
  5043.     ULONG    SAD_D4        ; User register d4
  5044.     ULONG    SAD_D5        ; User register d5
  5045.     ULONG    SAD_D6        ; User register d6
  5046.     ULONG    SAD_D7        ; User register d7
  5047.     ULONG    SAD_A0        ; User register a0
  5048.     ULONG    SAD_A1        ; User register a1
  5049.     ULONG    SAD_A2        ; User register a2
  5050.     ULONG    SAD_A3        ; User register a3
  5051.     ULONG    SAD_A4        ; User register a4
  5052.     ULONG    SAD_A5        ; User register a5
  5053.     ULONG    SAD_A6        ; User register a6
  5054.     ; This is for SAD internal use...  It is the prompt that
  5055.     ; SAD is using...  Changing this will have no effect on SAD.
  5056.     ULONG    SAD_PROMPT    ; SAD Prompt Longword...  (internal use)
  5057.     ; From here on down is the standard exception frame
  5058.     ; The first two entries (SR and PC) are standard on all 680x0 CPUs
  5059.     UWORD    SAD_SR        ; Status register (part of exception frame)
  5060.     ULONG    SAD_PC        ; Return address (part of exception frame)
  5061.  
  5062.  
  5063.  Command ACK:    $00 $09
  5064.  Command DONE:    $1F $09 $ww $xx $yy $zz
  5065.  
  5066.  
  5067. SAD/NOP                                                               SAD/NOP
  5068.  
  5069.  NO-OP - Do nothing other than tell SAD you are still there...
  5070.  
  5071.  Command:    $AF $00
  5072.  Data:        <none>
  5073.  
  5074.  This just tells SAD you are still there.  Required so that timeouts do
  5075.  not exit SAD while you are not doing anything.
  5076.  
  5077.  This command will *NOT* be ACK'ed.  It will just cause the timeout to
  5078.  be restarted.
  5079.  
  5080.  
  5081. SAD/READ_ARRAY                                                 SAD/READ_ARRAY
  5082.  
  5083.  READ ARRAY - Read a range of bytes
  5084.  
  5085.  Command:    $AF $0F
  5086.  Data:        $ww $xx $yy $zz $qq $rr $ss $tt
  5087.  
  5088.  Read a range of bytes from address <$wwxxyyzz> for <$qqrrsstt> bytes
  5089.  Will return that number of bytes...
  5090.  
  5091.  Command will be ACK'ed when received.
  5092.  Command ACK:    $00 $0F
  5093.  Command DONE:    $1F $0F $uu [$uu ...]
  5094.  
  5095.  
  5096. SAD/READ_BYTE                                                   SAD/READ_BYTE
  5097.  
  5098.  READ BYTE - Read a byte from the given address
  5099.  
  5100.  Command:    $AF $04
  5101.  Data:        $ww $xx $yy $zz
  5102.  
  5103.  Read a byte from address <$wwxxyyzz>  Returns <$qq> as result
  5104.  
  5105.  Command will be ACK'ed when received.
  5106.  Command ACK:    $00 $04
  5107.  Command DONE:    $1F $04 $qq
  5108.  
  5109.  
  5110. SAD/READ_LONG                                                   SAD/READ_LONG
  5111.  
  5112.  READ LONG - Read a long from the given address
  5113.  
  5114.  Command:    $AF $06
  5115.  Data:        $ww $xx $yy $zz
  5116.  
  5117.  Read a long from address <$wwxxyyzz>  Returns <$qqrrsstt> as result
  5118.  
  5119.  Command will be ACK'ed when received.
  5120.  Command ACK:    $00 $06
  5121.  Command DONE:    $1F $06 $qq $rr $ss $tt
  5122.  
  5123.  
  5124. SAD/READ_WORD                                                   SAD/READ_WORD
  5125.  
  5126.  READ WORD - Read a word from the given address        (V40 SAD)
  5127.  
  5128.  Command:    $AF $05
  5129.  Data:        $ww $xx $yy $zz
  5130.  
  5131.  Read a word from address <$wwxxyyzz>  Returns <$qqrr> as result
  5132.  
  5133.  Command will be ACK'ed when received.
  5134.  Command ACK:    $00 $05
  5135.  Command DONE:    $1F $05 $qq $rr
  5136.  
  5137.  BUGS
  5138.     This command does not return correct values in pre-V40 EXEC.
  5139.  
  5140. SAD/RESET                                                           SAD/RESET
  5141.  
  5142.  RESET - Reset the computer...
  5143.  
  5144.  Command:    $AF $10
  5145.  Data:        $FF $FF $FF $FF
  5146.  
  5147.  This command will reset the computer.  the $FFFFFFFF value is there
  5148.  mainly to prevent false reset.  This command will only be ACK'ed as
  5149.  the computer will be reset afterwards...
  5150.  
  5151.  Command will be ACK'ed when received.
  5152.  Command ACK:    $00 $10
  5153.  
  5154.  
  5155. SAD/RETURN_TO_SYSTEM                                     SAD/RETURN_TO_SYSTEM
  5156.  
  5157.  RETURN TO SYSTEM
  5158.  
  5159.  Command:    $AF $08
  5160.  Data:        $00 $00 $00 $00
  5161.  
  5162.  This command will return <exit> from SAD back to whatever started it.
  5163.  The 4 $00 are required as a "safty" to this command.  The command
  5164.  will be ACK'ed only as it will have lost control of the system.
  5165.  
  5166.  Command ACK:    $00 $08
  5167.  
  5168.  
  5169. SAD/TURN_OFF_SINGLE                                       SAD/TURN_OFF_SINGLE
  5170.  
  5171.  TURN OFF SINGLE STEPPING
  5172.  
  5173.  Command:    $AF $0D
  5174.  Data:        $ww $xx $yy $zz
  5175.  
  5176.  This command will turn off SAD single stepping mode.  You need to pass
  5177.  to it the address returned from the call to turn on single stepping mode.
  5178.  
  5179.  Command ACK:    $00 $0D
  5180.  Command DONE:    $1F $0D
  5181.  
  5182.  
  5183. SAD/TURN_ON_SINGLE                                         SAD/TURN_ON_SINGLE
  5184.  
  5185.  TURN ON SINGLE STEPPING
  5186.  
  5187.  Command:    $AF $0C
  5188.  Data:        <none>
  5189.  
  5190.  This command will turn on SAD single stepping mode.  This means that SAD
  5191.  will single step (via 68000 trace mode) the system.  SAD will take over
  5192.  the TRACE exception vector during this time.  This command will return
  5193.  the contents of the vector such that you can return this value when
  5194.  you wish to turn off single stepping mode.  Note that turning on single
  5195.  stepping mode while in $BF prompting will cause the step to be taken
  5196.  and then SAD will execute in $3F mode (non-NMI)
  5197.  The command returns <$wwxxyyzz> which you must use when turning off
  5198.  the single-step mode.
  5199.  
  5200.  Command ACK:    $00 $0C
  5201.  Command DONE:    $1F $0C $ww $xx $yy $zz
  5202.  
  5203.  
  5204. SAD/WRITE_ARRAY                                               SAD/WRITE_ARRAY
  5205.  
  5206.  WRITE ARRAY - Write a range of bytes
  5207.  
  5208.  Command:    $AF $0E
  5209.  Data:        $ww $xx $yy $zz $qq $rr $ss $tt
  5210.  
  5211.  Write a range of bytes to address <$wwxxyyzz> for <$qqrrsstt> bytes
  5212.  After the computer sends the ACK, you must then send the byte stream...
  5213.  
  5214.  Command will be ACK'ed when received.
  5215.  Command ACK:    $00 $0E
  5216.  Command DONE:    $1F $0E
  5217.  
  5218.  
  5219. SAD/WRITE_BYTE                                                 SAD/WRITE_BYTE
  5220.  
  5221.  WRITE BYTE - Write the given data to the address given    (V40 SAD)
  5222.  
  5223.  Command:    $AF $01
  5224.  Data:        $ww $xx $yy $zz $qq
  5225.  
  5226.  Write the byte <$qq> to address <$wwxxyyzz>
  5227.  
  5228.  Command will be ACK'ed when received.
  5229.  Command ACK:    $00 $01
  5230.  Command DONE:    $1F $01
  5231.  
  5232.  BUGS
  5233.     This command does not exists in pre-V40 EXEC.
  5234.     This command can be emulated with the WRITE_ARRAY command with
  5235.     a length of 1.
  5236.  
  5237. SAD/WRITE_LONG                                                 SAD/WRITE_LONG
  5238.  
  5239.  WRITE LONG - Write the given data to the address given
  5240.  
  5241.  Command:    $AF $03
  5242.  Data:        $ww $xx $yy $zz $qq $rr $ss $tt
  5243.  
  5244.  Write the long <$qqrrsstt> to address <$wwxxyyzz>
  5245.  
  5246.  Command will be ACK'ed when received.
  5247.  Command ACK:    $00 $03
  5248.  Command DONE:    $1F $03
  5249.  
  5250.  
  5251. SAD/WRITE_WORD                                                 SAD/WRITE_WORD
  5252.  
  5253.  WRITE WORD - Write the given data to the address given
  5254.  
  5255.  Command:    $AF $02
  5256.  Data:        $ww $xx $yy $zz $qq $rr
  5257.  
  5258.  Write the word <$qqrr> to address <$wwxxyyzz>
  5259.  
  5260.  Command will be ACK'ed when received.
  5261.  Command ACK:    $00 $02
  5262.  Command DONE:    $1F $02
  5263.  
  5264.  
  5265.