Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

162 lines
3.2 KiB

  1. title "Parallel Write Loop"
  2. ;++
  3. ;
  4. ;Copyright (c) 1994 Microsoft Corporation
  5. ;
  6. ;Module Name:
  7. ;
  8. ; parloop.c
  9. ;
  10. ;Abstract:
  11. ;
  12. ; This module contains the i386 version of the
  13. ; write loop for the parallel driver.
  14. ;
  15. ;Author:
  16. ;
  17. ; Norbert P. Kusters 9-Mar-1994
  18. ;
  19. ;Environment:
  20. ;
  21. ; Kernel mode
  22. ;
  23. ;Notes:
  24. ;
  25. ; This module makes use of the IN and OUT commands. Making
  26. ; use of these commands is generally not portable and so using
  27. ; IN and OUT should only be used when performance is critical.
  28. ;
  29. ;Revision History :
  30. ;
  31. ;--
  32. .386p
  33. .xlist
  34. include callconv.inc
  35. .list
  36. ;
  37. ; Parallel control register definitions.
  38. ;
  39. L_NORMAL equ 0CCH
  40. L_STROBE equ 0CDH
  41. ;
  42. ; Parallel status "ok to send" definition.
  43. ;
  44. L_INVERT equ 098H
  45. L_NOT_READY equ 0B8H
  46. _TEXT SEGMENT DWORD PUBLIC 'CODE'
  47. ASSUME DS:FLAT, ES:FLAT, SS:NOTHING, FS:NOTHING, GS:NOTHING
  48. ;++
  49. ;
  50. ;Routine Description:
  51. ;
  52. ; This routine outputs the given write buffer to the parallel port
  53. ; using the standard centronics protocol.
  54. ;
  55. ;Arguments:
  56. ;
  57. ; Controller - Supplies the base address of the parallel port.
  58. ;
  59. ; WriteBuffer - Supplies the buffer to write to the port.
  60. ;
  61. ; NumBytesToWrite - Supplies the number of bytes to write out to the port.
  62. ;
  63. ;Return Value:
  64. ;
  65. ; The number of bytes successfully written out to the parallel port.
  66. ;
  67. ;Notes:
  68. ;
  69. ; This routine runs at DISPATCH_LEVEL.
  70. ;
  71. ;--
  72. Controller equ [esp + 8]
  73. WriteBuffer equ [esp + 12]
  74. NumBytesToWrite equ [esp + 16]
  75. cPublicProc _ParWriteLoop, 3
  76. cPublicFpo 3, 1
  77. push ebx
  78. mov edx,Controller ; Set up DX for OUT
  79. mov ecx,NumBytesToWrite ; Set up CX for LOOP
  80. mov ebx,WriteBuffer ; Start of write buffer
  81. inc edx ; Point to status register
  82. align 4
  83. @@:
  84. ; Get the status lines, read until two sucessive reads are the same.
  85. in al,dx
  86. mov ah,al
  87. in al,dx
  88. cmp al,ah
  89. jnz @b
  90. ; Check the status lines.
  91. xor al,L_INVERT
  92. and al,L_NOT_READY
  93. jnz short @f ; If the printer isn't ready then abort
  94. ; Output a character to the printer
  95. mov al,[ebx]
  96. dec edx ; Point to data register
  97. inc ebx
  98. out dx,al ; Set data lines
  99. add edx,2 ; Point to control register
  100. mov al,L_STROBE
  101. out dx,al ; Turn strobe on
  102. mov al,L_NORMAL
  103. jmp $+2
  104. jmp $+2
  105. jmp $+2
  106. jmp $+2
  107. out dx,al ; Turn strobe off
  108. dec edx ; Point to status register
  109. dec ecx
  110. jmp $+2
  111. jmp $+2
  112. jmp $+2
  113. jmp $+2
  114. jmp $+2
  115. jmp $+2
  116. jmp $+2
  117. jmp $+2
  118. jmp $+2
  119. jmp $+2
  120. jmp $+2
  121. jmp $+2
  122. jmp $+2
  123. jmp $+2
  124. jmp $+2
  125. jnz short @b ; Continue until ECX = 0
  126. @@:
  127. ; return the number of bytes output in EAX
  128. mov eax,NumBytesToWrite ; Put 'NumBytesToWrite' in EAX
  129. sub eax,ecx ; Subtract the number of bytes not written
  130. pop ebx
  131. stdRET _ParWriteLoop
  132. stdENDP _ParWriteLoop
  133. _TEXT ends
  134. end