home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / kernex32.zip / mwdd_src.zip / 32bits / ext2-os2 / doc / mwdd32 / samples.im < prev    next >
Text File  |  1997-03-16  |  8KB  |  177 lines

  1. .*
  2. .* $Header: d:\\32bits\\ext2-os2\\doc\\mwdd32\\rcs\\samples.im,v 1.4 1997/03/15 17:13:14 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. .nameit symbol=titre_700 text='Sample 32 bits device drivers'
  25. .nameit symbol=titre_701 text='32 bits regular (DEVICE) device driver'
  26. .nameit symbol=titre_702 text='32 bits base (BASEDEV) device driver'
  27. .nameit symbol=titre_703 text='32 bits Installable File System (IFS) driver'
  28. .nameit symbol=titre_704 text='32 bits OS/2 Security Enabling Services (SES) driver'
  29.  
  30. .*******************************************************************************
  31. .*** VI- Sample 32 bits device drivers                                      ***
  32. .*******************************************************************************
  33. :h1 id=700.&titre_700.
  34.  
  35. :p.
  36. This chapter describes the sample device drivers included in this package.
  37.  
  38. :ol compact.
  39. :li.:link reftype=hd refid=701.&titre_701.:elink.
  40. :li.:link reftype=hd refid=702.&titre_702.:elink.
  41. :li.:link reftype=hd refid=703.&titre_703.:elink.
  42. :li.:link reftype=hd refid=704.&titre_704.:elink.
  43. :eol.
  44.  
  45. :nt.
  46. The 32 bits version of my Linux ext2fs IFS is now available and is a good example of
  47. a full featured 32 bits IFS, which uses mwdd32.sys services. It can be found at &colon.
  48. :sl compact.
  49. :li.ftp&colon.//ftp.leo.org/pub/comp/os/os2/drivers/ifs/ext2_200.zip
  50. :li.ftp&colon.//sunsite.unc.edu/pub/Linux/system/Filesystems/ext2/ext2_200.zip
  51. :esl.
  52. :ent.
  53.  
  54. .*******************************************************************************
  55. .*** regular (DEVICE) device driver                                         ***
  56. .*******************************************************************************
  57. :h2 id=701.&titre_701.
  58.  
  59. :h4.Location&colon.
  60. :xmp.
  61. &dot./32bits/ext2-os2/skeleton/device
  62. :exmp.
  63.  
  64. :h4.Device driver initialization&colon.
  65. :p.
  66. Regular device drivers initialize at ring 3. Because at this time the FLAT code segment
  67. is unreachable (ring 0), the driver cannot do a far call to its 32 bits initialization routine.
  68. To achieve 32 bits initialization, a small 16 bits routine called at INIT time does the following&colon.
  69. :ol compact.
  70. :li.Opens the mwdd32$ device (mwdd32.sys)
  71. :li.Sends IOCTL category 0xF0 function 0x42 to mwdd32$, with the following parameters &colon.
  72. :sl compact.
  73. :li.the FLAT pointer to the kernel's TKSSBase pointer.
  74. :li.the FLAT pointer to a DevHelp32 structure
  75. :li.the FLAT pointer to the 32 bits INIT routine
  76. :li.the 16&colon.16 pointer to the INIT request packet.
  77. :esl.
  78. :li.mwdd32$ updates the TKSSBase value, so that our driver can use the :color fc=red bc=default.__StackToFlat():color fc=default bc=default. helper.
  79. :li.mwdd32$ fills the DevHelp32 structure with pointers to 32 bits DevHelp and utility functions, so that our driver can use them.
  80. :li.mwdd32$ calls back our 32 bits INIT routine at ring 0.
  81. :li.Upon return from our 32 bits routine, mwdd32$ stores the return code in the IOCTL data packet.
  82. :li.Upon return from the IOCTL call, the small 16 bits routine mentionned above retrieves the return code from the IOCTL data packet, and passes it back to the kernel.
  83. :eol.
  84.  
  85. .*******************************************************************************
  86. .*** base (BASEDEV) device driver                                           ***
  87. .*******************************************************************************
  88. :h2 id=702.&titre_702.
  89.  
  90. :p.
  91. Location&colon.
  92. :xmp.
  93. &dot./32bits/ext2-os2/skeleton/basedev
  94. :exmp.
  95.  
  96. :h4.Device driver initialization&colon.
  97. :p.
  98. Unlike regular device drivers, base device drivers initialize at ring 0. In this case, the 32 bits INIT BASE 
  99. routine can be called directly. The first think the INIT base does is to call a routine which does the following&colon.
  100.  
  101. :ol compact.
  102. :li.Attaches to the mwdd32$ device (mwdd32.sys)
  103. :li.Calls mwdd32$'s IDC entry point, with the following parameters &colon.
  104. :sl compact.
  105. :li.the FLAT pointer to the kernel's TKSSBase pointer.
  106. :li.the FLAT pointer to a DevHelp32 structure
  107. :esl.
  108. :li.mwdd32$ updates the TKSSBase value, so that our driver can use the :color fc=red bc=default.__StackToFlat():color fc=default bc=default. helper.
  109. :li.mwdd32$ fills the DevHelp32 structure with pointers to 32 bits DevHelp and utility functions, so that our driver can use them.
  110. :eol.
  111.  
  112.  
  113. .*******************************************************************************
  114. .*** Installable File System (IFS) driver                                   ***
  115. .*******************************************************************************
  116. :h2 id=703.&titre_703.
  117.  
  118. :h4.Location&colon.
  119. :xmp.
  120. &dot./32bits/ext2-os2/skeleton/ifs
  121. :exmp.
  122.  
  123. :h4.IFS initialization&colon.
  124. :p.
  125. Installable File System drivers initialize at ring 3. Because at this time the FLAT code segment
  126. is unreachable (ring 0), the IFS cannot do a far call to its 32 bits initialization routine.
  127. To achieve 32 bits initialization, a small 16 bits routine called at INIT time does the following&colon.
  128. :ol compact.
  129. :li.Opens the mwdd32$ device (mwdd32.sys)
  130. :li.Sends IOCTL category 0xF0 function 0x41 to mwdd32$, with the following parameters &colon.
  131. :sl compact.
  132. :li.the FLAT pointer to the kernel's TKSSBase pointer.
  133. :li.the FLAT pointer to a DevHelp32 structure
  134. :li.the FLAT pointer to the 32 bits IFS INIT routine
  135. :li.the 16&colon.16 pointer to the parameters passed to FS_INIT.
  136. :esl.
  137. :li.mwdd32$ updates the TKSSBase value, so that our driver can use the :color fc=red bc=default.__StackToFlat():color fc=default bc=default. helper.
  138. :li.mwdd32$ fills the DevHelp32 structure with pointers to 32 bits DevHelp and utility functions, so that our driver can use them.
  139. :li.mwdd32$ converts the 16&colon.16 pointer to FS_INIT parameters to 0&colon.32.
  140. :li.mwdd32$ calls back our 32 bits IFS INIT routine at ring 0.
  141. :li.Upon return from our 32 bits routine, mwdd32$ stores the return code in the IOCTL data packet.
  142. :li.Upon return from the IOCTL call, the small 16 bits routine mentionned above retrieves the return code from the IOCTL data packet, and passes it back to the kernel.
  143. :eol.
  144.  
  145. .*******************************************************************************
  146. .*** OS/2 Security Enabling Services (SES) driver                           ***
  147. .*******************************************************************************
  148. :h2 id=704.&titre_704.
  149.  
  150.  
  151. :h4.Location&colon.
  152.  
  153. :xmp.
  154. &dot./32bits/ext2-os2/skeleton/ses
  155. :exmp.
  156.  
  157.  
  158. :h4.OS/2 SES driver Initialization&colon.
  159.  
  160. :p.
  161. An OS/2 Security device driver is actually a base device driver, so the first part of 
  162. the initialization phase is similar to a BASEDEV initialization phase.
  163.  
  164. :p.
  165. In addition to the BASEDEV initialization phase, an OS/2 security driver must at least
  166. issue the following&colon.
  167. :ol compact.
  168. :li.Call the kernel DevHlp32_Security helper to retrieve 32 bits kernel SecHlp entry points.
  169. :li.Call the kernel DevHlp32_Security helper to pass to the kernel the addresses of our security callbacks.
  170. :li.Attach to SES's sesdd32.sys and call its IDC entry point to retrieve 32 bits sesdd32.sys's SecHlp entry points.
  171. :eol.
  172.  
  173. :p.
  174. Once done, in our example, the only non NULL callback is OPEN_PRE. This callback will be called each time a file is opened
  175. by the kernel (DosOpen) before the actual open operation is done. Our sample checks if the file name matches CONFIG.* and returns
  176. ERROR_ACCESS_DENIED if it is the case.
  177.