Booting: The Kernel
© Tony Lawrence, aplawrence.com
This is part of a series of articles that covers the booting of an OSR5 machine. See Booting OSR5 for other related articles.
When you type the name of a kernel or just press enter to get the kernel defined by defbootstr, /boot first checks to see that you haven't typed a built in command that it understands, or that what you typed is an alias (remember, it has already read /stand/etc/default/boot) that will expand to something that it can understand; if it is either an alias or a direct reference (like "hd(40)unix") it then looks to see if the kernel or other program you want you want is on the disk. Other program? Yes, if you aren't loading a kernel, you'll be running something else like bootos.
If you have given the name of a program to load, /boot checks the magic number of the file. For example, if you type "/etc/default/boot" at the boot prompt, you'll be told that it has a "bad magic number"; in other words it is not a program that can be executed by /boot. Only standalone programs can be run. If you have the opportunity, try this:
btmt -w # remounts /stand as read/write cp /bin/ls /stand btmnt -d # remounts /stand as readonly shutdown -g1 -y
At the Boot: prompt, type "ls". You will be told that "ls" has a bad magic number. It isn't a standalone program, so /boot won't load it.
Built in commands usually affect some later behavior of /boot or the kernel that it loads, although a notable exception is "dir", which acts much like "ls" except that it has no flags: you can't do "dir -l", for example. Another is "debug", which will be very familiar to those old enough to remember machines that always booted to a debug console, or MSDOS "debug", which served exactly the same purpose as this. Probably the only thing anyone would use this for nowadays is low-level disk format if the disk bios didn't provide any other way to do it. If you have been doing this long enough to remember when that was standard operating procedure, you won't be surprised to learn that "g C800:6" would transfer you to drive formatting code hopefully located at that address.
There's no harm in taking a peek at debug: just type "debug" at the Boot: prompt. A "?" will show you the commands it understands. You can examine registers with "r", and print bytes (just bytes; this is not a disassembler) with "p". Just don't change anything; when you've had enough, type "g" to return to the normal prompt.
"link" is another oddball: when you type "link", it looks like it takes over the loading of the kernel, but actually /boot still does the work, and passes control to link just after the loading. This can be seen by using an emergency boot floppy made with "mkdev fd" (which by default would not have the "link" program on the disk). If you type "link" at that floppy's Boot: prompt, boot will ask you what package(s) you want to link, will then load the unix kernel, and only then will fail because it is unable to load and pass control to link.
Other potentially useful commands:
This lets you change the default btld device (normally it is fd0). Of course, you can always specify specific devices to link, but if you had a strange machine where you needed to link from the second floppy, this could be useful to tuck into the /stand/.bootrc file.
This is one that gets passed to the kernel and would let you use a dumb terminal (or even a Windows PC with terminal emulation!) attached to the COM1 port as your system console. This is hardly ever done nowadays, but when monitors and video cards were fairly expensive, it was common. If you did use this, you'd probably also want to specify the SERIAL keyword in /etc/default/boot to set communications parameters.
This command gives you pretty tight control over the behaviour of the CPU cache. Again, it's unusual to need this nowadays, but the "man HW boot" page explains all about this.
Once you finally do type the name of a kernel, /boot actually sizes memory before it starts to load it. You can get /boot to do just the memory sizing by typing "mem=/p" at the Boot: prompt.
If you do that, you'll have another surprise when you actually do boot: after loading the kernel, /boot stops and tells you that the kernel is loaded and that you need to press RETURN to continue.
Memory sizing has a large section of the "man HW boot" page devoted to it. Each "." that it prints represents 1 megabyte of memory. If you have done "mem=/p", you'll see something like this after all the dots:
If you want to know what memory was used (and how it is used) after booting, run "hw -r ram".
After loading your kernel, /boot passes control to it. The information that boot has about memory size, etc. has been placed at a special memory address where the kernel will know to look for it. That information is documented in /usr/include/sys/bootinfo.h; if you examine this you'll see that /boot actually passes quite a bit of information.
After memory sizing, the kernel's .text (executable code) section is loaded. This procedure prints a "." for each 4K of text.
Jim Mohr, in SCO Companion says that each dot represents 12k, but my experience says that isn't so. For example, on this 5.0.4 machine, "size /stand/unix" tells me that the text size of this kernel is 1797680 bytes and the data segment is 205484 bytes. With each dot being 4k, /boot should print 439 dots for the text segment and 50 dots for data, and that is just what it does.
I suspect that this behaviour might have been changed after Jim published. He mentioned that the booting had the appearance (though not the reality) of being slow due to the 12k chunks; perhaps this perception caused the design change.
After .text comes .data (initialized variables), and then space is set aside for stack variables ("loading .bss"). At this point control is passed to the kernel unless btld's are to be linked in.
Boot Time Loadable Drivers
If you have essential equipment such as a hard disk controller that is not supported by any of the standard drivers included with the installation kernel, you need a boot time loadable driver. Generally, this is simple: you just type "link" at the Boot: prompt or construct a "defbootstr=" line that includes the link. For example, if you needed to link two drivers, you might have to type
defbootstr link="alad ida"
Where this can get confusing is when link objects to something about the driver and asks you what to do about it. The problems might be:
- Major number already in use
The major number is the first of the comma separated numbers that show up when you do a long listing of a device node. See Devices for more information.
You shouldn't have a conflict, and if you do, it probably means that the people providing the driver aren't familiar with SCO Unix- and if that's the case, how much do you trust their driver? The "Master" file that a BTLD provides normally tells the system to simply assign the next major number. If a driver insists upon using a specific number, it had better have an awfully compelling reason, and the instructions for its installation should note that and tell you what to do.
- Interrupt already in use
This, too, is a situation that shouldn't happen. If this is older hardware where there is no choice, you may have to force something else to use a different interrupt to avoid the conflict. This can be done in most BIOSes by forcing PCI devices not to use certain interrupts- generally terminology such as "Reserved for legacy device" is what you'd want.
- Driver name already exists
Unless the driver is actually replacing an existing driver, this is really bad, and there may not be a solution. If it is designed to replace something in the SCO kernel, the documentation should say so and assure you that telling link to replace the existing driver with the btld is indeed what you want to do.
If the name clash is just bad luck, and if you have access to a running Unix machine where you can mount the BTLD disk, you may be able to change the name of the driver to avoid the conflict. You should read the man page for "btld" carefully; at a minimum you'd be changing the name of several directories, and editing the Master and System files to change the name there. This is probably not something you want to do if you haven't had some previous experience with BTLD's and are certain of the effects. On the other hand, if this is stopping your install, what have you got to lose?
After this, /boot gives over control to the kernel.
(OLDER) <- More Stuff -> (NEWER) (NEWEST)
Printer Friendly Version