home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 26 / CD_ASCQ_26_1295.iso / voxrom / textes / repwin08 / annexes / triax / dma.pas next >
Pascal/Delphi Source File  |  1995-10-01  |  2KB  |  82 lines

  1. {▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓}
  2. { DMA - Unité gestion DMA }
  3. {▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓}
  4. Unit DMA;
  5.  
  6. INTERFACE {--Globals--------------------------------------------------------}
  7.  
  8. Const
  9.    DMARead      = $44;  {Mode transfert lecture}
  10.    DMAWrite     = $48;  {Mode transfert écriture}
  11.  
  12. Procedure DMAInit(Channel:BYTE;Mode:BYTE;Count:WORD;Address:POINTER);
  13.  
  14. IMPLEMENTATION {--Locals----------------------------------------------------}
  15.  
  16. Const
  17.    DMAMask      : array[0..7] of byte = ($0A,$0A,$0A,$0A,$D4,$D4,$D4,$D4);
  18.    DMAMode      : array[0..7] of byte = ($0B,$0B,$0B,$0B,$D6,$D6,$D6,$D6);
  19.    DMAFlipFlop  : array[0..7] of byte = ($0C,$0C,$0C,$0C,$D8,$D8,$D8,$D8);
  20.    DMACount     : array[0..7] of byte = ($01,$03,$05,$07,$C2,$C6,$CA,$CE);
  21.    DMAAddress   : array[0..7] of byte = ($00,$02,$04,$06,$C0,$C4,$C8,$CC);
  22.    DMAPage      : array[0..7] of byte = ($87,$83,$81,$82,$8F,$8B,$89,$8A);
  23.  
  24. Procedure DMAInit(Channel:BYTE;Mode:BYTE;Count:WORD;Address:POINTER); assembler;
  25. Asm
  26.         xor     dx,dx
  27.         xor     bx,bx
  28.         mov     bl,Channel
  29.  
  30.       {░░ Disable canal DMA ░░}
  31.         mov     dl,[offset DMAMask+bx]
  32.         mov     al,bl
  33.         and     al,00000011b
  34.         or      al,00000100b
  35.         out     dx,al
  36.  
  37.       {░░ Remet Flip-Flop à 0 ░░}
  38.         mov     dl,[offset DMAFlipFlop+bx]
  39.         xor     al,al
  40.         out     dx,al
  41.  
  42.       {░░ Sélectionne le mode de transfert ░░}
  43.         mov     dl,[offset DMAMode+bx]
  44.         mov     al,bl
  45.         and     al,00000011b
  46.         or      al,Mode
  47.         out     dx,al
  48.  
  49.       {░░ Envoie la taille du bloc à transférer ░░}
  50.         mov     dl,[offset DMACount+bx]
  51.         mov     ax,Count
  52.         out     dx,al
  53.         mov     al,ah
  54.         out     dx,al
  55.  
  56.       {░░ Envoie l'adresse et la page du bloc ░░}
  57.         mov     cl,4
  58.         mov     ax,word ptr [Address+2]
  59.         mov     ch,ah
  60.         shr     ch,cl
  61.         shl     ax,cl
  62.         add     ax,word ptr [Address]
  63.         adc     ch,0
  64.  
  65.         {To the dma...}
  66.         mov     dl,[offset DMAAddress+bx]
  67.         out     dx,al
  68.         mov     al,ah
  69.         out     dx,al
  70.         mov     dl,[offset DMAPage+bx]
  71.         mov     al,ch
  72.         out     dx,al
  73.  
  74.       {░░ Enable canal DMA ░░}
  75.         mov     dl,[offset DMAMask+bx]
  76.         mov     al,bl
  77.         and     al,00000011b
  78.         out     dx,al
  79. End;
  80.  
  81. End.
  82.