home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / Misc / TRSICAT.LZX / CATS_CD2_TRSI / Inc&AD2.1 / Text_Autodocs / cardres.doc < prev    next >
Encoding:
Text File  |  1992-09-11  |  37.5 KB  |  1,179 lines

  1. TABLE OF CONTENTS
  2.  
  3. card.resource/BeginCardAccess
  4. card.resource/CardAccessSpeed
  5. card.resource/CardChangeCount
  6. card.resource/CardForceChange
  7. card.resource/CardInterface
  8. card.resource/CardMiscControl
  9. card.resource/CardProgramVoltage
  10. card.resource/CardResetCard
  11. card.resource/CardResetRemove
  12. card.resource/CopyTuple
  13. card.resource/DeviceTuple
  14. card.resource/EndCardAccess
  15. card.resource/GetCardMap
  16. card.resource/IfAmigaXIP
  17. card.resource/OwnCard
  18. card.resource/ReadCardStatus
  19. card.resource/ReleaseCard
  20. card.resource/BeginCardAccess                   card.resource/BeginCardAccess
  21.  
  22.    NAME
  23.     BeginCardAccess -- Called before you begin credit-card memory access
  24.    
  25.    SYNOPSIS
  26.     result=BeginCardAccess( handle )
  27.     d0            a1
  28.  
  29.     BOOL BeginCardAccess( struct CardHandle * );
  30.  
  31.    FUNCTION
  32.     This function should be called before you begin access
  33.     to credit-card memory.
  34.  
  35.     Its effect will depend on the type of Amiga machine your
  36.     code happens to be running on.  On some machines it
  37.     will cause an access light to be turned ON.
  38.  
  39.    INPUTS
  40.     handle - Same handle as that used when OwnCard() was called.
  41.  
  42.    RETURNS
  43.     TRUE if you are still the owner of the credit-card, and
  44.     memory access is permitted.  FALSE if you are no longer
  45.     the owner of the credit-card (usually indicating that
  46.     the card was removed).
  47.  
  48.    NOTES
  49.     This function may be called from within a task, or from a level 1
  50.     or level 2 interrupt.
  51.  
  52.     It is highly recommended that you call this function
  53.     before accessing credit-card memory, as well as checking
  54.     the return value.  If it is a return value of FALSE, you
  55.     should stop accessing credit-card memory.
  56.  
  57.    SEE ALSO
  58.     OwnCard(), EndCardAccess()
  59.  
  60. card.resource/CardAccessSpeed                   card.resource/CardAccessSpeed
  61.  
  62.    NAME
  63.     CardAccessSpeed -- Select best possible memory access speed.
  64.    
  65.    SYNOPSIS
  66.     result=CardAccessSpeed( handle, nanoseconds );
  67.     d0             a1      d0
  68.  
  69.     ULONG CardAccessSpeed( struct CardHandle *, ULONG );
  70.  
  71.    FUNCTION
  72.     This function is used to set memory access speed for all CPU
  73.     accesses to card memory.
  74.  
  75.     Typically this information would be determined by first examining
  76.     the Card Information Structure.
  77.  
  78.     Then you would use this function to let the card.resource
  79.     select the best possible access speed for you, however note
  80.     that the range of possible access speeds may vary on some
  81.     machines (depending on the type of credit-card interface
  82.     hardware being provided).
  83.  
  84.    INPUTS
  85.     handle - Same handle as that used when OwnCard() was called.
  86.  
  87.     nanoseconds - Preferred access speed in nanoseconds.
  88.  
  89.    RETURNS
  90.     Speed - Access speed selected by resource (in nanoseconds). 
  91.  
  92.     0  - Not successful.  Either because the credit-card was
  93.     removed, or the access speed you requested is slower than
  94.     that supported by the credit-card interface hardware.
  95.  
  96.    NOTES
  97.     This function may be called from within a task, or from a level 1
  98.     or level 2 interrupt.
  99.  
  100.    SEE ALSO
  101.     OwnCard()
  102.  
  103. card.resource/CardChangeCount                   card.resource/CardChangeCount
  104.  
  105.    NAME
  106.     CardChangeCount -- Obtain card change count.
  107.    
  108.    SYNOPSIS
  109.     count = CardChangeCount( VOID )
  110.     d0
  111.  
  112.     ULONG CardChangeChange( VOID );
  113.  
  114.    FUNCTION
  115.     This function returns the card change count.  The
  116.     counter is incremented by one for every removal, and
  117.     for every successful insertion (a card which is inserted
  118.     long enough to be debounced before it is removed again).
  119.  
  120.    RESULT
  121.     The change count number.
  122.  
  123.    NOTES
  124.     This function may be called from a task, or any level interrupt.
  125.  
  126.    SEE ALSO
  127.  
  128. card.resource/CardForceChange                   card.resource/CardForceChange
  129.  
  130.    NAME
  131.     CardForceChange -- Force a card change.
  132.    
  133.    SYNOPSIS
  134.     success = CardForceChange( VOID )
  135.     d0
  136.  
  137.     BOOL CardForceChange( VOID );
  138.  
  139.    FUNCTION
  140.     This function is not intended for general use.  Its
  141.     purpose is to force a credit-card change as if
  142.     the user had removed, or inserted a card.
  143.     
  144.     This function is intended to be used by a utility program
  145.     which needs to force the current card owner to release
  146.     ownership of the card, thereby allowing the utility an
  147.     opportunity to own the credit-card.
  148.  
  149.    RESULT
  150.     TRUE if the function succeeded, FALSE if card change is
  151.     not allowed.  This function will generally succeed, unless
  152.     someone is using the card in reset remove mode at the time
  153.     this function is called.
  154.  
  155.    NOTES
  156.     This function should only be called from a task.
  157.  
  158.    SEE ALSO
  159.  
  160. card.resource/CardInterface                       card.resource/CardInterface
  161.  
  162.    NAME
  163.     CardInterface -- Determine the type of card interface.
  164.    
  165.    SYNOPSIS
  166.     return = CardInterface()
  167.     d0
  168.  
  169.     ULONG CardInterface( void );
  170.  
  171.    FUNCTION
  172.     This function is used to determine the type of credit-card
  173.     (hardware) interface available.  For the most part the
  174.     card.resource hides the hardware details from devices within its
  175.     function calls.  However should we need to provide a work-around
  176.     because of differences, or limitations imposed by future interface
  177.     hardware, this function must be used to identify which interface
  178.     is available.
  179.  
  180.    RETURN
  181.     A ULONG value as defined in card.h/i.
  182.  
  183.    NOTES
  184.     In general only I/O devices (e.g., a device which interfaces
  185.     with a modem card) would need to provide work-arounds,
  186.     or alternative code.  An example would be a change in the way
  187.     interrupt requests from the card are handled.  Specific details
  188.     will be provided as need in the future.  I/O devices) should abort
  189.     properly if this function returns a value which is unknown.
  190.  
  191.     Current implementations (see card.h/i) -
  192.  
  193.     CARD_INTERFACE_AMIGA_0
  194.     -------------------------------------------------------------
  195.  
  196.     The card slot can be configured for use as an I/O interface
  197.     by using the CardMiscControl() function.
  198.  
  199.     The card slot inhibits writes to cards which do not negate
  200.     the WP status bit.  This can be overridden by using the
  201.     CardMiscControl() function.
  202.  
  203.     Changes in the interrupt request line are latched by a gate-array,
  204.     and have to be obtained via the status change mechanism provided
  205.     when you call the OwnCard() function.  The interrupt is cleared
  206.     when you return from the status change interrupt.  A level 2
  207.     interrupt is generated.  The interrupt should also be cleared on
  208.     the card at this time.  The IRQ line is the same as the RDY/BSY
  209.     line.
  210.  
  211.     Changes in BVD1, WP, and RDY/BSY are also latched by the gate-array,
  212.     and are obtainable via the status change mechanism provided by
  213.     the OwnCard() function.  A level 2 interrupt is generated.
  214.  
  215.     Changes in BVD2 (also used for digital audio) have to be
  216.     monitored via polling.  Generally this will cause no problem.
  217.     Monitoring changes in BVD1 & BVD2 to monitor for low battery
  218.     condition can be handled by a low priority tool which periodically
  219.     checks the condition of both lines using the ReadCardStatus()
  220.     function.
  221.  
  222.     Some PC oriented eight (8) bit cards may require you read
  223.     odd-byte I/O address registers at the corresponding even-byte
  224.     address plus 64K.  There is sufficient I/O address space
  225.     provided that exceeding I/O address space should not be a problem.
  226.  
  227.     Your code should wait at least 1 millisecond for Vpp to stabilize
  228.     after voltage change (see CardProgramVoltage()).
  229.  
  230.     SEE ALSO
  231.     CardMiscControl(), resources/card.i, resources/card.h
  232.  
  233. card.resource/CardMiscControl                   card.resource/CardMiscControl
  234.  
  235.    NAME
  236.     CardMiscControl -- Set/Clear miscellaneous control bits
  237.    
  238.    SYNOPSIS
  239.     control_bits=CardMiscControl( handle, control_bits );
  240.     d0                 a1          d1
  241.  
  242.     UBYTE CardMiscControl( struct CardHandle *, UBYTE );
  243.  
  244.    FUNCTION
  245.     Used to set/clear miscellaneous control bits (generally for
  246.     use with I/O cards).
  247.  
  248.    INPUTS
  249.     handle - Same handle as that used when OwnCard() was called.
  250.  
  251.     control_bits - A mask value of control bits to be turned on/off.
  252.  
  253.     The bit values which might be usable are defined in card.h/i.
  254.  
  255.     For example, to enable digital audio, and disable hardware
  256.     write-protect (if supported), you would call this function with these
  257.     values --
  258.  
  259.     CARDF_DISABLE_WP|CARDF_ENABLE_DIGAUDIO
  260.     
  261.     Then to turn off digital audio, but leave write-protect
  262.     disable, you would use a value of --
  263.  
  264.     CARDF_DISABLE_WP
  265.  
  266.     Finally too reenable write protect, call this function with
  267.     a mask value of 0.
  268.  
  269.    RETURNS
  270.     control_bits - The same mask value you called this function
  271.     with if successful.  If one, or more bits has been cleared
  272.     in the return mask, this would indicate that the control bit
  273.     is not being supported, or that the card has been removed
  274.     by the user.
  275.  
  276.     For example, if you called this function with a mask value
  277.     of --
  278.  
  279.     CARDF_DISABLE_WP|CARDF_ENABLE_DIGAUDIO
  280.  
  281.     And this function returned a value of --
  282.  
  283.     CARDF_DISABLE_WP
  284.  
  285.     This would indicate that it is not possible to enable digital
  286.     audio (most likely because this feature has not been implemented).
  287.     
  288.    NOTES
  289.     This function may be called from within a task, or from a level 1
  290.     or level 2 interrupt.
  291.  
  292.     !!!IMPORTANT!!!
  293.  
  294.     You should ALWAYS try to enable digital audio for I/O cards
  295.     as this will also configure the card socket for the I/O
  296.     interface (if supported).
  297.  
  298.     Not all cards will connect the write-enable line (e.g.,
  299.     some I/O cards).  On some machines (e.g., the A600) it will
  300.     not be possible to write to such cards unless you disable
  301.     write-protection by using this function.
  302.  
  303.    SEE ALSO
  304.     CardInterface(), resources/card.h, resources/card.i
  305.  
  306. card.resource/CardProgramVoltage             card.resource/CardProgramVoltage
  307.  
  308.    NAME
  309.     CardProgramVoltage -- Set programming voltage.
  310.    
  311.    SYNOPSIS
  312.     success=CardProgramVoltage( handle, voltage );
  313.                     a1      d0
  314.  
  315.     LONG CardProgramVoltage( struct CardHandle *, ULONG );
  316.  
  317.    FUNCTION
  318.     Used to set programming voltages (e.g., for FLASH-ROM/EPROM
  319.     cards).
  320.  
  321.    INPUTS
  322.     handle - Same handle as that used when OwnCard() was called.
  323.  
  324.     voltage - See card.i/h for valid values.
  325.  
  326.    RETURNS
  327.     1  - Successful.
  328.  
  329.     0  - Not successful.  Most likely because the credit-card
  330.     card has been removed, and you are no longer the owner.
  331.  
  332.     -1 - This function is not being supported.  On some machines
  333.     with a minimal (hardware) credit-card interface, this feature
  334.     may not be possible.
  335.  
  336.    NOTES
  337.     This function may be called from within a task, or from a level 1
  338.     or level 2 interrupt.
  339.  
  340.        !!!WARNING!!!
  341.  
  342.     Flash-ROM programming requires careful coding to prevent
  343.     leaving the Erase command on too long.  Failure to observe
  344.     the maximum time between the Erase command, and the Erase-Verify
  345.     command can make a Flash-ROM card unusable.  Some Flash-ROM cards
  346.     may provide an internal watch-dog timer which protects the card.
  347.  
  348.     Because of the relatively long time (e.g., 10ms) between Erase, and
  349.     Erase-Verify which must be observed, the need for such critical
  350.     timing can be problematic on a multi-tasking machine.
  351.  
  352.     Vendors of Flash-ROM's recommend a high priority interrupt
  353.     generated by a 10ms timer be used to turn off Erase.  On the
  354.     Amiga this can be accomplished by using a CIA-B interval timer.
  355.     The timer.device also provides a mechanism for generating a low
  356.     priority interrupt.  The timer.device is easier to use than CIA
  357.     interval timers, though not as accurate or as safe.
  358.  
  359.     Even if the Flash-ROM card provides an internal watch-dog timer,
  360.     implementation of the code during Erase should assume that
  361.     the Flash-ROM does not.
  362.  
  363.    SEE ALSO
  364.     OwnCard(), resources/card.h, resources/card.i
  365.  
  366. card.resource/CardResetCard                       card.resource/CardResetCard
  367.  
  368.    NAME
  369.     CardResetCard -- Reset credit-card.
  370.    
  371.    SYNOPSIS
  372.     success=CardResetCard( handle );
  373.                 a1
  374.  
  375.     BOOL CardResetCard( struct CardHandle * );
  376.  
  377.    FUNCTION
  378.     Used to reset a credit-card.  Some cards, such as some
  379.     configurable cards can be reset.
  380.  
  381.     Asserts credit-card reset for at least 10us.
  382.  
  383.    INPUTS
  384.     handle - Same handle as that used when OwnCard() was called.
  385.  
  386.    RETURNS
  387.     TRUE  - Successful.
  388.  
  389.     FALSE  - Not successful.  Most likely because the credit-card
  390.     card has been removed, and you are no longer the owner.
  391.  
  392.    NOTES
  393.     This function may be called from within a task, or from a level 1
  394.     or level 2 interrupt.
  395.  
  396.     ***IMPORTANT***
  397.  
  398.     It is the responsibility of the card owner to reset
  399.     configurable cards, or any other type of card such as
  400.     some I/O cards before calling ReleaseCard() if the owner
  401.     has made use of that card such that it is no longer in its
  402.     reset state (unless you are releasing the card because it
  403.     has been removed).
  404.  
  405.     If the card manufacturer indicates that a certain amount
  406.     of time must elapse between end of reset, and completion
  407.     of card initialization, you should wait at least that long
  408.     before releasing the card (unless you are releasing the card
  409.     because it has been removed).
  410.  
  411.    SEE ALSO
  412.     OwnCard(), ReleaseCard()
  413.  
  414. card.resource/CardResetRemove                   card.resource/CardResetRemove
  415.  
  416.    NAME
  417.     CardResetRemove -- Set/Clear reset on card removal.
  418.    
  419.    SYNOPSIS
  420.     success=CardResetRemove( handle, flag );
  421.                  a1      d0
  422.  
  423.     BOOL CardResetRemove( struct CardHandle *, ULONG );
  424.  
  425.    FUNCTION
  426.     Used to set/clear HARDWARE RESET on card change detect.
  427.  
  428.     This function should generally not be used by devices
  429.     which support HOT-REMOVAL.  HARDWARE RESET on removal
  430.     is generally intended for execute-in-place software, or
  431.     ram cards whose memory has been added as system ram.
  432.  
  433.    INPUTS
  434.     handle - Same handle as that used when OwnCard() was called.
  435.  
  436.     flag - TRUE if you want to SET HARDWARE RESET on credit
  437.            card removal.  FALSE if you want to CLEAR HARDWARE
  438.            RESET.
  439.  
  440.    RETURNS
  441.     1  - Success.
  442.  
  443.     0  - Function failed (most likely because the card was removed
  444.          by the user, and you are no longer the owner of the card).
  445.  
  446.     -1 - This function is not being made available.
  447.  
  448.    NOTES
  449.     This function should only be called from a task.
  450.  
  451.    SEE ALSO
  452.     OwnCard()
  453.  
  454. card.resource/CopyTuple                               card.resource/CopyTuple
  455.  
  456.    NAME
  457.     CopyTuple -- Find/copy a credit card tuple.
  458.    
  459.    SYNOPSIS
  460.     success = CopyTuple( CardHandle, buffer, tuplecode, size );
  461.     d0            a1     a0     d1        d0
  462.  
  463.     BOOL CopyTuple( struct CardHandle *, UBYTE *, ULONG, ULONG );
  464.  
  465.    FUNCTION
  466.     This function scans credit-card memory for a tuple, and
  467.     if found, copies it into a supplied buffer.  The entire
  468.     tuple (including the tuple code, and link) are copied to
  469.     the supplied buffer.  The number of bytes copied to the
  470.     buffer will be 2 bytes, plus the argument "size", or the
  471.     value in the tuple LINK field (whichever is SMALLER).
  472.  
  473.     The software calling this function is responsible for
  474.     examining the copy of the tuple (e.g., recognition of
  475.     fields, recognition of stop bytes, etc. within the tuple).
  476.     
  477.     This function does the best job it can to find a tuple
  478.     in attribute, or common memory.  It follows tuple chains,
  479.     and skips odd bytes in attribute memory.
  480.  
  481.     This function monitors for credit-card removal while reading data.
  482.     If the credit-card is removed while a byte is being read, it will
  483.     stop searching, and return FALSE.
  484.  
  485.     This function does not protect against another task writing
  486.     to credit-card memory while data is being read.  The device
  487.     is responsible for single-threading reads/writes to the
  488.     credit card as needed.
  489.  
  490.     This function can be used to find multiple tuple codes; this
  491.     is a very rare case, so the mechanism provided for doing so is
  492.     unusual.  See INPUTS below for more information.
  493.  
  494.     This function does not read bytes within the body of any tuples
  495.     except for the tuple you want copied, and the basic compatibility
  496.     tuples this function understands (see list below).
  497.  
  498.     On some machines this function may slow down memory access
  499.     speed while reading the tuple chain.  This is done to prevent
  500.     potential problems on slow cards.  By examining the CISTPL_DEVICE,
  501.     and CISTPL_DEVICE_A tuples, you can determine the best possible
  502.     memory access speed for the type of card inserted.  Because memory
  503.     access speed may be slowed down, calls to this function should
  504.     be single-threaded.
  505.  
  506.     The Card Information Structure must start with a CISTPL_DEVICE
  507.     tuple stored as the first tuple in attribute memory.  If not,
  508.     this function will search for a CISTPL_LINKTARGET tuple
  509.     stored at byte 0 of common memory.  Therefore it is possible
  510.     to store a CIS on cards which do not have any writeable
  511.     attribute memory, though this may cause problems for other
  512.     software implemented on other machines.  For example, some
  513.     SRAM cards do not come with writeable attribute memory, and/or
  514.     some may have OPTIONAL EEPROM memory which may not have been
  515.     initialized by the card manufacturer.  While it could be
  516.     argued that such cards do not conform to the PCMCIA PC Card
  517.     Standard, such cards are cheaper, and therefore likely to be
  518.     used.
  519.  
  520.    INPUTS
  521.     CardHandle - Same handle as that used when OwnCard() was
  522.     called.
  523.  
  524.     buffer - Pointer to a buffer where the tuple will be copied.
  525.  
  526.     The buffer should be at least as large as "size" + 8 (see
  527.     use of "size" argument below).  Therefore the minimum buffer
  528.     size is 8 bytes.  See NOTES below.
  529.  
  530.     tuplecode - The tuple code you want to search for.  This is
  531.     a ULONG value.  The upper 16 bits should be 0, or a number between
  532.     1-32K where a value of 0 means you want to find the first tuple
  533.     match, a value of 1 the second, etc.  For example -
  534.  
  535.     0x41 means find the FIRST tuple equal to $41.
  536.  
  537.     ((1<<16)|(0x41)) means find the SECOND tuple equal to $41.
  538.  
  539.     ((2<<16)|(0x41)) means find the THIRD tuple equal to $41.
  540.  
  541.     size - The maximum number of bytes you want copied (not
  542.            including the tuple code, and link).  The actual number
  543.            of bytes copied may be less than "size" if the tuple
  544.            link field is less than "size".
  545.  
  546.            A size of 0 will result in only the tuple code, and
  547.            link being copied to your buffer if the tuple is found.
  548.  
  549.            If you do not care how many bytes are copied, any unsigned
  550.            value of 255 or greater will do.  In this case a maximum
  551.            of 257 bytes might be copied to your buffer (if the
  552.            tuple link field is the maximum of 255).
  553.  
  554.            Other sizes are useful if you know the size of the tuple
  555.            you want copied, or you know there are active registers
  556.            stored within the tuple, and only want to copy a portion
  557.            of a tuple.
  558.  
  559.    RETURNS
  560.  
  561.     TRUE if the tuple was found, and copied, else FALSE.
  562.     This function may also return false if the CIS is believed
  563.     to be corrupt, or if the card is removed while reading the
  564.     tuples.
  565.  
  566.    NOTES
  567.  
  568.     This function can be called multiple times (adjusting the "size"
  569.     argument) to read a tuple of variable length, or unknown size.
  570.  
  571.     Your supplied buffered is used by this function for working
  572.     storage - the contents of it will be modified even if this
  573.     function fails to find the tuple you want a copy of.
  574.  
  575.     This function should NOT be used to find/copy tuples of type :
  576.  
  577.     - CISTPL_LONGLINK_A
  578.     - CISTPL_LONGLINK_C
  579.     - CISTPL_NO_LINK
  580.     - CISTPL_LINKTARGET
  581.     - CISTPL_NULL
  582.     - CISTPL_END
  583.     
  584.     These tuples are automatically handled for you by this function.
  585.  
  586.    SEE ALSO
  587.     OwnCard()
  588.  
  589. card.resource/DeviceTuple                           card.resource/DeviceTuple
  590.  
  591.    NAME
  592.     DeviceTuple -- Decode a device tuple
  593.    
  594.    SYNOPSIS
  595.     return=DeviceTuple( tuple_data, storage)
  596.                    a0        a1    
  597.  
  598.     ULONG DeviceTuple( UBYTE *, struct DeviceTData *);
  599.  
  600.    FUNCTION
  601.     Extracts SIZE, TYPE, and SPEED from a device tuple (generally
  602.     obtained with CopyTuple()).
  603.  
  604.    INPUTS
  605.     tuple_data - Pointer to a CISTPL_DEVICE tuple (generally obtained
  606.     with CopyTuple()).
  607.  
  608.     storage - Pointer to a DeviceTData structure in which results
  609.     are to be stored.
  610.  
  611.     struct    DeviceTData {
  612.         ULONG    dtd_DTsize;        /* Size of card (bytes)    */
  613.         ULONG    dtd_DTspeed;        /* Speed in nanoseconds    */
  614.         UBYTE    dtd_DTtype;        /* Type of card        */
  615.         UBYTE    dtd_DTflags;        /* Other flags        */
  616.     };
  617.  
  618.  
  619.    RETURN
  620.     SIZE (same as dtd_DTsize) if the Device Tuple could be decoded.
  621.     FALSE (0) if the tuple is believed to be invalid.  The tuple is
  622.     considered to be invalid if:
  623.  
  624.         The tuple link value is 0.
  625.  
  626.         The device type/speed byte is $00, or $FF.
  627.  
  628.         The device type is DTYPE_EXTEND, which is undefined
  629.         as of this writing.
  630.  
  631.         The extended speed byte is a value which is
  632.         undefined as of this writing.
  633.  
  634.         The extended speed byte is extended again which is
  635.         undefined as of this writing.
  636.  
  637.         The device Size byte is $FF.
  638.  
  639.    NOTES
  640.     Some cards may not have a size specified in the device
  641.     tuple.  An example would be an I/O card.  The size would be
  642.     returned as one (1) in this case.
  643.  
  644.     You should not call this function with a partial CISTPL_DEVICE
  645.     tuple, or the return values may be junk.
  646.  
  647.    SEE ALSO
  648.     CopyTuple(), resources/card.h, resources/card.i
  649.  
  650. card.resource/EndCardAccess                       card.resource/EndCardAccess
  651.  
  652.    NAME
  653.     EndCardAccess -- Called at the end of credit-card memory access
  654.    
  655.    SYNOPSIS
  656.     result=EndCardAccess( handle )
  657.     d0            a1
  658.  
  659.     ULONG EndCardAccess( struct CardHandle * );
  660.  
  661.    FUNCTION
  662.     This function should be called when you are done accessing
  663.     credit-card memory.
  664.  
  665.     Its effect will depend on the type of Amiga machine your
  666.     code happens to be running on.  On some machines it
  667.     will cause an access light to be turned OFF in approximately
  668.     1/2 second.
  669.  
  670.     On machines which support an access light, the light will
  671.     automatically be turned off when you call ReleaseCard().
  672.  
  673.    INPUTS
  674.     handle - Same handle as that used when OwnCard() was called.
  675.  
  676.    RETURNS
  677.     TRUE if you are still the owner of the credit-card.  FALSE
  678.     if you are no longer the owner of the credit-card (usually
  679.     indicating the card was removed).
  680.  
  681.    NOTES
  682.     This function may be called from within a task, or from a level 1
  683.     or level 2 interrupt.
  684.  
  685.     It is highly recommended that you call this function
  686.     after accessing credit-card memory, as well as checking
  687.     the return value.  If it is a return value of FALSE, you
  688.     should stop accessing credit-card memory, and conclude
  689.     that the card was removed before this function was called.
  690.  
  691.     On some machines it is possible that the credit-card will be
  692.     removed before you receive the removed interrupt.
  693.  
  694.    SEE ALSO
  695.     OwnCard(), ReleaseCard(), BeginCardAccess()
  696.  
  697. card.resource/GetCardMap                             card.resource/GetCardMap
  698.  
  699.    NAME
  700.     GetCardMap -- Obtain pointer to CardMemoryMap structure
  701.    
  702.    SYNOPSIS
  703.     pointer=GetCardMap()
  704.     d0
  705.  
  706.     struct CardMemoryMap *GetCardMap( void );
  707.  
  708.    FUNCTION
  709.     Obtain pointer to a CardMemoryMap structure.  The structure
  710.     is READ only.
  711.  
  712.     Devices should never assume credit-card memory appears
  713.     at any particular place in memory.  By using this function
  714.     to obtain pointers to the base memory locations of the various
  715.     credit-card memory types, your device will continue to work
  716.     properly should credit cards appear in different memory
  717.     locations in future hardware.
  718.  
  719.    RETURNS
  720.     Pointer to CardMemoryMap structure -
  721.  
  722.         struct CardMemoryMap {
  723.         UBYTE    *cmm_CommonMemory;
  724.         UBYTE    *cmm_AttributeMemory;
  725.         UBYTE    *cmm_IOMemory;
  726.         };
  727.    NOTES
  728.     If any pointer in the structure is NULL, it means this type
  729.     of credit-card memory is not being made available.
  730.  
  731.    SEE ALSO
  732.     resources/card.h, resources/card.i
  733.  
  734. card.resource/IfAmigaXIP                             card.resource/IfAmigaXIP
  735.  
  736.    NAME
  737.     IfAmigaXIP -- Check if a card is an Amiga execute-in-place card.
  738.    
  739.    SYNOPSIS
  740.     result=IfAmigaXIP( handle )
  741.     d0               a2
  742.  
  743.     struct Resident *IfAmigaXIP( struct CardHandle * );
  744.  
  745.    FUNCTION
  746.     Check to see if a card in the slot is an Amiga execute-in-place
  747.     card.  The Card Information Structure must have a valid
  748.     CISTPL_AMIGAXIP tuple.
  749.     
  750.     Tuples can be treated like structures.  The format of a
  751.     CISTPL_AMIGAXIP tuple is -
  752.     
  753.  
  754.      struct TP_AmigaXIP {
  755.         UBYTE    TPL_CODE;
  756.         UBYTE    TPL_LINK;
  757.         UBYTE    TP_XIPLOC[4];
  758.         UBYTE    TP_XIPFLAGS;
  759.         UBYTE    TP_XIPRESRV;
  760.     };
  761.  
  762.  
  763.     The TPL_CODE field must be equal to CISTPL_AMIGAXIP (0x91).
  764.  
  765.     The TPL_LINK field must be equal to the length of the body
  766.     of a CISTPL_AMIGAXIP tuple (0x06).
  767.  
  768.     The TP_XIPLOC array is the memory location of your ROM-TAG
  769.     stored in little-endian order.  This value is stored as an
  770.     "offset" into common memory as is the standard for storing 32 bit
  771.     bit pointers in tuples.
  772.  
  773.     For example, a pointer to a ROM-TAG stored at an offset of
  774.     0x00000200 would be stored as four bytes like so:
  775.  
  776.         0x00, 0x02, 0x00, 0x00
  777.  
  778.     Currently credit-card common memory is mapped starting at
  779.     memory location 0x600000.  Because a ROM-TAG is used,
  780.     it is implied that execute-in-place code can be compiled/linked
  781.     to use absolute references.  It is believed that most developers
  782.     will not want to have to write pc-relative code only.
  783.  
  784.     The TP_XIPFLAGS field is treated as a set of flag bits.
  785.     See card.i/h for defined bits.  All undefined bits MUST be
  786.     0.
  787.  
  788.     The TP_XIPRESRV field must be 0 for now.
  789.     
  790.  
  791.     The system polls for cards which have a CISTPL_AMIGAXIP tuple
  792.     at the same time that it searches for devices to boot off.
  793.     When a card with a valid CISTPL_AMIGAXIP tuple is found, the
  794.     system will call your ROM-TAG via Exec's InitResident() function.
  795.  
  796.     The system examines the return code from InitResident().  A
  797.     NULL return in D0 means you are done with the card, and it can
  798.     be removed by the user.  A successful return indicates you are
  799.     still using the card.  Some programs (e.g., some games) may
  800.     never return.  The only requirement is that if you do return,
  801.     you must leave the system in a "good" state (including returning
  802.     most of, or all the memory you allocated).  The standard
  803.     convention for preserving registers apply.
  804.  
  805.     Note that your execute-in-place code will not be called
  806.     a second time, unless you have returned a non-successful
  807.     result.  In this case your execute-in-place code MUST
  808.     assume the user can remove, and insert your card again.
  809.     There are a variety of ways to check for re-insertion
  810.     (e.g., search for a message port, device, library, task,
  811.     etc., that you created).
  812.  
  813.     Note that your execute-in-place code runs in an environment
  814.     similar to boot block games; before DOS has been initialized!
  815.  
  816.     Your execute-in-place code should NOT try to initialize DOS
  817.     because DOS requires a suitable disk-like device be at
  818.     the head of the expansion base mountlist to boot off.
  819.  
  820.     If you need DOS, it is possible to boot off a credit-card using
  821.     carddisk.device.  Such cards will require a valid
  822.     CISTPL_DEVICE tuple, and CISTPL_FORMAT tuple.  A portion
  823.     of the card can be used for a minimal number of data blocks
  824.     like the method described above.
  825.  
  826.     However this method is not recommended, though it is anticipated
  827.     that some developers will have thought of, and used this
  828.     method anyway.  If you must do this, at least use the
  829.     CardHandle returned by OwnCard() to set hardware reset
  830.     on removal else the machine will likely crash anyway if
  831.     the card is removed while your execute-in-place code is running.
  832.  
  833.    RETURNS
  834.     Pointer to a ROM-TAG on the card, or NULL indicating that:
  835.  
  836.     o The card does not meet the above requirements, or
  837.     o The card has been removed, or
  838.     o You are not the owner of the credit-card.
  839.  
  840.    NOTES
  841.     This function is being made public so developers can test
  842.     test that their execute-in-place credit-cards meet the
  843.     requirements for an Amiga execute-in-place card.  In general
  844.     there is no reason for devices, or applications to use this
  845.     function.
  846.  
  847.     Amiga execute-in-place software is identified via a tuple code
  848.     reserved for manufacturer specific use, therefore the manufacturer
  849.     of the card may freely use the CISTPL_VERS_1, or CISTPL_VERS_2
  850.     tuples to place identification information on the credit-card.
  851.  
  852.     No attempt has been made to make use of the MS-DOS execute-in-place
  853.     method; it is believed that most manufacturers of Amiga
  854.     execute-in-place software will prefer a simple, and small
  855.     scheme for running their execute-in-place code.
  856.  
  857.    SEE ALSO
  858.     OwnCard(), resources/card.h, resources/card.i
  859.  
  860. card.resource/OwnCard                                   card.resource/OwnCard
  861.  
  862.    NAME
  863.     OwnCard -- Own credit card registers, and memory
  864.    
  865.    SYNOPSIS
  866.     return = OwnCard( handle )
  867.     d0        a1
  868.  
  869.     struct CardHandle *OwnCard( struct CardHandle * );
  870.  
  871.    FUNCTION
  872.     This function is used to obtain immediate, or deferred
  873.     ownership of a credit-card in the credit-card slot.
  874.  
  875.     Typically an EXEC STYLE DEVICE will be written to interface
  876.     between an application, and a credit card in the slot.  While
  877.     applications, and libraries can attempt to own a credit-card
  878.     in the card slot, the rest of this documentation assumes a
  879.     device interface will be used.
  880.  
  881.     Because credit-cards can be inserted, or removed by the user at
  882.     any time (otherwise known as HOT-INSERTION, and HOT-REMOVAL),
  883.     the card.resource provides devices with a protocol which
  884.     lets many devices bid for ownership of a newly inserted card.
  885.  
  886.     In general, devices should support HOT-REMOVAL, however there
  887.     are legitimate cases where HOT-REMOVAL is not practical.  For
  888.     these cases this function allows you to own the resource using
  889.     the CARDB_RESETREMOVE flag.  If the card is removed before your
  890.     device calls ReleaseCard(), the machine will RESET.
  891.  
  892.    INPUTS
  893.     handle - pointer to a CardHandle structure.
  894.  
  895.         struct CardHandle {
  896.         struct Node          cah_CardNode;
  897.         struct Interrupt    *cah_CardRemoved;
  898.         struct Interrupt    *cah_CardInserted;
  899.         struct Interrupt    *cah_CardStatus;
  900.         UBYTE             cah_CardFlags;
  901.         };
  902.  
  903.     The following fields in the structure must be filled
  904.     in by the application before calling OwnCard() -
  905.  
  906.     cah_CardNode.ln_Pri -
  907.  
  908.         See table below.  The Node field is used by the resource to
  909.         add your handle to a sorted list of CardHandle structures. 
  910.         This list is used by the resource to notify devices when the
  911.         device owns the credit-card.
  912.  
  913.         Your device will only be notified (at most) one time
  914.         per card insertion, and perhaps less often if some
  915.         higher priority device on the notification list retains
  916.         ownership of a card in the slot.
  917.  
  918.     Priority    Comments
  919.     --------------------------------------------------
  920.         >= 21    Reserved for future use
  921.  
  922.         10-20    To be used by third party devices (e.g.,
  923.             I/O CARD manufacturers) which look for
  924.             specific card tuples to identify credit-cards.
  925.  
  926.         01-19    Reserved for future use
  927.  
  928.         00    To be used by general purpose devices which
  929.             have loose card specification requirements.
  930.  
  931.         <= -1    Reserved for future use
  932.  
  933.           
  934.     cah_CardNode.ln_Type -
  935.  
  936.         Must be set to 0 for now.  This field may be used in the
  937.         future to identify an extended CardHandle structure.
  938.  
  939.     cah_CardNode.ln_Name -
  940.  
  941.         Must be initialized to NULL, or name of device which owns
  942.         this structure.
  943.  
  944.     cah_CardRemoved -
  945.  
  946.         Pointer to an initialized interrupt structure.  Only the
  947.         is_Data, and is_Code fields need to be initialized.  This
  948.         is the interrupt code which will be called when a credit-card
  949.         which your device owns is removed.  Once you receive this
  950.         interrupt, all credit-card interface control registers are
  951.         reset (e.g., programming voltage, access speed, etc.), and 
  952.         you should stop accessing the card as soon as possible.
  953.  
  954.         Because your code is called on interrupt time, you
  955.         should do the least amount possible, and use little
  956.         stack space.
  957.  
  958.         This pointer can be NULL if you have asked for reset
  959.         on card-removal, and you never turn reset off.
  960.  
  961.     cah_ CardInserted -
  962.  
  963.         Pointer to an initialized interrupt structure.  Only the
  964.         is_Data, and is_Code fields need to be initialized.  This
  965.         is the code which will be called when your CardHandle owns
  966.         the credit-card in the slot.
  967.  
  968.         Note that your code may be called on the context of
  969.         an interrupt, or a task in FORBID, therefore you should
  970.         do the least amount possible, and use little stack space.
  971.  
  972.         Note that it is possible to receive a card removed
  973.         interrupt immediately before you receive this interrupt if
  974.         the card is removed while your CardInserted interrupt
  975.         is being called.
  976.         
  977.         Your device owns the credit-card until the card is manually
  978.         removed by the user, or you release the card by calling
  979.         ReleaseCard().
  980.  
  981.         Your device should examine the card in the slot (e.g., look
  982.         for specific tuples), and decide if the card is of a type your
  983.         device understands.
  984.  
  985.         If not, release ownership of the card by calling
  986.         ReleaseCard() so that other devices will be given a chance to
  987.         examine the current card in the credit-card slot.
  988.  
  989.     cah_CardStatus -
  990.  
  991.         Pointer to an initialized interrupt structure.  Only the
  992.         is_Data, and is_Code fields need to be initialized.
  993.  
  994.         Note that your code will be called on the context of
  995.         an interrupt, therefore you should do the least
  996.         amount possible, and use little stack space.
  997.  
  998.         Note that it is possible to receive a card removed
  999.         interrupt immediately before you receive this interrupt
  1000.         if the card is removed during this interrupt.
  1001.         
  1002.         If this pointer is NULL, you will not receive card status
  1003.         change interrupts.
  1004.  
  1005.         Your interrupt code will be called with a mask value in
  1006.         register D0, and a pointer to your data in A1.
  1007.  
  1008.         The mask value in D0 can be interpreted using the same bit
  1009.         definitions returned by ReadCardStatus().  Note that more
  1010.         than one bit may be set, and the mask only tells you what has
  1011.         changed, not the current state.
  1012.  
  1013.         Use ReadCardStatus() if you need to determine the current
  1014.         state of the status bits.
  1015.  
  1016.         Not all status change interrupts will necessarily be
  1017.         enabled on all systems.  For example, on some systems
  1018.         BVD2/DA status change interrupts will not be enabled so
  1019.         that digital audio can occur without generating many
  1020.         interrupts.  Status change interrupts are typically meant
  1021.         to be used for monitoring BSY/IRQ, WR, and BVD1/SC.  Battery
  1022.         voltage low detection would best be done by a separate
  1023.         utility which periodically polls BVD1 & BVD2 by using the
  1024.         ReadCardStatus() function.
  1025.  
  1026.         Typically the mask value in D0 MUST be returned unchanged
  1027.         on exit from your code.  The return value in D0 is then used
  1028.         to clear the source(s) of the interrupt.
  1029.  
  1030.         In the rare case that you need to keep a status change
  1031.         interrupt active, clear the appropriate bit(s) in D0 before
  1032.         returning via RTS.  Clear no bits other than those defined
  1033.         as valid bits for ReadCardStatus()!
  1034.  
  1035.     cah_CardFlags -
  1036.  
  1037.         Optional flags (all other bits must be 0).
  1038.  
  1039.         - CARDB_RESETREMOVE means you want the machine to
  1040.           reset if the credit-card in the slot is removed
  1041.           while you own the credit-card.
  1042.  
  1043.         - CARDB_IFAVAILABLE means you only want ownership of
  1044.           the credit-card in the slot if it is immediately
  1045.           available.
  1046.  
  1047.         If it is available, your CardHandle structure will be added
  1048.         to a list so that you can be notified via an interrupt when
  1049.         the credit-card is removed by the user.
  1050.  
  1051.         If the credit-card is not immediately available (either
  1052.         because there is no credit-card in the slot, or because some
  1053.         other device owns the credit-card), your CardHandle structure
  1054.         will NOT be added to the notification list.
  1055.  
  1056.         - CARDB_DELAYOWNERSHIP means you never want a successful
  1057.           return from OwnCard() even if the credit-card is
  1058.           available.  Rather you will be notified of ownership
  1059.           via your cah_CardInserted interrupt.  If you use this flag,
  1060.           OwnCard() will always return -1.  This flag cannot be used
  1061.           with the CARDB_IFAVAILABLE flag.
  1062.  
  1063.     ALL other fields are used by the resource, and no fields in the
  1064.     structure may be modified while the structure is in use by the
  1065.     resource.  If you need to make changes, you must remove your
  1066.     CardHandle (see ReleaseCard()), make the changes, and then call
  1067.     OwnCard() again.
  1068.  
  1069.    RESULTS
  1070.      0  - indicates success, your device owns the credit card.
  1071.  
  1072.     -1  - indicates that the card cannot be owned (most likely 
  1073.           because there is no card in the credit card slot).
  1074.  
  1075.     ptr - indicates failure.  Returns pointer to the CardHandle
  1076.           structure which owns the credit card.
  1077.  
  1078.    NOTES
  1079.     This function should only be called from a task.
  1080.  
  1081.       CardHandle interrupts are called with a pointer to your data
  1082.     in A1, and a pointer to your code in A5.  With the exception
  1083.     of status change interrupts, D0-D1, A0-A1, and A5-A6 may be
  1084.     treated as scratch registers.  Status change interrupts are
  1085.     also called with meaningful data in D0, and expect D0 be
  1086.     preserved upon RTS from your code.  No other registers are
  1087.     guaranteed to contain initialized data.  All other registers
  1088.     must be preserved.
  1089.  
  1090.     SEE ALSO
  1091.     ReleaseCard(), ReadCardStatus(), resources/card.i, resources/card.h
  1092.  
  1093. card.resource/ReadCardStatus                     card.resource/ReadCardStatus
  1094.  
  1095.    NAME
  1096.     ReadCardStatus -- Read credit card status register
  1097.    
  1098.    SYNOPSIS
  1099.     status=ReadCardStatus()
  1100.     d0
  1101.  
  1102.     UBYTE ReadCardStatus( void );
  1103.  
  1104.    FUNCTION
  1105.     Returns current state of the credit card status register.
  1106.  
  1107.     See card.h/i for bit definitions.
  1108.  
  1109.     Note that the meaning of the returned status bits may vary
  1110.     depending on the type of card inserted in the slot, and
  1111.     mode of operation.  Interpretation of the bits is left
  1112.     up to the application.
  1113.  
  1114.    RETURNS
  1115.     A UBYTE value to be interpreted as status bits.
  1116.  
  1117.    NOTES
  1118.     This function may be called from within a task, or from any level
  1119.     interrupt.
  1120.  
  1121.    SEE ALSO
  1122.     resources/card.h, resources/card.i
  1123.  
  1124. card.resource/ReleaseCard                           card.resource/ReleaseCard
  1125.  
  1126.    NAME
  1127.     ReleaseCard -- Release ownership of credit card
  1128.    
  1129.    SYNOPSIS
  1130.     ReleaseCard( handle, flags )
  1131.              a1         d0
  1132.  
  1133.     void ReleaseCard( struct CardHandle *, ULONG );
  1134.  
  1135.    FUNCTION
  1136.     This function releases ownership of the credit card in the
  1137.     slot.
  1138.  
  1139.     The access light (if any) is automatically turned off
  1140.     (if it was turned on) when you release ownership of
  1141.     a card you owned, and all credit-card control registers
  1142.     are reset to their default state.
  1143.  
  1144.     You must call this function if -
  1145.  
  1146.     You own the credit-card, and want to release it so that
  1147.     other devices on the notification list will have a chance
  1148.     to examine the credit-card in the card slot.
  1149.  
  1150.     You took a Card Removed interrupt while you owned the
  1151.     credit-card.  If so, you MUST call this function, else
  1152.     no other task will be notified of newly inserted cards.  On
  1153.     some machines the credit-card interface hardware may also
  1154.     be left disabled until you respond to the card removed interrupt
  1155.     by calling this function.
  1156.  
  1157.     You want to remove yourself from the notification list (see
  1158.     optional flags below).
  1159.  
  1160.    INPUTS
  1161.     handle - Same handle as that used when OwnCard() was called.
  1162.  
  1163.     flags - Optional flags.
  1164.  
  1165.         - CARDB_REMOVEHANDLE means you want remove your
  1166.         CardHandle structure from the notification list
  1167.         whether or not you currently own the credit-card
  1168.         in the card slot.  The node structure in your
  1169.         CardHandle will be removed from the notification
  1170.         list, and ownership will be released if you were
  1171.         the owner of the card.
  1172.  
  1173.    NOTES
  1174.     This function should only be called from a task.
  1175.  
  1176.     SEE ALSO
  1177.     OwnCard(), resources/card.i, resources/card.h
  1178.  
  1179.