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.

137 lines
4.2 KiB

  1. .MODEL small
  2. ;*************************************************
  3. ; Filename: hpscan16.asm
  4. ; Purpose: Stub DOS Device Driver. Pass device
  5. ; "HPSCAN" requests to the VDD, hpscan32.dll.
  6. ; Environment: MSDOS, Windows NT.
  7. ; (C) Hewlett-Packard Company 1993.
  8. ;*************************************************
  9. INCLUDE hpscan16.inc ;private
  10. INCLUDE isvbop.inc ;NT DDK
  11. SUBTTL Segment and data definitions
  12. ASSUME CS:CSEG,DS:NOTHING,ES:NOTHING
  13. CSEG SEGMENT
  14. ;-------------------------------------------------
  15. ; Resident data area - variables needed after init
  16. ;-------------------------------------------------
  17. ;**--- Device Header, must be at offset zero ---**
  18. SCAN_HEADER:
  19. dd -1 ;becomes ptr to next req hdr
  20. dw 0C000H ;character, supports IOCTL
  21. dw offset STRAT ;Strategy routine
  22. dw offset IDVR ;Interrupt routine
  23. DH_NAME db 'HPSCAN ' ;char device name
  24. ;**---- Request Header addr, saved by STRAT ----**
  25. RH_PTRA LABEL DWORD
  26. RH_PTRO dw ? ;offset
  27. RH_PTRS dw ? ;segment
  28. ;**------------- Define Stack Space ------------**
  29. STK_SEG dw ? ;Save original stack segment
  30. STK_PTR dw ? ;Save original stack pointer
  31. STACK dw 200 DUP (0) ;Local stack
  32. TOP_STK dw ? ;Top of local stack
  33. ;**--------------- VDD information -------------**
  34. VDD_DllName db "HPSCAN32.DLL", 0
  35. VDD_InitFunc db "VDDInit", 0
  36. VDD_DispFunc db "VDDDispatch", 0
  37. VDD_hVDD dw ?
  38. ;**-------------- Copyright Info ---------------**
  39. db '(C) Copyright Hewlett-Packard Company 1993.'
  40. db 'All rights reserved.'
  41. SUBTTL Device Strategy & Interrupt entry points
  42. ;**--------------- STRAT routine ---------------**
  43. STRAT proc far ;Strategy routine
  44. mov cs:RH_PTRO,bx ;save offset address
  45. mov cs:RH_PTRS,es ;save segment address
  46. ret ;end Strategy routine
  47. STRAT endp
  48. ;**--------------- IDVR routine ---------------**
  49. IDVR proc far ;Interrupt routine
  50. push ds ;save all modified registers
  51. push es ;DOS has stack for 20 pushes
  52. push ax
  53. push bx
  54. push cx
  55. push dx
  56. push di
  57. push si
  58. push bp
  59. mov cs:STK_PTR,sp ;save original stack ptr
  60. mov cs:STK_SEG,ss ;save original stack seg
  61. cli ;disable for stack ops
  62. mov ax,cs ;setup new stack ptr
  63. mov ss,ax ;setup new stack seg
  64. mov sp,offset TOP_STK
  65. sti ;restore flags back
  66. cld ;all moves are forward
  67. les bx,cs:RH_PTRA ;load req hdr adr in es:bx
  68. mov al,RH.RHC_CMD
  69. cmp al,0 ;check for init command
  70. je BOOTUP ;command 0 = init
  71. xor dx,dx ;some other command
  72. mov dl,RH.RHC_CMD ;dx = command code
  73. mov cx,RH.RHC_CNT ;cx = count
  74. mov ax,RH.RHC_SEG ;es:bx = addr of data
  75. mov bx,RH.RHC_OFF
  76. mov es,ax ;finally, load VDD handle
  77. mov ax,word ptr cs:[VDD_hVDD]
  78. DispatchCall ;call Dispatch in VDD
  79. ;returns with status in di
  80. EXIT:
  81. les bx,cs:RH_PTRA ;restore ES:BX
  82. or di,STAT_DONE ;add "DONE" bit to status
  83. mov RH.RHC_STA,di ;save status in requ hdr
  84. cli ;disable ints for stack op
  85. mov ss,cs:STK_SEG ;restore stack seg
  86. mov sp,cs:STK_PTR ;restore stack ptr
  87. sti ;re-enable interrupts
  88. pop bp ;restore registers
  89. pop si
  90. pop di
  91. pop dx
  92. pop cx
  93. pop bx
  94. pop ax
  95. pop es
  96. pop ds
  97. ret ;far return
  98. IDVR endp
  99. ;**--------- jump here for Init Command --------**
  100. BOOTUP:
  101. mov ax,offset EndDriver
  102. mov RH.RHC_OFF,ax ;address of end of driver
  103. mov RH.RHC_SEG,CS ;reference from code seg
  104. mov si,offset VDD_DllName ;load regs for VDD
  105. mov di,offset VDD_InitFunc
  106. mov bx,offset VDD_DispFunc
  107. mov ax,ds
  108. mov es,ax
  109. RegisterModule ;calls the VDD
  110. jnc save_hVDD ;if NC then success
  111. mov di,STAT_GF ;set failure status
  112. jmp EXIT ;return via common exit
  113. save_hVDD:
  114. mov [VDD_hVDD],ax ;save handle in ax
  115. mov di,STAT_OK ;load OK status
  116. jmp EXIT ;return via common exit
  117. EndDriver db ?
  118. CSEG ENDS
  119. END SCAN_HEADER ;REQUIRED BY EXE2BIN
  120.