home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / at-inc-bin.lha / os-include / exec / libraries.i < prev    next >
Text File  |  1993-10-15  |  4KB  |  129 lines

  1.     IFND    EXEC_LIBRARIES_I
  2. EXEC_LIBRARIES_I    SET    1
  3. **
  4. **    $VER: libraries.i 39.2 (10.4.92)
  5. **    Includes Release 40.15
  6. **
  7. **    Definitions for use when creating or using Exec libraries
  8. **
  9. **    (C) Copyright 1985-1993 Commodore-Amiga, Inc.
  10. **        All Rights Reserved
  11. **
  12.  
  13.     IFND EXEC_NODES_I
  14.     INCLUDE "exec/nodes.i"
  15.     ENDC    ; EXEC_NODES_I
  16.  
  17.  
  18. *------ Special Constants ---------------------------------------
  19. LIB_VECTSIZE    EQU    6        ;Each library entry takes 6 bytes
  20. LIB_RESERVED    EQU    4        ;Exec reserves the first 4 vectors
  21. LIB_BASE    EQU    -LIB_VECTSIZE
  22. LIB_USERDEF    EQU    LIB_BASE-(LIB_RESERVED*LIB_VECTSIZE) ;First user func
  23. LIB_NONSTD    EQU    LIB_USERDEF
  24.  
  25.  
  26. *----------------------------------------------------------------
  27. *
  28. *   Library Definition Macros (for creating libraries)
  29. *
  30. *----------------------------------------------------------------
  31.  
  32. *------ LIBINIT initializes the base offset for using the "LIBDEF" macro:
  33. LIBINIT     MACRO   ; [baseOffset]
  34.         IFC     '\1',''
  35. COUNT_LIB   SET     LIB_USERDEF
  36.         ENDC
  37.         IFNC    '\1',''
  38. COUNT_LIB   SET     \1
  39.         ENDC
  40.         ENDM
  41.  
  42. *------ LIBDEF is used to define each library function entry:
  43. LIBDEF        MACRO   ;libraryFunctionSymbol
  44. \1        EQU     COUNT_LIB
  45. COUNT_LIB   SET     COUNT_LIB-LIB_VECTSIZE
  46.         ENDM
  47.  
  48. *------ FUNCDEF is used to parse library offset tables.  Many applications
  49. *------ need a special version of FUNCDEF - you provide your own macro
  50. *------ to match your needs.  Here is an example:
  51. *
  52. *    FUNCDEF         MACRO
  53. *    _LVO\1         EQU    FUNC_CNT
  54. *    FUNC_CNT     SET    FUNC_CNT-6    * Standard offset-6 bytes each
  55. *    FUNC_CNT     EQU    LIB_USERDEF    * Skip 4 standard vectors
  56. *             ENDM
  57.  
  58. *----------------------------------------------------------------
  59. *
  60. *   Standard Library Functions
  61. *
  62. *----------------------------------------------------------------
  63.  
  64.     LIBINIT LIB_BASE
  65.  
  66.     LIBDEF  LIB_OPEN
  67.     LIBDEF  LIB_CLOSE
  68.     LIBDEF  LIB_EXPUNGE ; must exist in all libraries
  69.     LIBDEF  LIB_EXTFUNC    ; for future expansion - must return zero.
  70.  
  71.  
  72. *----------------------------------------------------------------
  73. *
  74. *   Library Base Structure Definition
  75. *   Also used for Devices and some Resources
  76. *
  77. *----------------------------------------------------------------
  78.  
  79.  STRUCTURE LIB,LN_SIZE
  80.     UBYTE   LIB_FLAGS            ; see below
  81.     UBYTE   LIB_pad            ; must be zero
  82.     UWORD   LIB_NEGSIZE        ; number of bytes before LIB
  83.     UWORD   LIB_POSSIZE        ; number of bytes after LIB
  84.     UWORD   LIB_VERSION        ; major
  85.     UWORD   LIB_REVISION        ; minor
  86.     APTR    LIB_IDSTRING        ; ASCII identification
  87.     ULONG   LIB_SUM            ; the system-calculated checksum
  88.     UWORD   LIB_OPENCNT        ; number of current opens
  89.     LABEL   LIB_SIZE    ;Warning: Size is not a longword multiple!
  90.  
  91. *------ LIB_FLAGS bit definitions (all others are system reserved)
  92.     BITDEF  LIB,SUMMING,0  ; system is currently checksumming
  93.     BITDEF  LIB,CHANGED,1  ; something has changed the library since last sum
  94.     BITDEF  LIB,SUMUSED,2  ; indicates if the library allows checksumming
  95.     BITDEF  LIB,DELEXP,3   ; delayed expunge flag (for use by library)
  96.     BITDEF  LIB,EXP0CNT,4  ; special system expunge flag.
  97.  
  98.  
  99. *---------------------------------------------------------------------------
  100. *
  101. *    Function Invocation Macros (for calling existing, opened, libraries)
  102. *    Also see exec/macros.i
  103. *
  104. *---------------------------------------------------------------------------
  105.  
  106. *------ CALLLIB for calling functions where A6 is already correct:
  107.  
  108. CALLLIB     MACRO   ; functionOffset
  109.     IFGT NARG-1
  110.         FAIL    !!! CALLLIB MACRO - too many arguments !!!
  111.     ENDC
  112.         JSR     \1(A6)
  113.         ENDM
  114.  
  115.  
  116. *------ LINKLIB for calling functions where A6 is incorrect:
  117.  
  118. LINKLIB     MACRO   ; functionOffset,libraryBase
  119.     IFGT NARG-2
  120.         FAIL    !!! LINKLIB MACRO - too many arguments !!!
  121.     ENDC
  122.         MOVE.L  A6,-(SP)
  123.         MOVE.L  \2,A6
  124.         JSR     \1(A6)
  125.         MOVE.L  (SP)+,A6
  126.         ENDM
  127.  
  128.     ENDC    ; EXEC_LIBRARIES_I
  129.