|
Building a Bootable Image FileLast modified: April 14, 2005 |
|
|
CSE Home
|
About Us
|
Search
|
Contact Info
|
- An image file represents raw disk storage that has been formatted and loaded with a boot loader, an OS, and some applications (including a shell).
- Cebollita is distributed with two shells, and so two standard bootable images. File
imagecontains a standard, interactive shell. FilebenchImageis intended for benchmarking runs - the shell it contains runs through a list of user applications and then shuts down.- Building an image file is easy:
- Navigate to directory
cebollita/apps/- Say
make imageormake benchImage- To run the image using Cebollita's software simulator and graphical debugger:
(or
$ java dbg.UI --bootable imagebenchImage).The remainder of this document is an advanced tutorial to experiment with a simple operating system under Cebollita.
If the simulator is run in "bootable" mode, the "BIOS" will load the first disk block into low memory and then start the machine at that address.To run an interesting system in this mode, you'll have to create an image file (a disk image) which contains the various components on it. The image should contain a bootloader at block zero. The bootloader will probably want to just stream in the first executable (starting at block one into low memory). This executable is often a simple OS, which will then take control and perhaps launch other processes. The image files we have built look like this:
- Bootloader (.../Cebollita/apps/os/bootloader.s)
- To make the bootloader
The --bare flag links the bootloader as a "raw" executable. That is, it has no executable header or data segment. It is just a sequence of instructions.java asm.Asm bootloader.s java asm.Linker --output bootloader --bare bootloader.op- OS (in .../Cebollita/apps/os/)
- Consists of the following files:
trap-handler.s (low-level interrupt handler and dispatcher) os.c (system calls, loader, etc). stopProcessor.s (contains a Halt assembler instruction)The kernel is just a regular executable, with a small catch. The bootloader simply drops the OS image into memory starting at location zero. Because the first 6 words of the executable descriptor, the first actual instruction of the OS is at location 24. (The trap handler lives at this location.) For this reason, the OS has to be linked to live at a fixed location, namely 24. Make the kernel as follows:java asm.Asm trap-handler.s java asm.Asm stopProcessor.s java comp.parser os.c java asm.Asm os.s java asm.Linker --output kernel --at 24 --entry __init trap-handler.o stopProcessor.o os.oSee the apps/os/Makefile for details (and use it to automate this process).- The shell (in .../cebollita/apps/os/)
- There are two shells,
shell.candbenchmarkShell.c. They are normal applications, and can be built using the usual compile, assemble, and link procedure.- User programs (a number exist below .../cebollita/apps/)
- Simple user programs with a main can be compiled, assembled, and linked in a normal manner. They should make use of syscalls as defined in iolibs/iolib-os.s. That is, they perform io via syscalls that are ultimately handled by the operating system.
To make an image:
java sim.DiskMake --output image bootloader kernel shell.exe app1.exe app2.exe ...This will create an image file calledimage. As it does so, it will print an index that maps block number to the start of each of the above programs. It will also create a file called "image.map" containing that mapping.Finally, some trickiness is required to run the image, because your console window has to have character input buffering and echoing turned off for the OS you just built to work correctly (just like a real OS...). The best thing to do is use the shell script
.../cebollita/apps/cebrun.shto launch the bootable image:./cebrun.sh image(That command assumes you are in directory.../cebollita/apps.) Once the UI comes up, hit htebootbutton to load the bootloader, and then therunbutton to begin its execution.
|
Department of Computer Science & Engineering University of Washington Box 352350 Seattle, WA 98195-2350 (206) 543-1695 voice, (206) 543-2969 FAX [comments to zahorjan@cs.washington.edu] | |