home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 8 Other / 08-Other.zip / PCTJOS2.ZIP / OS2NLOK.ASM < prev   
Assembly Source File  |  1988-09-16  |  6KB  |  157 lines

  1. ;********************************************************************
  2. ;
  3. ; os2nlok - OS/2 Device driver to turn off NumLock state of keyboard.
  4. ;          Performs its function at initialization, does not
  5. ;          install itself.
  6. ;
  7. ; Copyright (c) 1988 PC Tech Journal and Ziff Communications Co.
  8. ;
  9. ;                   Written by Ted Mirecki
  10. ;
  11. ;********************************************************************
  12.  
  13.            .286                   ;enables 'push immediate' instr.
  14.  
  15. ;********************************************************************
  16. ; Declarations:  OS/2 API functions;
  17. ;                Device driver request packet:
  18. ;                    - standard request header 
  19. ;                    - header extension specific to init request
  20. ;                Bimodal address of request packet is in ES:BX
  21. ;                at entry to strategy routine.  
  22. ;********************************************************************
  23.  
  24.            extrn   DosPutMessage:Far
  25.            extrn   DosDevIOCTL:Far
  26.            extrn   DosOpen:Far
  27.            extrn   DosClose:Far
  28.  
  29. devpacket  struc                  ;Device driver request packet
  30. req_len    db      ?              ;standard request packet header
  31. req_unit   db      ?
  32. req_comm   db      ?
  33. req_status dw      ?
  34. req_res    dd      ?
  35. req_queue  dd      ?
  36.                                   ;rest of packet for init request:
  37. init_data1 db      ?              ;block count (zero for char device)
  38. init_ecode dw      ?              ;resident segment lengths
  39. init_edata dw      ?
  40. init_ptr2  dd      ?              ;unused by char device
  41. devpacket  ends
  42.  
  43. ;********************************************************************
  44. ; DATA segment:  begin w/device header, follow w/local data
  45. ; Use explicit segment declarations, not simplified ones,
  46. ;    to ensure proper segment order (data segment first).
  47. ;********************************************************************
  48.  
  49. data       segment
  50.            assume ds:data
  51.                                   ;DEVICE DRIVER HEADER:
  52. devhdr     dd      -1             ;device header linkage
  53. devattr    dw      8080h          ;bit 15 = char device,
  54.                                   ;bit  7 = OS/2 driver
  55. deventry   dw      offset strategy     ;offset in code segment
  56.            dw      ?              ;reserved
  57. devname    db      'OS2NLOK '     ;device name, must be 8 chars
  58.            db      8 dup (?)      ;reserved
  59.                                   ;end of header
  60. CR         equ     0Dh
  61. LF         equ     0Ah
  62. RESET      equ     not 20h        ;reset num lock bit
  63.  
  64. signon     db      CR, LF, 'Numeric Unlock, OS/2 version', CR, LF
  65.            db      '  Copyright (c) 1988 PC Tech Journal and'
  66.            db      ' Ziff Communications Co.', CR, LF
  67.            db      '  Written by Ted Mirecki', CR, LF, LF
  68. lenmsg     equ     $-signon
  69.                                   ;data for open call
  70. kbd        db      'KBD$', 0
  71. handle     dw      ?
  72. action     dw      ?
  73.                                   ;data area for IOCTL calls
  74. shift      dw      ?              ;word for shift flags
  75. nls        db      ?              ;byte for NLS shift status
  76.  
  77. data       ends
  78.  
  79. ;********************************************************************
  80. ; CODE segment: strategy routine, performs initialization only.
  81. ; Processing: 1. Display message
  82. ;             2. Open KBD$ device
  83. ;             3. Get shift state w/IOCTL call
  84. ;             4. Change NumLock, call IOCTL to set shift state
  85. ;             5. Close KBD$ device
  86. ;             6. Return to kernel without installing.  
  87. ;********************************************************************
  88.  
  89. code       segment 'code'
  90.            assume  cs:code
  91. strategy   proc    far
  92.  
  93. ; 1. call DosPutMessage(0, lenmsg, @signon)           
  94.            push    1              ;handle 1 = std output
  95.            push    lenmsg
  96.            push    ds             ;far address of message
  97.            push    offset signon
  98.            call    DosPutMessage
  99.  
  100. ; 2. call DosOpen("KBD$", @handle, @action, 0L, 0, 1, 12h, 0L)
  101.            push    ds
  102.            push    offset kbd     ;device name
  103.            push    ds
  104.            push    offset handle  ;returned handle
  105.            push    ds
  106.            push    offset action  ;returned new/existed flag
  107.            xor     ax,ax
  108.            push    ax             ;initial file length = dword 0
  109.            push    ax
  110.            push    ax             ;file attribute = word 0
  111.            push    1              ;fail if file non-existent
  112.            push    12h            ;not sharable, r/w access
  113.            push    ax             ;reserved: dword zero
  114.            push    ax
  115.            call    DosOpen
  116.  
  117. ; 3. Get shift status for handle opened above:
  118. ;    call DosDevIOCTL(@data, @parm, function, category, handle)
  119.            push    ds             ;far addr of data area
  120.            push    offset shift
  121.            push    ds             ;use same addr as parm area
  122.            push    offset shift
  123.            push    73h            ;function 73: get shift status
  124.            push    4              ;category 4: keyboard IOCTL
  125.            push    handle         ;handle from previous open call
  126.            call    DosDevIOCTL
  127.  
  128. ; 4. Reset NumLock bit, call DosDevIOCTL as above to set shift status
  129.            and     shift,RESET    ;reset bit in Kbd status word
  130.            push    ds             ;far addr of data area
  131.            push    offset shift
  132.            push    ds             ;use same addr as parm area
  133.            push    offset shift
  134.            push    53h            ;function 53: set shift status
  135.            push    4              ;category 4: keyboard IOCTL
  136.            push    handle
  137.            call    DosDevIOCTL
  138.  
  139. ; 5. Close the KBD$ handle: call DosClose(handle)
  140.            push    handle
  141.            call    DosClose
  142.  
  143. ; 6. Terminate w/o installing
  144.            xor     ax,ax          ;set code & data lengths to zero
  145.            mov     es:[bx].init_data1,ah
  146.            mov     es:[bx].init_ecode,ax
  147.            mov     es:[bx].init_edata,ax
  148.            mov     es:[bx].req_status,810Ch ;set return status:
  149.                                             ; bit 15 = error
  150.                                             ; bit  8 = done
  151.                                             ; bits 0-7 = error code
  152.            ret
  153. strategy   endp
  154. code       ends
  155.            end
  156.