-
Notifications
You must be signed in to change notification settings - Fork 110
Build Process for basekernel.iso
basekernel.iso is the disk image that is booted onto a virtual machine to run Basekernel. To build it, the Makefile in the root directory builds and combines the library, user programs, and kernel image.
The root Makefile first runs make inside the library subdirectory. In the library's Makefile, all of the .c files are compiled into object files. Then, the library object files are archived into one archive file, baselib.a. An archive file is basically a file built from one or more object files and their metadata. Archive files are portable and compressible.(https://en.wikipedia.org/wiki/Archive_file).
Another object file called user-start.o is also compiled in the library Makefile. user-start.o is the starting point for all user programs.
After the library is built, the root Makefile calls make for the Makefile inside the user directory. This Makefile compiles and builds the user programs into executables linked with baselib.a and user-start.o.
The root Makefile will then run make inside of the kernel directory to build basekernel.img. In this Makefile, all of the .c and .S files are compiled into object files. Then, bootblock.elf is made by running ld
on bootblock.o. From bootblock.elf, the binary bootblock is made. bootblock is the code the BIOS will use to load basekernel into memory and start running it. kernel.elf is made by running ld
on all of the kernel object files (all of the other object files besides bootblock.o). Then, from kernel.elf, the binary kernel is made. kernel contains the majority of the Operating System code. Finally, bootblock and kernel are concatenated together to form basekernel.img. Zeros are added at the end of basekernel.img to make the file 1474560 lines.
After the library, user programs and basekernel.img are built, the root Makefile then starts to put everything together. First, the Makefile creates image, image/boot and image/bin directories. Then, it copies the kernel/basekernel.img into the image/boot directory. After this, it copies all of the user programs into the image/bin directory.
Then, using a program like genisoimage (the default for Basekernel), basekernel.iso is created from the image directory. genisoimage "takes a snapshot of a given directory tree, and generates a binary image which will correspond to an ISO9660 and/or HFS filesystem when written to a block device".(https://linux.die.net/man/1/genisoimage) After basekernel.iso is created, you are ready to boot Baskernel on a virtual machine.