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