DMAINIT(10.2)                 (x86)                 DMAINIT(10.2)

     NAME
          dmainit, dmasetup, dmadone, dmaend, dmacount - platform-
          specific DMA support

     SYNOPSIS
          void   dmainit(int chan)

          long   dmasetup(int chan, void *va, long len, int isread)

          int    dmadone(int chan)

          void   dmaend(int chan)

          int    dmacount(int chan)

     DESCRIPTION
          These functions manage DMA on a bus that uses ISA-style DMA
          controllers.  They were originally devised for the x86 plat-
          form, but the same interface, and similar code, is used by
          other platforms that use similar controllers.  They compen-
          sate as best they can for the limitations of older DMA
          implementations (eg, alignment, boundary and length restric-
          tions).  There are 8 DMA channels: 0 to 3 are byte-oriented;
          4 to 7 are word-oriented (16-bit words).

          Dmainit must be called early in a driver's initialisation to
          prepare chan for use.  Amongst other things, it allocates a
          page-sized buffer to help circumvent hardware restrictions
          on DMA addressing.

          Dmasetup prepares DMA channel chan for a transfer between a
          device configured to use it and the virtual address va. (The
          transfer is started by issuing a command to the device.)  If
          va lies outside the kernel address space, the transfer
          crosses a 64k boundary, or exceeds the 16 Mbyte limit
          imposed by some DMA controllers, the transfer will be split
          into page-sized transfers using the buffer previously allo-
          cated by dmainit. If isread is true (non-zero), data is to
          be transferred from chan to va; if false, data is trans-
          ferred from va to chan. In all cases, dmasetup returns the
          number of bytes to be transferred.  That value (rather than
          len) must be given to the device in the read or write
          request that starts the transfer.

          Dmadone returns true (non-zero) if chan is idle.

          Dmaend must be called at the end of every DMA operation.  It
          disables chan, preventing further access to the previously
          associated memory and, if a low-memory buffer was required
          for input, transfers its contents to the appropriate part of

     DMAINIT(10.2)                 (x86)                 DMAINIT(10.2)

          the target buffer.

          Dmacount returns the number of bytes that were last trans-
          ferred by channel chan. The count is always even for word-
          oriented DMA channels.

     SOURCE
          /os/pc/dma.c