home *** CD-ROM | disk | FTP | other *** search
/ ProfitPress Mega CDROM2 …eeware (MSDOS)(1992)(Eng) / ProfitPress-MegaCDROM2.B6I / MISC / NETWORK / PCBRI120.ZIP / MEMORY.INC < prev    next >
Encoding:
Text File  |  1991-02-19  |  6.0 KB  |  174 lines

  1. ;;******************************************************************************
  2. ;;                         memory.inc      memory.inc
  3. ;;******************************************************************************
  4. ;;
  5. ;;  Copyright (C) 1990 Vance Morrison
  6. ;;
  7. ;;
  8. ;; Permission to view, compile, and modify for LOCAL (intra-organization) 
  9. ;; USE ONLY is hereby granted, provided that this copyright and permission 
  10. ;; notice appear on all copies.  Any other use by permission only.
  11. ;;
  12. ;; Vance Morrison makes no representations about the suitability 
  13. ;; of this software for any purpose.  It is provided "as is" without expressed 
  14. ;; or implied warranty.  See the copywrite notice file for complete details.
  15. ;;
  16. ;;******************************************************************************
  17. ;; 
  18. ;; In order to do fast 16 bit transfers between cards with shared memory
  19. ;; we need to tell each card that it can use all 16 bits.  Unforunately,
  20. ;; we can't leave this on all the time (because this bit is shared among
  21. ;; hardward that may want it unasserted).  Thus before each transfer, the
  22. ;; source and destination card need to be places in 16 bit mode.
  23. ;;
  24. ;; Because in PCroute determining the destination card is difficult, and
  25. ;; since it is unlikely that there will be configurations with a mix
  26. ;; of 8 and 16 bit shared memory cards, we take a simplified view.  
  27. ;; Namely if any 8 bit shared memory boards exist, everyone does 8 bit
  28. ;; transfers all the time.  If all boards are 16 bit, then before any copy, 
  29. ;; all cards are placed in 16 bit mode.   ZZ
  30.  
  31. ;; of networking cards is not transparent (at least not with the WD8013EBT).
  32. ;; because of this, we need to toggle 16bit mode when it is necessary
  33. ;; (it is also necessary to do this with interupts disabled, which also
  34. ;; requires special processing).  memory.inc provides functions that allow
  35. ;; this toggling to be done automatically.  
  36. ;;
  37. ;;******************************************************************************
  38. ;;
  39. ;; functions provided by this module are
  40. ;;
  41. ;;   MEM_DECLARE_16BIT on_macro, off_macro
  42. ;;   MEM_DECLARE_8BIT 
  43. ;;   MEM_DECLARE_NEED_INTS lantency 
  44. ;;   MEM_COPY_in_CX_SI_DI_ES_out_SI_DI_const_AX_BX_DX_BP_ES  
  45. ;;
  46. ;;******************************************************************************
  47.  
  48. mem_num_16bit = 0
  49. mem_num_8bit = 0
  50. mem_min_latency = -1
  51.  
  52.  
  53. ;;******************************************************************************
  54. ;;  MEM_DECLARE_16BIT declares the fact that a 16 bit shared memory card 
  55. ;;  exists in the system.  'on_macro' turns 16 bit mode on for that card`
  56. ;;  'off_macro' turns it off.  Interfaces that use main memory for buffering
  57. ;;  need not be declared.  Note that on and off macros CAN ONLY MODIFY
  58. ;;  THE AX AND DX REGISTERS
  59.     
  60. MEM_DECLARE_16BIT MACRO on_macro, off_macro
  61.  
  62.     mem_num_16bit = mem_num_16bit + 1
  63.  
  64.     HELPER MACRO num
  65.         mem_16bit_&&num&&_on  equ <on_macro>
  66.         mem_16bit_&&num&&_off equ <off_macro>
  67.     ENDM
  68.  
  69.     HELPER %mem_num_16bit
  70. ENDM
  71.  
  72.  
  73. ;;******************************************************************************
  74. ;; MEM_DECLARE_NEED_INTS declares the fact that there is an interface
  75. ;; that uses interupts that need to be serviced quickly, so interupts 
  76. ;; cannot remain disabled for long times.  'lantency' is the worst case
  77. ;; latency required measured in usec.  For example a SLIP line at 19.2K
  78. ;; baud requires that interupts be serviced in 500 us.
  79. ;; 
  80.     
  81. MEM_DECLARE_NEED_INTS MACRO latency
  82.     if mem_min_latency gt latency       ;; take the minimum
  83.         mem_min_latency = latency
  84.     endif
  85. ENDM
  86.  
  87.  
  88. ;;******************************************************************************
  89. ;;  MEM_DECLARE_8BIT declares the fact that a 8 bit shared memory card 
  90. ;;  exists in the system.   In this implementation, this means don't ever
  91. ;;  use 16 bit mode at all.
  92.     
  93. MEM_DECLARE_8BIT MACRO 
  94.     mem_num_8bit = 1
  95. ENDM
  96.  
  97.  
  98. ;;******************************************************************************
  99. ;; MEM_COPY_in_CX_SI_DI_ES_out_SI_DI does the copy operation.  It requires
  100. ;; that SI and DI are EVEN.   This function is esentially a 'rep movsw'
  101. ;; with added functionality that enables 16bit bus transfers if possible.
  102. ;;
  103.  
  104. MEM_COPY_in_CX_SI_DI_ES_out_SI_DI_const_AX_BX_DX_BP_ES MACRO 
  105.     local copy_loop, done
  106.  
  107.     inc CX          
  108.     shr CX, 1
  109.     if (mem_num_8bit eq 0) and (mem_num_16bit gt 0)
  110.         push AX
  111.         push DX
  112.         if mem_min_latency lt 0
  113.             cli
  114.             MEM_ALL_16BIT_ON_const_BX_CX_BP_SI_DI_ES 
  115.             rep 
  116.             movsw
  117.             MEM_ALL_16BIT_OFF_const_BX_CX_BP_SI_DI_ES 
  118.             sti
  119.         else
  120.                 ;; really should copy in pieces, but I don't have
  121.                 ;; the time to code it.  for now we just give up 
  122.                 ;; on 16 bit access
  123.             rep
  124.             movsw
  125.         endif
  126.         pop DX
  127.         pop AX
  128.     else
  129.         rep 
  130.         movsw
  131.     endif
  132. ENDM
  133.  
  134.  
  135. ;;****************************************************************************
  136. ;; These macros call the stored on_macro and off_macro respectively
  137.  
  138. MEM_ALL_16BIT_ON_const_BX_CX_BP_SI_DI_ES MACRO
  139.     irp idx,<1,2,3,4,5,6,7,8>
  140.     if idx le mem_num_16bit
  141.         MEM_16BIT_ON_const_BX_CX_BP_SI_DI_ES idx
  142.     endif
  143.     endm
  144. ENDM
  145.  
  146. ;;****************************************************************************
  147.  
  148. MEM_ALL_16BIT_OFF_const_BX_CX_BP_SI_DI_ES MACRO
  149.     irp idx,<1,2,3,4,5,6,7,8>
  150.     if idx le mem_num_16bit
  151.         MEM_16BIT_OFF_const_BX_CX_BP_SI_DI_ES idx
  152.     endif
  153.     endm
  154. ENDM
  155.  
  156. ;;****************************************************************************
  157. MEM_16BIT_ON_const_BX_CX_BP_SI_DI_ES MACRO num
  158.     HELPER MACRO name
  159.         name
  160.     ENDM
  161.  
  162.     HELPER %mem_16bit_&num&_on
  163. ENDM
  164.  
  165. ;;****************************************************************************
  166. MEM_16BIT_OFF_const_BX_CX_BP_SI_DI_ES MACRO num
  167.     HELPER MACRO name
  168.         name
  169.     ENDM
  170.  
  171.     HELPER %mem_16bit_&num&_off
  172. ENDM
  173.  
  174.