home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 420.lha / Example_device / Example.i < prev    next >
Encoding:
Text File  |  1990-09-29  |  7.0 KB  |  119 lines

  1. ;*********************************************************************
  2. ;*                                                                   *
  3. ;*********************************************************************
  4.  
  5.         ;*************
  6.         ;* Constants *
  7.         ;*************
  8. ABSEXECBASE EQU 4       ; Absolute Location of the Pointer to Exec.Library Base
  9.  
  10. MD_NUMUNITS EQU 4       ; Maximum Number of Units for This Device
  11. TASKSTKSIZE EQU $900    ; Size of Stack Provided for Each Unit Task
  12.  
  13.                         ; Set INFO_LEVEL to Zero to Disable Debugging Output
  14.                         ; Set INFO_LEVEL to 300 or so for Maximum Detail Output
  15. INFO_LEVEL  EQU 0       ; Specifies the Amount of Debugging Info Desired.
  16.                         ; If > 0 You Must Link with DEBUG.LIB!
  17.                         ; (You will need to run a terminal program to
  18.                         ; initially set the baud rate).
  19.  
  20.         ;****************************************
  21.         ;* Device Command Function-Code Equates *
  22.         ;* (In Addition to the Standard Codes)  *
  23.         ;* (See Include:Exec/IO.I for Info)     *
  24.         ;****************************************
  25.         DEVINIT                 ; Establish the Standard Basic Codes
  26. ;Option DEVCMD   CMD_USERDEF    ; Additional 'Extended' Device Commands as Defined
  27.         DEVCMD   CMDRANGE_END   ; Placemarker - First Illegal Command Code
  28.  
  29.         ;********************
  30.         ;* External Symbols *
  31.         ;********************
  32.         XLIB    Debug               ; Enter the Runtime Wack Debugger
  33.         XLIB    InitStruct          ; Initialize a Data Structure
  34.         XLIB    OpenLibrary         ; Open an Exec-Style Shared Library
  35.         XLIB    MakeLibrary         ; Create a Library-Style Node
  36.         XLIB    CloseLibrary        ; Close an Exec-Style Shared Library
  37.         XLIB    Alert               ; Display a Popup Alert Box to the User
  38.         XLIB    AllocMem            ; Allocate Some Memory
  39.         XLIB    FreeMem             ; Release Some Memory
  40.         XLIB    Remove              ; Remove a Node from a Linked List
  41.         XLIB    AddPort             ; Add a Message Port to the Public List
  42.         XLIB    AddTask             ; Create a New Task
  43.         XLIB    RemTask             ; Destroy an Existing Task
  44.         XLIB    SetTaskPri          ; Set the Scheduling Priority of a Task
  45.         XLIB    PutMsg              ; Send a Message to a Message Port
  46.         XLIB    WaitPort            ; Wait for a Message to Arrive at a Message Port
  47.         XLIB    GetMsg              ; Retrieve the Next Message at a Message Port
  48.         XLIB    ReplyMsg            ; Reply to a Message Received at a Message Port
  49.         XLIB    AllocSignal         ; Allocate One of My Signal Bits
  50.         XLIB    Signal              ; Generate a Signal to a Task
  51.         XLIB    Wait                ; Wait for Certain Signals to Me
  52.         XLIB    CopyMemQuick        ; Copy Memory Contents Quickly from A to B
  53.         XLIB    InitSemaphore       ; Initialize a Signal Semaphore Structure
  54.         XLIB    ObtainSemaphore     ; Obtain Exclusive Access to the Controlled Item
  55.         XLIB    ReleaseSemaphore    ; Release Exclusive Access to the Controlled Item
  56.  
  57.         INT_ABLES               ; Macro to Define XREF for Enable/Disable (exec/ables.i)
  58.  
  59.         ;***************************************
  60.         ;* Device-Command Classification Masks *
  61.         ;***************************************
  62.         ;* This equate is used to tell which device commands should be
  63.         ;* handled immediately (on the caller's thread).  This method
  64.         ;* of encoding limits the number of possible commands to 32.
  65.         ;*
  66.         ;* Commands which are trivially short and 100% reentrant should
  67.         ;* be performed immediately by the device, to eliminate the
  68.         ;* task switching overhead.
  69. IMMEDIATES  EQU %00000000000000000000000111000011
  70. ;                --------========--------========
  71. ;                FEDCBA9876543210FEDCBA9876543210
  72.         ;* This equate is used to tell which device commands should
  73.         ;* never be handled immediately.  This method of encoding
  74.         ;* limits the number of possible commands to 32.
  75.         ;*
  76. NEVERIMMED  EQU %00000000000000000000100000001100
  77. ;                --------========--------========
  78. ;                FEDCBA9876543210FEDCBA9876543210
  79.  
  80. ;*********************************************************************
  81. ;*          Layout Template of Device and Unit Structures            *
  82. ;*********************************************************************
  83.  
  84.         ; Device Node Structure <=====================================================
  85.         STRUCTURE   MyDev,LIB_SIZE          ; Standard Shared-Library-Style Structure |
  86.                     ; The rest of the items (except md_SegList) in this structure are |
  87.                     ; optional.  The device's seglist must be returned to Exec upon   |
  88.                     ; upon close to properly unload the device's code.                |
  89.         UBYTE       md_Flags                ; Device-Specific Flags                   |
  90.         UBYTE       md_Pad1                 ; (Pad to Longword Boundary)              |
  91.         ULONG       md_SysLib               ; Ptr to Base of Exec Shared Library      |
  92.         ULONG       md_SegList              ; Ptr to Device's Own LoadSegment List    |
  93.         STRUCT      md_SemLock,SS_SIZE      ; Semaphore Controlling Sharing of the    |
  94.                                             ;   Device Global Data Area               |
  95.         STRUCT      md_Units,MD_NUMUNITS*4  ; Array of Ptrs to Unit Descriptors (0-3) |
  96.         ;                                                                             |
  97.         ; Other Device-Specific Data Global Across All Units                          |
  98.         ;                                                                             |
  99.         LABEL       MyDev_Sizeof ; End of Device Node Structure <=====================
  100.  
  101.         ; Unit Descriptor Structure <=================================================
  102.         STRUCTURE   MyDevUnit,UNIT_SIZE     ; Standard MsgPort, RefCount, etc.        |
  103.         UBYTE       mdu_UnitNum             ; Unit Number (0-255)                     |
  104.         UBYTE       mdu_Pad2                ; (Pad to Longword Boundary)              |
  105.         APTR        mdu_Device              ; Ptr to Our Device Node                  |
  106.         STRUCT      mdu_Stack,TASKSTKSIZE   ; Memory Block for Use as Our Stack       |
  107.         STRUCT      mdu_Tcb,TC_SIZE         ; Memory Block for Use as Our TaskCtrlBlk |
  108.         LABEL       MyDevUnit_Sizeof        ; End of Unit Descriptor Structure <======
  109.  
  110.         ; Unit Descriptor Flags (UNIT_FLAGS)
  111. ;Std    BITDEF      UNIT,ACTIVE,0           ; Device is Active
  112. ;Std    BITDEF      UNIT,INTASK,1           ; Running in Device's Unit Task (vs User's Task)
  113.         BITDEF      MDU,STOPPED,2           ; Unit's Operation is Suspended (Stopped)
  114.  
  115. ;*********************************************************************
  116. ;*                                                                   *
  117. ;*********************************************************************
  118.  
  119.