home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.2 (Developer) / NS_dev_3.2.iso / NextDeveloper / Headers / driverkit / i386 / directDevice.h next >
Text File  |  1993-08-06  |  7KB  |  229 lines

  1. /*
  2.  * Copyright (c) 1993 NeXT Computer, Inc.
  3.  *
  4.  * ISA/EISA direct device interface.
  5.  *
  6.  * HISTORY
  7.  *
  8.  * 10Jan93 Brian Pinkerton at NeXT
  9.  *    Created.
  10.  *
  11.  */
  12. #import <driverkit/IODevice.h>
  13. #import <driverkit/IODirectDevice.h>
  14. #import <driverkit/IODeviceDescription.h>
  15. #import <driverkit/i386/IOEISADeviceDescription.h>
  16. #import <driverkit/i386/driverTypes.h>
  17.  
  18.  
  19. void IOSendInterrupt(void *identity, void *state, unsigned int msgId);
  20.  
  21. @interface IODirectDevice(IOEISADirectDevice)
  22.  
  23. /*
  24.  *  Initialization and free.  Call the initFromDeviceDescription with a
  25.  *  description of type ATDeviceDescription (it's typed as IODevDesc to
  26.  *  avoid bogus compiler warnings!)
  27.  */
  28. - (IODirectDevice *) initFromDeviceDescription:(IODeviceDescription *) devDesc;
  29. - free;
  30.  
  31. /*
  32.  *  Dealing with interrupts.
  33.  */
  34. - (IOReturn) enableAllInterrupts;
  35. - (void) disableAllInterrupts;
  36.  
  37. - (IOReturn) enableInterrupt    : (unsigned int) localInterrupt;
  38. - (void) disableInterrupt    : (unsigned int) localInterrupt;
  39.  
  40. /*
  41.  *  Implement this methods to provide your own function as the handler for a
  42.  *  particular local interrupt, and to specify a level for that handler to run
  43.  *  at.  You can also specify an argument that get's passed to your handler.
  44.  *  This method will be called once before an interrupt is enabled.
  45.  *
  46.  *  This method returns NO by default.
  47.  */
  48. - (BOOL) getHandler        : (IOEISAInterruptHandler *)handler
  49.                         level : (unsigned int *)ipl
  50.                  argument : (unsigned int *) arg
  51.                   forInterrupt : (unsigned int) localInterrupt;
  52.  
  53. /*
  54.  * Determine whether localChannel's DMA is complete.
  55.  */
  56. - (BOOL) isDMADone:(unsigned int) localChannel;
  57.  
  58. /*
  59.  *  Methods to map device memory into the calling task's address space.
  60.  */
  61. - (IOReturn) mapMemoryRange    : (unsigned int) localRange
  62.                  to : (vm_address_t *) destAddr
  63.               findSpace : (BOOL) findSpace
  64.               cache : (IOCache) cache;
  65.  
  66. - (void) unmapMemoryRange     : (unsigned int) localRange
  67.                from : (vm_address_t) virtAddr;
  68.  
  69. /*
  70.  *  Methods to reserve and enable DMA channels.  Also, methods to obtain
  71.  *  buffers for DMA, and do DMA using those buffers.
  72.  */
  73. - (IOReturn) enableChannel    : (unsigned int) localChannel;
  74. - (void) disableChannel        : (unsigned int) localChannel;
  75.  
  76. /*
  77.  * Specify basic DMA transfer mode.
  78.  */
  79. typedef enum {
  80.     IO_Demand,
  81.     IO_Single,
  82.     IO_Block,
  83.     IO_Cascade,
  84. } IODMATransferMode;
  85.  
  86. - (IOReturn) setTransferMode    : (IODMATransferMode) mode 
  87.              forChannel : (unsigned int) localChannel;
  88.  
  89. /*
  90.  * Enable/disable autoinitialize DMA mode. Default is 
  91.  * disabled.
  92.  */
  93. - (IOReturn)setAutoinitialize      : (BOOL)flag
  94.                     forChannel     : (unsigned)localChannel;
  95.  
  96. /*
  97.  * Set DMA address increment/decrement mode.
  98.  * Default is IO_Increment.
  99.  */
  100. typedef enum {
  101.     IO_Increment,
  102.     IO_Decrement,
  103. } IOIncrementMode;
  104.  
  105. - (IOReturn)setIncrementMode       : (IOIncrementMode)mode
  106.                     forChannel     : (unsigned)localChannel;
  107.  
  108. /*
  109.  *  Returns a DMA buffer for the contents of physical memory starting at
  110.  *  addr and continuing for length bytes.  If the physical address changed
  111.  *  to accommodate the ISA bus, the new physical address is returned in
  112.  *  place.  The IOEISADMABuffer is an opaque type.
  113.  */
  114. - (IOEISADMABuffer) createDMABufferFor:(unsigned int *) physAddr
  115.              length    : (unsigned int) length
  116.                read : (BOOL) isRead
  117.          needsLowMemory : (BOOL) lowerMem
  118.               limitSize : (BOOL) limitSize;
  119.  
  120. /*
  121.  *  Complete DMA on, and free, the given DMABuffer.  If the DMA was a read,
  122.  *  and the buffer relocated the original physical memory, then the relocated
  123.  *  memory is copied to the source in this step.
  124.  */
  125. - (void) freeDMABuffer        : (IOEISADMABuffer) buffer;
  126.  
  127. /*
  128.  *  Like -freeDMABuffer, except it doesn't copy the memory.
  129.  */
  130. - (void) abortDMABuffer        : (IOEISADMABuffer) buffer;
  131.  
  132. /*
  133.  *  Perform host-master DMA using the given DMABuffer on the given DMA channel.
  134.  */
  135. - (IOReturn) startDMAForBuffer    : (IOEISADMABuffer) buffer
  136.             channel : (unsigned int) localChannel;
  137.  
  138. /*
  139.  * Return localChannel's current address and count.
  140.  */
  141. - (unsigned)currentAddressForChannel : (unsigned)localChannel; 
  142. - (unsigned)currentCountForChannel   : (unsigned)localChannel;
  143.  
  144. /*
  145.  *  Methods to reserve resources.  You don't normally need to call these, as
  146.  *  they're called automatically when IOEISADirectDevice is initialized with
  147.  *  the -initFromDeviceDescription method.
  148.  */
  149. - (IOReturn) reservePortRange    : (unsigned int) localPortRange;
  150. - (void) releasePortRange    : (unsigned int) localPortRange;
  151.  
  152. - (IOReturn) reserveInterrupt    : (unsigned int)localInterrupt;
  153. - (void) releaseInterrupt    : (unsigned int) localInterrupt;
  154.  
  155. - (IOReturn) reserveChannel    : (unsigned int) localChannel;
  156. - (void) releaseChannel        : (unsigned int) localChannel;
  157.  
  158. /*
  159.  * Reserve and release exclusive DMA lock. Use is optional; provides
  160.  * exclusion between mutually incompatible DMA devices.
  161.  */
  162. - (void)reserveDMALock;
  163. - (void)releaseDMALock;
  164.  
  165. /*
  166.  * Determine whether or not the associated device is connected to an EISA 
  167.  * bus. Returns YES if so, else returns NO.
  168.  */
  169. - (BOOL)isEISAPresent;
  170.  
  171. /*
  172.  * Get the EISA id for the specified slot.
  173.  * Returns YES if slot is valid, else returns NO.
  174.  */
  175. - (BOOL)getEISAId: (unsigned int *) _id  forSlot: (int) slot;
  176.  
  177. /*
  178.  * Support for the extended mode register (EISA only).
  179.  */
  180.  
  181. /*
  182.  * Select transfer width. Default is IO_8Bit.
  183.  */
  184. typedef enum {
  185.     IO_8Bit,            // 8  bit I/O, count by bytes
  186.     IO_16BitWordCount,        // 16 bit I/O, count by words
  187.                     //   (not currently supported)
  188.     IO_16BitByteCount,        // 16 bit I/O, count by bytes
  189.     IO_32Bit,            // 32 bit I/O, count by bytes
  190. } IOEISADMATransferWidth;
  191.  
  192.  
  193. - (IOReturn)setDMATransferWidth    : (IOEISADMATransferWidth)width
  194.                      forChannel : (unsigned)localChannel;
  195. - (IOReturn)getDMATransferWidth    : (IOEISADMATransferWidth *)width_p
  196.                      forChannel : (unsigned)localChannel;
  197.  
  198. /*
  199.  * Select DMA Timing. Default is IO_Compatible. 
  200.  */
  201. typedef enum {
  202.     IO_Compatible,    
  203.     IO_TypeA,
  204.     IO_TypeB,
  205.     IO_Burst,    
  206. } IOEISADMATiming;
  207.  
  208. - (IOReturn)setDMATiming    : (IOEISADMATiming)timing
  209.                      forChannel : (unsigned)localChannel;
  210.  
  211. /*
  212.  * Select whether EOP pin is output (default) or input.
  213.  */
  214. - (IOReturn)setEOPAsOutput    : (BOOL)flag
  215.                      forChannel    : (unsigned)localChannel;
  216.  
  217. /*
  218.  * Enable Stop register. Default is disabled.
  219.  */
  220. typedef enum {
  221.     IO_StopRegisterEnable,
  222.     IO_StopRegisterDisable,
  223. } IOEISAStopRegisterMode;
  224.  
  225. - (IOReturn)setStopRegisterMode : (IOEISAStopRegisterMode)mode
  226.                     forChannel     : (unsigned)localChannel;
  227.  
  228. @end
  229.