home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / unix / bsd / 2876 < prev    next >
Encoding:
Text File  |  1992-07-25  |  2.6 KB  |  72 lines

  1. Newsgroups: comp.unix.bsd
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!rpi!greg
  3. From: greg@ecse.rpi.edu (Greg)
  4. Subject: 386bsd-0.1: primary bootstrap (wdbootblk.c) problem & fix.
  5. Message-ID: <greg.712111605@hibp1.ecse.rpi.edu>
  6. Summary: I have solved a timing dependent boot problem by adding a delay.
  7. Keywords: 386bsd boot bootstrap wdbootblk.c
  8. Nntp-Posting-Host: hibp0.ecse.rpi.edu
  9. Date: Sun, 26 Jul 1992 00:46:45 GMT
  10. Lines: 60
  11.  
  12.    In a recent post I described a booting problem I was having: I could only
  13. boot about 20% of the time in high speed mode. I tried all the latest patches,
  14. but the problem persisted. By putting a printf at the top of boot.c, I          determined that it was not making it out of wdbootblk.c.
  15.  
  16.    I managed to learn enough 386 assembly language from reading the source, to
  17. enable me to write directly to the video buffer. By placing video writes 
  18. throughout the bootstrap, I was able to figure out where it was getting hung up.
  19.  
  20. from wdbootblk.c:
  21.  
  22.     readblk:
  23.             movl    $ IO_WD1+wd_status,%edx
  24.                NOP
  25.             inb     %dx,%al
  26.             testb   $ WDCS_BUSY,%al
  27.             jnz readblk
  28.  
  29. It would get stuck in this loop, thinking that the controller was busy.
  30. my code:
  31.  
  32. readblk:
  33. # beware, ugly hack ahead!!
  34. # it is safe to clobber ax, cx here
  35.         movl    $0xff,%ecx
  36. blink:  movw     $0x0f30,%ax
  37.         movw     %ax, VIDEO
  38.         movw     $0x0f5c,%ax
  39.         movw     %ax, VIDEO+160
  40.         movw     $0x0f21,%ax
  41.         movw     %ax, VIDEO+160
  42.         movw     $0x0f2f,%ax
  43.         movw     %ax, VIDEO+160
  44.         movw     $0x0f5f,%ax
  45.         movw     %ax, VIDEO+160
  46.         decl    %ecx
  47.         movl    %ecx,%eax
  48.         jnz     blink
  49. # end of ugly hack
  50.  
  51.         movl    $ IO_WD1+wd_status,%edx
  52.         NOP
  53.         inb     %dx,%al
  54.         testb   $ WDCS_BUSY,%al
  55.         jnz readblk
  56.  
  57.      After adding this, I was able to successfully boot 30 consecutive times at
  58. full speed. I appologize if its ugly, as my knowledge of 386 assembly 
  59. language is entirely based on reading wdbootblk.c. I appeal to someone who 
  60. actually knows 386 assembler to write a proper delay loop. My version works 
  61. fine, but I am sure it can be more compactly coded. Also, in a final version
  62. the video writes would be removed.
  63.      If someone could help me recode this into a more "publishable" form,
  64. it can be made available as a patch and a patched binary. I don't think
  65. (at least I hope), that this will "break" the bootstrap with respect
  66. to machines other than mine. Also, I wonder if anyone has any insight as to the 
  67. cause of this problem. Perhaps there is a better fix for it.
  68.  
  69.       Happily booting and rebooting,
  70.                                      Greg  -  greg@megas.ecse.rpi.edu
  71.  
  72.