dmainit 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. .TH DMAINIT 9
  2. .SH NAME
  3. dmainit, dmasetup, dmadone, dmaend, dmacount \- platform-specific DMA support
  4. .SH SYNOPSIS
  5. .ta \w'\fLushort 'u
  6. .B
  7. void dmainit(int chan)
  8. .PP
  9. .B
  10. long dmasetup(int chan, void *va, long len, int isread)
  11. .PP
  12. .B
  13. int dmadone(int chan)
  14. .PP
  15. .B
  16. void dmaend(int chan)
  17. .PP
  18. .B
  19. int dmacount(int chan)
  20. .PP
  21. .SH DESCRIPTION
  22. These functions manage DMA on a bus that uses ISA-style DMA controllers.
  23. They were originally devised for the x86 platform, but the same interface, and similar code,
  24. is used by other platforms that use similar controllers.
  25. They compensate as best they can for the limitations of older DMA implementations
  26. (eg, alignment, boundary and length restrictions).
  27. There are 8 DMA channels:
  28. 0 to 3 are byte-oriented; 4 to 7 are word-oriented (16-bit words).
  29. .PP
  30. .I Dmainit
  31. must be called early in a driver's initialisation to prepare
  32. .I chan
  33. for use.
  34. Amongst other things, it allocates a page-sized buffer to help circumvent hardware
  35. restrictions on DMA addressing.
  36. .PP
  37. .I Dmasetup
  38. prepares DMA channel
  39. .IR chan
  40. for a transfer between a device configured to use it
  41. and the virtual address
  42. .IR va .
  43. (The transfer is started by issuing a command to the device.)
  44. If
  45. .I va
  46. lies outside the kernel address space,
  47. the transfer crosses a 64k boundary,
  48. or exceeds the 16 Mbyte limit imposed by some DMA controllers,
  49. the transfer will be split into page-sized transfers using the buffer previously allocated by
  50. .IR dmainit .
  51. If
  52. .I isread
  53. is true (non-zero), data is to be transferred from
  54. .I chan
  55. to
  56. .IR va ;
  57. if false, data is transferred from
  58. .I va
  59. to
  60. .IR chan .
  61. In all cases,
  62. .I dmasetup
  63. returns the number of bytes to be transferred.
  64. That value (rather than
  65. .IR len )
  66. must be given to the device in the read or write request that starts the transfer.
  67. .PP
  68. .I Dmadone
  69. returns true (non-zero) if
  70. .I chan
  71. is idle.
  72. .PP
  73. .I Dmaend
  74. must be called at the end of every DMA operation.
  75. It disables
  76. .IR chan ,
  77. preventing further access to the previously associated memory and,
  78. if a low-memory buffer was required for input, transfers its contents
  79. to the appropriate part of the target buffer.
  80. .PP
  81. .I Dmacount
  82. returns the number of bytes that were last transferred by channel
  83. .IR chan .
  84. The count is always even for word-oriented DMA channels.
  85. .SH SOURCE
  86. .B /sys/src/9/pc/dma.c