Compiling bochs from source

When installing bochs on Ubuntu, a precompiled bochs version including a debugger is intalled. The debugger kicks in with the first instruction when booting from a floppy. Typing continue makes the debugger continue. When debugging with bochs as an emulator, this gets annoying quickly. People report that the -q option turns off the debugger. This did not work for me. The solution for me was to compile bochs from code without enabling the debugger option and again with the debugging option turned on. Using the version without the debugger speeds up development.

Compiling without debugger

Download the bochs source code from http://bochs.sourceforge.net/getcurrent.html
Scroll down
To download, click the link TAR file containing source code (5061k)

sudo apt-get install libxrandr-dev
sudo apt-get install xorg-dev

Read http://bochs.sourceforge.net/doc/docbook/user/compiling.html

Unzip that downloaded file to a directory
Enter the directory

./configure
make

The folder now contains a bochs executable

Compiling with debugger

Download the bochs source code from http://bochs.sourceforge.net/getcurrent.html
Scroll down
To download, click the link TAR file containing source code (5061k)

sudo apt-get install libxrandr-dev
sudo apt-get install xorg-dev

Read http://bochs.sourceforge.net/doc/docbook/user/compiling.html

Unzip that downloaded file to a directory
Enter the directory

./configure --enable-debugger 
make

The folder now contains a bochs executable

 

Lessons Learned

Own Bootloader vs. GRUB

When writing your own bootloader, you are responsible for finding the kernel binary or bootstrap code and loading it at the correct memory location. GRUB on the other hand will automatically give you a lot of features.

A good GRUB example can be found here http://www.jamesmolloy.co.uk/tutorial_html/.

A good custom bootloader example can be found here https://github.com/cfenollosa/os-tutorial

  • Kernel Binary Loading – Your first bootloader will be very simple. Unless you implement filesystem support, your loader has to read the binary using BIOS calls. It cannot know how large a kernel file is without node information of a filesystem. Hence the sectors read by the BIOS have to be hardcoded and you have to read enough sectors to read your entire kernel in. If you read your kernel only partially, your OS will fail. As your kernel grows, it will outgrow the hardcoded value and you have to update the loader or else the OS will fail. GRUB can read the filesystem on a floppy for example. It knows how large your kernel using the node information provided by the filesystem. No partial loading of your kernel will ever occur.
  • Protected Mode – GRUB can immediately put the CPU into protected mode for you.
  • Graphics Mode – GRUB can set the video mode for you.
  • Multiboot – GRUB can give the user the option to choose which OS to boot. If your OS plays nicely by adhering to the multiboot specification, you can easily have several OS installed on the same machine. A good GRUB multiboot example can be found here http://www.jamesmolloy.co.uk/tutorial_html/.

List of Operating Systems and Links

Table of Operating Systems (Written for educational purposes)

Also visit the operating system topic on github: https://github.com/topics/operating-system and https://archiveos.org/. Another intersting list is https://wiki.osdev.org/Notable_Projects

Name Description Homepage Source Languages
xv6 Unix Version 6 clone https://github.com/mit-pdos/xv6-public https://github.com/mit-pdos/xv6-public  
MMURTL – Message-Based Multitasking Real-Time Kernel Open Source along with the book as PDF http://www.ipdatacorp.com/mmurtl/ https://github.com/bproctor/MMURTL  
tyndur The OS acompanying http://www.lowlevel.eu http://www.lowlevel.eu https://git.tyndur.org/lowlevel/tyndur ASM. C
thor-os     https://github.com/wichtounet/thor-os ASM, C++
kylecs     https://github.com/kylecs/Kernel  
Q-Operating-System     https://github.com/raphydaphy/Q-Operating-System  
eduOS RTWH Aachen educational OS   https://rwth-os.github.io/eduOS/  
Syllable   https://archiveos.org/syllable/    
AtheOS        
Haiku        
Contiki   http://contiki-os.org/ https://github.com/contiki-os/contiki  
intermezzos     https://intermezzos.github.io/  
DexOS   http://dex-os.github.io/    

General Concepts

Links (Intel, AMD)

Links (ARM)

Linux

Unix

Rust

Paging, Memory Management