📄 readme.386bsd
字号:
Note: all my original references to 386BSD also refer to freeBSD and NetBSDwhich in some ways are derived from 386BSD. --julian@freebsd.orgThis Boot code is different from the original boot code that came with386BSD in that it uses the BIOS to load the kernel and to provide all i/oservices. The advantage ofthis is that the same boot code exactly, can runon any device that is supported by the BIOS. (That's most of them)This is important for the 'generic scsi' project because it means we canwrite drivers for new scsi adapters without having to develop an newset of boot blocks for each.At this point you should read the first part of README.MACH... come back herewhen you have done that:In normal operation, when co-existing with other operating systems, thefollowing operations occur:1/ the BIOS loads the first block of the disk (called the Master Boot Recordor MBR) and if it has the correct magic numbers, jumps into it:2/ The MBR code, looks at the Partition table that is embedded within it,to determine which is the partition to boot from. If you install theboot manager when FreeBSD is first installed, it will also give you a nicemenu for switching between operating systems.3/ The MBR will load the first record of the selected partition andif it has (the same) magic numbers, jumps into it. In 386bsd this is thefirst stage boot, (or boot1) it is represented in /usr/mdec bywdboot, asboot and sdboot. If the disk has been set up without DOS partitioningthen this block will be at block zero, and will have been loaded directly bythe BIOS. This is the usual case with floppies.4/ Boot1 will look at block0 (which might be itself if there are no DOSpartitions) and will find the 386bsd partition,Boot 1 also contains a compiled in DOS partition table(in case it is at block 0), which contains a 386bsd partition startingat 0. This ensures that the same code can work whether or notboot1 is at block 0.4A/ IF the NAMEBLOCK option is compiled into the bootcode, then the boot1 code will load and examine block1 (usually unused) andlook for a default boot string to use later (if the correct magic numberis present). If the option NAMEBLOCK_WRITEBACK is also defined, thenit will zero out that name after finding it, and write the block back,having "used up" that name. The block may contain multiple differentboot strings which will be "used up" one after the other (one per boot)They are set using the "nextboot" utility.4B/ Using the information found in step 4, regarding the start positionof the BSD partition, boot1 will load the first 16 sectors of that partition,to around 0x10000 (64k) and will jump into it at the appropriate entry point.Since boot1 and boot2 were compiled together as one file and then splitlater, boot1 knows the exact position within boot2 of the entry point.5/ Boot2 asks the user for a boot device, partition and filename, and thenloads the MBR of the selected device. This may or may not be the devicewhich was originally used to boot the first MBR. The partition tableof the new MBR is searched for a 386bsd partition, and if one is found,that is then in turn searched for the disklabel. This could all be on thesecond disk at this point, if the user selected it. If the user makes noactions then a default string will be used.If the NAMEBLOCK option is used, then the default string may have beenloaded from block2. If none was found then a compiled in default will be used.6/On finding the disklabel, on the disk the user spacified, boot2 can findthe correct unix partition within the 386bsd partition, and using cutdownfilesystem code, look for the file to boot (e.g., 386bsd).7/ Boot2 loads this file starting at the location specified by the a.out header,(see later) and leaps into it at the location specified in he header.if the file does not exist or cannot be loaded, boot2 goes back to step 5.386bsd is now running and will hopefully start vm etc. and get to multi-usermode.##########################################################################During all these steps, all i/o is performed using the BIOS. This has a numberof side effects:1/ Since BIOS disk calls are specified in terms of cylinder,head and sector,and the BIOS read the disk information from either the CMOS or from some otherlocation which is un-available to us, we must use the cyl,head,sec informationthat is given in the MBR, rather than the start address in the MBR, becausewe cannot guarentee that we can corectly calculate C,H,S from the start address.Therefore, the C,H,S information in the MBR must be as correct for this bootto work as it would be for DOS to boot. For example, adaptec BIOS routinesassume a layout of 64 heads and 32 sectors giving 1MB per ficticious cylinder.You must use these figures to calculate the correct values. Luckily, the DOSfdisk program will do all this for you if you tell it to give you a DOSpartition, and you can change it to a 386BSD partition later. If you use no DOS partitioning, then the compiled in table in Boot1 will do just fine.If you want to do it by hand remember that BIOS counts sectors starting at 1.(cylinders and heads start at 0 (??))2/ you cannot overwrite the bottom 4k of ram until you have finished ALLbios calls, as BIOS uses this area as scratch memory.This is no longer really a problem as we no-longer support loading the kernelat location 0.3/ Since BIOS runs in REAL mode, and Boot2 runs in protected mode,Boot 2 switches back to real mode just before each BIOS call and thenback to protected mode on each return. Touch this at your peril.!#########################################################################In answering the prompt from Boot2:you can, 1/ leave it alone. It will boot the indicated file from the first partition of the first drive seen by the BIOS (C:)If the NAMEBLOCK option is in use, the default name might be taken from block1(2nd block) on that drive (the drive on which boot 1 was loaded).2/ enter only "-s" to boot the default to single user mode3/ enter only a filename (optionally with -s) to boot that kernel,4/ enter a whole line of the form shown in the prompt. This allows you toboot some other partition, possibly on the second drive, as root.##########################################################################In the case you have several drives the same type (all scsi or all IDE/ESDI), wd(0,a)xxxwill boot xxx from drive 0, a partition. wd(1,a)xxxwill boot xxx from drive 1, a partition.similarly for sd and for higher drive numbers (if the BIOS supports them).if you have one or more wd drives and one or more scsi drives, then youMUST specify the BIOS drive number for booting the scsi drives: 2:sd(0,a)xxxwill boot xxx from scsi drive 0, a partition, provided `2' is the correctBIOS drive number for sd0.otherwise the following will happen:with wd0 and sd0, you specify sd1 or wd1 to indicate the 2nd drive.it boots the kernel correctly, then tells the kernel to use sd1 as root.you however may not have an sd1, and problems arise.Whether sd or wd is specified to the kernel is read from the disklabel,so ensure that all SCSI disks have type SCSI in their disklabel or theboot code will assume they are ESDI or IDE. (Remember, because it isworking through the BIOS it has ho idea what kind of disk it is.##########################################################################Installing:The makefile supplied has a target install which will create thefiles wdboot,bootwd ,sdboot and bootsd in /usr/mdec.BEWARE these will overwrite the existing wdboot and bootwd. (so backthem up)there are also targets wd and sd which wil only do one of themThe commented out targets wd0 and sd0 are examples of how to load the new bootblocks, however,make sure you change the device type and label to suit your drive if you uncomment them.(see 'man disklabel')If you already have made partitions using the old bootblocksthese should install painlessly.Before you do this ensure you have a booting floppy with correctdisktab and bootblock files on it so that if it doesn't work, you canre-disklabel from the floppy.$FreeBSD: src/sys/pc98/boot/biosboot/README.386BSD,v 1.2.2.1 1999/09/05 08:20:02 peter Exp $
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -