home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / kernex32.zip / mwdd_src.zip / 32bits / ext2-os2 / mwdd32 / mwdd32_start.asm < prev    next >
Assembly Source File  |  1997-03-16  |  7KB  |  206 lines

  1. ;
  2. ; $Header: d:\\32bits\\ext2-os2\\mwdd32\\rcs\\mwdd32_start.asm,v 1.4 1997/03/16 12:44:29 Willm Exp $
  3. ;
  4.  
  5. ; 32 bits OS/2 device driver and IFS support. Provides 32 bits kernel 
  6. ; services (DevHelp) and utility functions to 32 bits OS/2 ring 0 code 
  7. ; (device drivers and installable file system drivers).
  8. ; Copyright (C) 1995, 1996, 1997  Matthieu WILLM (willm@ibm.net)
  9. ;
  10. ; This program is free software; you can redistribute it and/or modify
  11. ; it under the terms of the GNU General Public License as published by
  12. ; the Free Software Foundation; either version 2 of the License, or
  13. ; (at your option) any later version.
  14. ;
  15. ; This program is distributed in the hope that it will be useful,
  16. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  18. ; GNU General Public License for more details.
  19. ;
  20. ; You should have received a copy of the GNU General Public License
  21. ; along with this program; if not, write to the Free Software
  22. ; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  23.  
  24.         .386p
  25.  
  26.  
  27.         INCL_DOSERRORS equ 1
  28.         include bseerr.inc
  29.         include devhlp.inc
  30.         include devcmd.inc
  31.         include devsym.inc
  32.  
  33.         include segdef.inc
  34.         include r0thunk.inc
  35.  
  36. ; Definition of the request packet header.
  37.  
  38. reqPacket       struc
  39. reqLenght       db ?
  40. reqUnit         db ?
  41. reqCommand      db ?
  42. reqStatus       dw ?
  43. reqFlags        db ?
  44.                 db 3 dup (?)    ; Reserved field
  45. reqLink         dd ?
  46. reqPacket       ends
  47.  
  48. rpInitIn        struc
  49. i_rph           db size reqPacket dup (?)
  50. i_unit          db ?
  51. i_devHelp       dd ?
  52. i_initArgs      dd ?
  53. i_driveNum      db ?
  54. rpInitIn        ends
  55.  
  56. DATA16 segment
  57.                 extrn data16_end : byte
  58.                 public device_header
  59.  
  60. ;*********************************************************************************************
  61. ;************************* Device Driver Header **********************************************
  62. ;*********************************************************************************************
  63. device_header   dd -1                            ; Pointer to next driver
  64.                 dw 1100100110000000b             ; Device attributes
  65. ;                  ||||| +-+   ||||
  66. ;                  ||||| | |   |||+------------------ STDIN
  67. ;                  ||||| | |   ||+------------------- STDOUT
  68. ;                  ||||| | |   |+-------------------- NULL
  69. ;                  ||||| | |   +--------------------- CLOCK
  70. ;                  ||||| | |
  71. ;                  ||||| | +------------------------+ (001) OS/2
  72. ;                  ||||| |                          | (010) DosDevIOCtl2 + SHUTDOWN
  73. ;                  ||||| +--------------------------+ (011) Capability bit strip
  74. ;                  |||||
  75. ;                  ||||+----------------------------- OPEN/CLOSE (char) or Removable (blk)
  76. ;                  |||+------------------------------ Sharing support
  77. ;                  ||+------------------------------- IBM
  78. ;                  |+-------------------------------- IDC entry point
  79. ;                  +--------------------------------- char/block device driver
  80.  
  81.                 dw offset CODE16:mwdd32_stub_strategy ; Strategy routine entry point
  82.                 dw offset CODE16:mwdd32_stub_IDC       ; IDC routine entry point
  83.                 db 'mwdd32$ '                    ; Device name
  84.                 db 8 dup (0)                     ; Reserved
  85.                 dw 0000000000011011b             ; Level 3 device driver capabilities
  86. ;                             |||||
  87. ;                             ||||+------------------ DosDevIOCtl2 + Shutdown
  88. ;                             |||+------------------- More than 16 MB support
  89. ;                             ||+-------------------- Parallel port driver
  90. ;                             |+--------------------- Adapter device driver
  91. ;                             +---------------------- InitComplete
  92.                 dw 0000000000000000b
  93. DATA16 ends
  94.  
  95. CODE16 segment
  96.         assume cs:CODE16, ds:DATA16
  97.  
  98.         extrn code16_end : byte
  99.  
  100.         public mwdd32_stub_strategy
  101.         public mwdd32_stub_IDC
  102.         public thunk16$mwdd32_idc_1
  103.         public thunk16$mwdd32_idc_2
  104.  
  105. mwdd32_stub_strategy proc far
  106. ;    int 3
  107.         movzx eax, byte ptr es:[bx].reqCommand
  108.         cmp eax, 0
  109.         jz short @@error
  110.         push es                                 ; seg reqpkt
  111.         push bx                                 ; ofs reqpkt
  112.         push eax                                ; command
  113.         mov word ptr es:[bx].reqStatus, 0       ; updates the request status
  114.         call far ptr FLAT:MWDD32_STRATEGY       ; 32 bits strategy entry point
  115.         mov word ptr es:[bx].reqStatus, ax      ; updates the request status
  116.         retf
  117.  
  118. @@error:
  119.         ;
  120.         ; Cannot be initialized as a DEVICE statement. MUST be
  121.         ; initialized as a BASEDEV statement. (ring 0 FLAT CS is
  122.         ; unreachable at DEVICE INIT time ...)
  123.         ;
  124.         mov dword ptr es:[bx].i_devHelp, 0
  125.         mov  word ptr es:[bx].reqStatus, STDON + STERR + ERROR_I24_BAD_COMMAND
  126.         retf
  127. mwdd32_stub_strategy endp
  128.  
  129. mwdd32_stub_IDC proc far
  130.         jmp far ptr FLAT:thunk32$mwdd32_idc
  131. thunk16$mwdd32_idc_1:
  132.         retf
  133. thunk16$mwdd32_idc_2:
  134.         retf 8
  135. mwdd32_stub_IDC endp
  136.  
  137.  
  138. ;*********************************************************************************************
  139. ;**************** Everything below this line will be unloaded after init *********************
  140. ;*********************************************************************************************
  141. end_of_code:
  142.  
  143. CODE16 ends
  144.  
  145. CODE32 segment
  146. ASSUME CS:FLAT, DS:FLAT, ES:FLAT
  147.  
  148.         public begin_code32
  149.         public thunk32$mwdd32_idc
  150.  
  151.         extrn  MWDD32_STRATEGY  : far
  152.         extrn  mwdd32_idc       : near
  153.  
  154. begin_code32:
  155.  
  156.  
  157. thunk32$mwdd32_idc:
  158.         push ds
  159.         push es
  160.     mov ax, seg FLAT:DATA32
  161.         mov ds, ax
  162.         mov es, ax
  163.  
  164.         lea eax, [esp + 12]
  165. ;        push eax
  166.         call mwdd32_idc
  167. ;       add esp, 4
  168.  
  169.         pop es
  170.         pop ds
  171.     ;
  172.     ; Was it a V1.00 style request ?
  173.     ;
  174.     mov edx, eax
  175.     and edx, 0FFFF0000h
  176.     jnz short @@old
  177.     ;
  178.     ; new post V1.00 idc interface
  179.     ;
  180.         jmp far ptr thunk16$mwdd32_idc_1
  181. @@old:
  182.     ;
  183.     ; old V1.00 idc interface
  184.     ;
  185.         jmp far ptr thunk16$mwdd32_idc_2
  186.  
  187. CODE32 ends
  188.  
  189. DATA32 segment
  190.         public  codeend
  191.         public  dataend
  192.  
  193.         codeend dw offset CODE16:code16_end
  194.         dataend dw offset DATA16:data16_end
  195.  
  196.  
  197. DATA32 ends
  198.  
  199. BSS32 segment
  200.         public  begin_data32
  201.  
  202.         begin_data32 dd (?)
  203. BSS32 ends
  204. end
  205.  
  206.