home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS 1992 June / SIMTEL_0692.cdr / msdos / screen / vdriver.arc / DRIVER.DOC < prev    next >
Encoding:
Text File  |  1986-09-21  |  4.8 KB  |  175 lines

  1.                  Installable Device Drivers in C
  2.  
  3.  
  4. This document is intended to describe a method for using Lattice 
  5. C (small model) to develop Installable Device Drivers for MS-DOS.  
  6. Additionally, a number of C functions (provided in library 
  7. format) are defined.
  8.  
  9. Installable Device Drivers are created by first writing the 
  10. functions to be supported, then linking these functions with the 
  11. Driver Header.  A prototype header file is provided in the file 
  12. HDR.ASM.  Note that two data items (the Attribute and Name/unit 
  13. fields) must be filled in with information specific to your 
  14. driver before this file will assemble properly.
  15.  
  16. The driver header file assumes the existence of the following 
  17. functions (stubs are provided in the DRIVER.LIB library file), 
  18. which perform the various operations described in the Installable 
  19. Device Drivers chapter of the DOS Reference Manual:
  20.  
  21.           Init()
  22.           MediaCheck()
  23.           BuildBPB()
  24.           IoCtlIn()
  25.           Input()
  26.           ndInput()
  27.           InputStatus()
  28.           InputFlush()
  29.           Output()
  30.           OutVerify()
  31.           OutStatus()
  32.           OutFlush()
  33.           IoCtlOut()
  34.           DevOpen()
  35.           DevClose()
  36.           RemMedia()
  37.  
  38. A sample character device driver is included in this package, 
  39. which allows for a device named "MON".  Outputting to this device 
  40. will cause characters to appear on the IBMPC monochrome screen.  
  41. Study of the file MONO.C should reveal the details of this 
  42. implementation.
  43.  
  44.      Questions or comments on this package may be directed to:
  45.  
  46.                           Frank Whaley
  47.                        7211 Camino Colegio
  48.                      Rohnert Park, CA  94928
  49. Through the balance of this document, the pseudo-type "Addr" is 
  50. used to describe a long integer value (32-bits) which is used to 
  51. describe a memory address.  Note that the Segment:Offset 
  52. addressing method used in the 8086 family of processors causes 
  53. this data type to be incompatible with true long integers.  The 
  54. following definition is assumed:
  55.  
  56.                       typedef   long Addr;
  57.  
  58.  
  59. Addr EndAddr();
  60.  
  61.      EndAddr() returns the driver's ending address, as required 
  62.      by the Init function call.
  63.  
  64.  
  65. Addr Dword(ptr)
  66.          char    *ptr;
  67.  
  68.      Dword() converts a 16-bit pointer (into the driver's data 
  69.      segment) to a 32-bit pointer.
  70.  
  71.  
  72. int CopyB(from, to, len)
  73.     Addr    from,
  74.         to;
  75.     int    len;
  76.  
  77.      CopyB() copies a section of memory "len" bytes in length 
  78.      from the area whose address is "from" to the area whose 
  79.      address is "to".  Note that this code assumes that the 
  80.      memory sections do not overlap and that a forward copy is 
  81.      correct.  This function returns the number of bytes copied.
  82.  
  83.  
  84. int CopyW(from, to, len)
  85.     Addr    from,
  86.         to;
  87.     int    len;
  88.  
  89.      CopyW() copies a section of memory "len" words in length 
  90.      from the area whose address is "from" to the area whose 
  91.      address is "to".  Note that this code assumes that the 
  92.      memory sections do not overlap and that a forward copy is 
  93.      correct.  This function returns the number of words copied.
  94. char InB(port)
  95.     int    port;
  96.  
  97.      InB() inputs and returns a byte from the hardware port 
  98.      described by "port".
  99.  
  100.  
  101. int InW(port)
  102.     int    port;
  103.  
  104.      InW() inputs and returns a word from the hardware port 
  105.      described by "port".
  106.  
  107.  
  108. char OutB(byte, port)
  109.     char    byte;
  110.     int    port;
  111.  
  112.      OutB() outputs the byte "byte" to the hardware port 
  113.      described by "port".  This function returns the output byte.
  114.  
  115.  
  116. int OutW(word, port)
  117.     int    word,
  118.         port;
  119.  
  120.      OutW() outputs the word "word" to the hardware port 
  121.      described by "port".  This function returns the output word.
  122.  
  123.  
  124. char PeekB(addr)
  125.     Addr    addr;
  126.  
  127.      PeekB() returns the byte value found at the absolute address 
  128.      given by "addr".
  129.  
  130.  
  131. int PeekW(addr)
  132.     Addr    addr;
  133.  
  134.      PeekW() returns the word value found at the absolute address 
  135.      given by "addr".
  136. char PokeB(val, addr)
  137.     char    val;
  138.     Addr    addr;
  139.  
  140.      PokeB() stores the value "val" into the absolute byte 
  141.      address given by "addr".  This function returns "val".
  142.  
  143.  
  144. int PokeW(val, addr)
  145.     int    val;
  146.     Addr    addr;
  147.  
  148.      PokeW() stores the value "val" into the absolute word 
  149.      address given by "addr".  This function returns "val".
  150.  
  151.  
  152. int SetB(start, len, byte)
  153.     Addr    start;
  154.     int    len;
  155.     char    byte;
  156.  
  157.      SetB() initializes a section of memory "len" bytes in 
  158.      length, beginning with the address given by "start", to the 
  159.      value "byte".  This function returns the number of bytes 
  160.      set.
  161.  
  162.  
  163. int SetW(start, len, word)
  164.     Addr    start;
  165.     int    len,
  166.              word;
  167.  
  168.      SetW() initializes a section of memory "len" words in 
  169.      length, beginning with the address given by "start", to the 
  170.      value "word".  This function returns the number of words 
  171.      set.
  172.