home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / os / cpm / 1569 < prev    next >
Encoding:
Text File  |  1993-01-11  |  9.7 KB  |  198 lines

  1. Path: sparky!uunet!news.tek.com!wrgate!fury.wr.tek.com!donk
  2. From: donk@fury.wr.tek.com (Donald C. Kirkpatrick)
  3. Newsgroups: comp.os.cpm
  4. Subject: Re: diseased Kaypro/Wordstar
  5. Message-ID: <11122@wrgate.wr.tek.com>
  6. Date: 11 Jan 93 21:30:56 GMT
  7. References: <1if6sfINNeou@CS.UTK.EDU>
  8. Sender: news@wrgate.wr.tek.com
  9. Organization: Tektronix, Inc.
  10. Lines: 186
  11.  
  12. In article <1if6sfINNeou@CS.UTK.EDU> jfarmer@cs.utk.edu (JOHN FARMER) writes:
  13. >
  14. >I have a Kaypro 4'84, and I'm using Wordstar 4.0, and I have a problem
  15. >somewhere.  I keep looking part of 'large-files'.  What's happening is that
  16. >parts of files are disappearing only to be replaced with other (duplicate)
  17. >parts of the same file.
  18. >
  19. >The first times it happened, I was working on a large file on a full disk,
  20. >and I just assumed that when I had tried to save, and there wasn't room, that
  21. >Wordstar got lost when it stopped to tell me there wasn't any room and I had 
  22. >to delete stuff to continue.  The latest time it happened, I was working on
  23. >a much smaller file on a virtually empty disk.  (and to make it worse,
  24. >I was dutifully saving every so often, so there was no backup file to
  25. >get the data from.  I lost about 2-3 hours of work.)
  26. >
  27. >My husband thinks it's a disk drive problem.  I'm not so sure.  I don't 
  28. >seem to have the problem with pip, for instance.  Any suggestions?  Ideas?
  29. >I do re-build Wordstar ever so often.  I use it all the time, and the disk
  30. >"goes bad" every so often.
  31. >
  32. >All help appreciated.
  33. >
  34. >Thanks
  35. >Susan B. Farmer     farmer@cs.utk.edu
  36.  
  37. While it is not yet known for sure, the problem described above appears
  38. to me as if Susan has found the infamous BDOS Function 37 bug. She is
  39. now checking to see if that was indeed her problem. To save others her
  40. grief, I thought I'd post the information I sent to her. Everyone who
  41. has not yet installed a BDOS replacement must at least become aware of
  42. this bug and decide for themselves whether or not to patch their BDOS.
  43.  
  44. The following text is from the file NULU151.INF contained in the
  45. library NULU152A.LBR. I have deleted much that is not relevant and you
  46. will find my comments in square brackets with my initials.
  47.  
  48.  
  49. -------------------------begin extraction-------------------------------
  50.  
  51. [Extracted from: NULU152.INF, a file included with NULU152A.LBR, a
  52. library utility program - DCK]
  53.  
  54. <much stuff deleted -DCK>
  55.  
  56. The  other  problem  - that  of  overcoming  the  BDOS  error  is   more
  57. complicated.  The  simplest  way  would be to fix the BDOS  and  I  have
  58. included a patch to the Digital Research BDOS for those who wish to make
  59. the change. There are dangers inherent with fixing the BDOS however, and
  60. I would strongly recommend leaving things the way they are.  My argument
  61. for leaving things is as follows:
  62.  
  63. The  CP/M 2.2 BDOS is a stable product and can be guaranteed to  perform
  64. in exactly the same way for every user.  Knowing its limitations,  it is
  65. possible to overcome the problems caused by the bug(s).  If all users of
  66. NULU were to patch their BDOSes,  they may one day come across a program
  67. which  works  BECAUSE  of  the bug and hence would  not  work  on  their
  68. systems.  Similarly,  any software developed on a 'fixed' BDOS cannot be
  69. guaranteed to work on an unfixed BDOS.  However, I include the patch and
  70. leave it up the users to decide. Freedom of choice is everyones right.
  71.  
  72. The  BDOS bug although related to function 37 is not,  in fact,  in that
  73. function  but in the Select Disk function (function 14).  Problems  will
  74. only be caused under the following circumstances:
  75.  
  76. 1. The default drive has been reset, AND
  77.  
  78. 2. Data has been written to the default drive since the disk reset, AND
  79.  
  80. 3. Some sort of disk activity is requested on a different drive.
  81.  
  82. The  BDOS  keeps  a 16 bit variable (the login vector) which  shows  the
  83. login state for each of drives A-P.  In the vector,  each bit represents
  84. one drive and is set if the drive is logged in.  As records are  written
  85. to disk,  the allocation vector in the BIOS is used to maintain a record
  86. of  those  disk blocks allocated to the file.  The allocation vector  is
  87. updated  as blocks are written to disk but is initially set up from  the
  88. disk  directory  when the drive is first logged  in.  BDOS  function  37
  89. simply  resets  the appropriate bit(s) in the login vector which  should
  90. cause the drive to be relogged on the next access.
  91.  
  92. Unfortunately,  Digital  Research  maintain  an  internal  variable  for
  93. holding  the last drive accessed and check it before logging in a  disk.
  94. If  the requested drive is the same as the last,  then the BDOS  assumes
  95. that  it  is already logged in and it doesn't check the login vector  at
  96. all.  If  we have reset the default drive,  the internal  variable  will
  97. still  say that is is logged in,  even though the login vector bit  will
  98. have  been  reset.  Disk writes may still be made to this drive and  the
  99. allocation vector will still be updated.
  100.  
  101. If we were now to temporarily switch drives to do a read,  for  example.
  102. The  internal  variable  will reflect this and NEXT time we  access  the
  103. default drive,  the BDOS's check will now say "Ah,  a different drive  -
  104. check the login vector".  When this happens, of course, it will find the
  105. bit  for  this  drive is reset and will re-read the  disk  directory  to
  106. update the allocation vector.
  107.  
  108. The  disk  directory is only updated when either an extent  boundary  is
  109. passed (every 16k) or when the file is closed.  Consequently,  unless we
  110. are lucky,  the disk directory will not show the last few disk writes we
  111. have  made and those bits will be reset in the allocation  vector.  This
  112. means  that as far as the BDOS is concerned,  those blocks are free  for
  113. use  and  it will use them again - even if it means allocating the  same
  114. block(s) twice to the same file.
  115.  
  116. In context of NULU,  assume that a library, resident on drive A, is open
  117. and  that  we  are currently logged into drive B (ie:  drive  B  is  the
  118. default  drive).  Assume  that we wish to extract a 100k member file  to
  119. drive  B.  NULU  creates a buffer when the library is opened  and  a  2k
  120. buffer for the file to be extracted.  The buffer for the library will be
  121. a  large percentage of the remaining TPA size but suffice to say that it
  122. will  be smaller than our member file.  We then fill the library  buffer
  123. with  the  first part of the member file and reset drive B in  case  the
  124. disk  has  been changed - condition 1 is then satisfied.  We  now  start
  125. writing  out the member file (condition 2) until the library  buffer  is
  126. exhausted.  We  then  need  to read more of the library from drive  A  -
  127. condition 3.
  128.  
  129. <more stuff deleted - mostly NULU specific code - DCK>
  130.  
  131. On another subject altogether,  the additions of code to save and resore
  132. the S2 byte are to do with files larger than 512k. It may be of interest
  133. to  note that Digital Research 'forgot' to document that the S2 byte  is
  134. an overflow extent byte.  Anyone who has tried to edit a text file under
  135. Wordstar  will  probably have found that it goes bananas when  the  file
  136. size  exceeds  512k.  Wordstar is not alone in this,  there are  several
  137. other  commercial  and PD programs that suffer badly when  dealing  with
  138. files greater than 512k.
  139.  
  140. Digital  Research  say that CP/M 2.2 can handle files of up to  8Mb  and
  141. CP/M  Plus can handle files up to 32Mb.  They also say that  the  extent
  142. byte  (under 2.2 and Plus) can vary between 0 and 31 in use - under CP/M
  143. 1.4  this was 0 to 15.  Now 32 times 16k is nowhere near 8Mb  let  alone
  144. 32Mb,  in fact it comes to that magic figure of 512k - this is where the
  145. S2  byte  comes in.  The S2 byte counts the multiples of 512k used in  a
  146. file  and may range from 0 to 15 under CP/M 2.2 (bits 0-3) and 0  to  63
  147. under CP/M Plus (bits 0-6).  Bit 7 of the S2 byte is used by the BDOS as
  148. an internal 'archive' bit.  When a file is opened, an examination of the
  149. S2 byte will show a value of 80H.  If any write is performed to the file
  150. in question,  this bit will be cleared.  When the close file function is
  151. called,  if  the bit is set then no action is required.  If it is clear,
  152. the  disk  directory is updated.
  153.  
  154. <more NULU specific code deleted - DCK>
  155.  
  156. The DRI BDOS fix
  157. ----------------
  158.  
  159. Zero  out the following locations in the DRI BDOS,  note that  the  BDOS
  160. starts  6  bytes before the address at location 0006H and that  ZSID/DDT
  161. etc.  will not give the true address. Use something like Z3LOC or STATUS
  162. to  determine your BDOS address.  The bytes at those locations and  what
  163. they do are given so that you can patch away with confidence.
  164.  
  165. Location to patch       Byte at that location (Hex)
  166.                      (xx = depends upon BDOS address)
  167.  
  168. BDOS + 0C45H                    3A         LDA xxD6H     ; Get wanted drive
  169. BDOS + 0C46H                    D6
  170. BDOS + 0C47H                    xx
  171. BDOS + 0C48H                    21         LXI H,xx42H   ; Get last drive
  172. BDOS + 0C49H                    42
  173. BDOS + 0C4AH                    xx
  174. BDOS + 0C4BH                    BE         CMP M         ; Same drive?
  175. BDOS + 0C4CH                    C8         RZ            ; Return if it is
  176.  
  177. [Note: only the RZ code at 0c4ch need be set to zero - DCK]
  178.  
  179. This patch prevents the BDOS from using its internal saved record of the
  180. last  drive  accessed  and forces it to check the login vector  bits  to
  181. determine whether or not to relog a drive.
  182.  
  183. The patch above works but on your own head be it!
  184.  
  185.  
  186. -------------------------end of extraction------------------------------ 
  187.  
  188.  
  189. As a final note, anyone who is running one of the BDOS replacements, P2DOS,
  190. NovaDOS, ZRDOS, ZSDOS, and so on, should find that this bug has been fixed.
  191. I all my 14 years of CP/M, I have never encountered a program that required
  192. the bug present to work properly. (Insert weasel words here) Thats not to
  193. say such a program doesn't exist, just that I have not found it yet.
  194.  
  195. --
  196.     -Don Kirkpatrick (Donald.C.Kirkpatrick@tek.com)
  197.         UUCP:    ...!uunet!tektronix!Donald.C.Kirkpatrick
  198.