MiniOS is a miniature operating system kernel for operating system development learners that can run on a 32-bit x86 architecture CPU. MiniOS focuses on learning and researching the core concepts and basic principles in operating system development, and implements various basic subsystems or modules in the operating system based on general hardware.
The popular operating system kernels such as Linux and FreeBSD are good, but they are not suitable for beginners in kernel development. On the one hand, these operating system kernels have developed for many years and have accumulated a huge amount of code (the early version of the Linux kernel v2.6.12 released in 2005 already had about 4 million lines of code). On the other hand, because of the needs of applications in production environments, these kernel codes contain a large number of details that are not related to the basic principles of the operating system, which is difficult for beginners to grasp the key points. Therefore, starting with a simple operating system kernel with a small amount of code, using a short time to familiarize yourself with and master the core concepts and basic principles of the operating system kernel development field, mastering these basic knowledge to a certain level, and then devote yourself to the development of practical kernels such as Linux, is a relatively realistic and feasible strategy for kernel beginners. Even if you don't plan to engage in kernel development, learning some basic knowledge about the operating system through an easy-to-start kernel will help you write more robust and performing applications.
MiniOS is mainly developed based on C language and x86 assembly language, and the development tools used include:
Among them, Binutils is a set of tools for operating binary files, including tools for creating static libraries, tools for strips for removing symbol tables from binary files to reduce file size, etc.
MiniOS is currently started from the floppy disk, and the startup process is:
Since MiniOS is an operating system kernel for learners, it is currently mainly running in virtual machines, with optional virtual machines including Bochs and Qemu.
Run MiniOS in Bochs
sudo apt-get install bochs under the Ubuntu system to install it. You can download the source code of Bochs first and then compile and install it. You can select the desired version of Bochs when installing through the source code.tar zxvf misc/80m.img.tar.gz . , and decompress the hard disk image from the hard disk image compression package.bochs command in the current directory to start the Bochs virtual machine. Bochs will first read the configuration information from the bochsrc file, and then confirm the run prompt information given by Bochs to allow MiniOS to run in Bochs.Run MiniOS in Qemu
sudo apt-get install qemu-system-x86 under the Ubuntu system for installation, or you can download the source code of Qemu for compilation and installation.tar zxvf misc/80m.img.tar.gz . , and decompress the hard disk image from the hard disk image compression package../launch-qemu.sh command in the current directory to start the Qemu virtual machine, and then MiniOS will start running directly in Qemu. The Qemu virtual machine does not use a configuration file like bochsrc. The configuration information is specified through command line options. The script launch-qemu.sh contains the configuration options currently used. MiniOS can be debugged at the assembly-level by using the debugging function included in Bochs or Qemu, but this debugging method is not very convenient to use because the assembly program is lengthy and difficult to read. Fortunately, both Bochs and Qemu have built-in gdb support. By combining with the remote debugging function provided by gdb, MiniOS can be debugged at C source code.
Debugging MiniOS with Bochs+gdb
./launch-bochs-gdb.sh in the MiniOS source directory. The running shell script will run gdb in a new terminal window and load the debug version of the kernel binary.target remote :2345 in the gdb command interface to establish a connection with Bochs.Debugging MiniOS with Qemu+gdb
./launch-bochs-gdb.sh in the MiniOS source directory. The running shell script will run gdb in a new terminal window and load the debug version of the kernel binary.target remote :1234 in the gdb command interface to establish a connection with Qemu. # 编译 MiniOS 内核和用户程序 init,并写入到软盘镜像 a.img 中
make image
# 清除所有 .o 目标文件
make clean
# 清除所有 .o 目标文件和可执行文件
make realclean