Bug 26382

Summary: FreeBSD Bootable CDROM won't boot on IBM PC Desktops
Product: Base System Reporter: ambrisko <ambrisko>
Component: i386Assignee: freebsd-bugs (Nobody) <bugs>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Unspecified   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
file.diff none

Description ambrisko 2001-04-06 17:30:01 UTC
The problem is that some BIOSes namely IBM's writes to the boot sector
of the floppy to potentially update the parameters for the emulated
floppy used for the El Torrito boot.  Since we do not allocate space
for a typical MSDOS "Boot Sector" when the BIOS updates this area
it then ends up modifying the boot code which is not a good thing.
The boot code then fails in random ways.

Fix: This is relative to /sys/boot/i386/boot2 and was generated against 
-stable.  Hints were obtained from OpenBSD & NetBSD.  

Space in boot1 was allocated so the BIOS could non-destructively update the
MSDOS Boot Sector in boot1 without nuking code.

I added a hack since "xread" was being called from boot2 with a hard
coded value.  Since this can change and lead me on a wild goose chase
I added a perl script and modified the Makefile to determine the
offset for "xread" and then patch that into boot2.c  So whenever boot1
changes boot2.c will be patched with a potentially new value.  This
also means that xread can be moved around the boot1.s code without
breaking things.

I did not put in the full label from OpenBSD since boot1 started to 
overflow.  So I only did it for the size that NetBSD did.

We can now boot CDROM on several different IBM desktops.
How-To-Repeat: 
Stick any FreeBSD CDROM that is bootable into an IBM PC and it won't
boot of the CDROM currectly (For example IDE CDROM on IntelliStations
and other IDE based models).  This does not fix failures on ThinkPads
(770Z & 600E for sure).  That seems to be yet a different problem.
Comment 1 ambrisko 2001-04-06 23:00:55 UTC
Here is the updated structure in boot1.s to fix FreeBSD CDROM booting on
ThinkPads 770Z, 600E.

  /*  From OpenBSD biosboot.S with tuned values from Doug Ambrisko so
      ThinkPads can boot from CDROM.  I think the critical part
      is setting the media type.
  */
          .org 0x03, 0x00
          .asciz  "FreeBSD"
          /* BPB */
          .org 0x0b, 0x00
  bpb:    .word   512             /* sector size */
          .byte   1               /* sectors/cluster */
          .word   1               /* reserved sectors */
          .byte   2               /* # of FAT */
          .word   224             /* root entries */
          .word   2880            /* small sectors */
          .byte   0xf0            /* media type (fd) */
          .word   144             /* sectors/fat */
          .word   18              /* sectors per track */
          .word   2               /* # of heads */

          /* EBPB */
          .org 0x1c, 0x00
  ebpb:   .long   16              /* hidden sectors */
          .long   0               /* large sectors */
Comment 2 John Baldwin freebsd_committer freebsd_triage 2001-07-31 20:50:32 UTC
State Changed
From-To: open->closed

Committed, thanks!