Skip to content

MidnightRaider06/hippos

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

hippos

🦛hippOS is a hobby OS kernel that I will attempt to implement from scratch during Summer 2025 and beyond as a learning experience. I will document my progress in this README including any challenges I face and resources I use.

6/13/25

I finished following the Bare Bones tutorial on OSDev Wiki to write a simple kernel for 32-bit x86. I got familiar with setting up a cross-compiler, using it to assemble object files and link them into a final kernel, and testing an OS using QEMU. I still have to figure out my next steps with this project, including how a project like this should be properly structured, what my target platform should be (32-bit or 64-bit), and the features I should prioritize first.

Screenshot 2025-06-13 200743

Resources:

6/18/25

I finished following the Meaty Skeleton tutorial on OSDev Wiki, which is a continuation of the Bare Bones tutorial. It is a template operating system that serves as an example of how to structure the project, including things like a freestanding kernel C library, arch directories for architecture-dependent code, and different Makefiles and build scripts. I plan on taking some time to study this structure and all the code in it so I know what's going on instead of blindly copying and pasting without learning what the different parts do. I've found some resources to help me figure out some next steps, including another OSDev Wiki article and a YouTube playlist by Daedalus Community that looks fairly promising for figuring out general next steps.

Resources:

6/21/25

I spent some time looking at all the Meaty Skeleton code trying to understand what each part does and how they interact with each other. I'd say I have a much better understanding of it than before, although some things are a bit fuzzy (I get it for the most part though). After watching some YouTube videos and reading the "Going Further on x86" article linked below, it seems like creating a GDT is a logical next step. After that, I'll most likely work on interrupts, paging, and getting keyboard input in some order (not too sure yet). I've decided to build on top of the Meaty Skeleton tutorial code instead of starting everything from scratch because this way, I have some foundation instead of going in completely blind which might be counterproductive for a beginner to learn. From my understanding, this is a good way to organize the project and I can always rewrite any parts if I need to.

Resources:

6/30/25

I have been working on setting up the GDT and reading the OSDev Wiki pages closely. Initially, I got this error message:

Booting from hard disk. Boot failed: could not read the boot disk. Booting from floppy. Boot failed: could not read the boot disk. Booting from DVD/CD

I figured out that the issue was somewhere in my gdt_flush assembly function, which is supposed to flush the GDT set up by GRUB and replace it with my own. I did some research on how to use GDB with the kernel and thankfully there was an OSDev Wiki article. I looked closely at the GDT tutorial page and used GDB to make sure the bits were set correctly for each entry in the table. After making sure there weren't any issues with my gdt_entry struct and how I was setting its fields, I continued using GDB to find the issue. It turns out that I forgot a dollar sign so instead of moving the immediate value 0x10 to the %eax register, I moved the contents of memory address 0x10 to %eax. This messed up the values in the segment registers because I used %eax to set %ds, %es, %fs, %gs, and %ss. The GDT seems to be working properly now after adding the dollar sign. My next step is to start researching and working on the IDT.

Resources:

7/10/25

I've been reading up on the different types of interrupts, the IDT, and different gate types. I also read about PICs and how they manage hardware interrupts. I finished setting up the IDT and creating a table of ISR stubs. Right now, the IDT code sets up interrupt vectors 0–31 (CPU exceptions) in the IDT, where each entry points to its corresponding ISR stub handler from isr_stub_table[]. The attribute for all the IDT entries is set to 0x8E, making them interrupt gates, so there aren't any trap gates yet. From my understanding after researching a bit, starting with only interrupt gates in the early stages is safer because they clear the IF flag (disabling maskable interrupts until iret restores IF), making sure that any unpredictable behavior is avoided if an interrupt occurs while another is being handled. Right now, exceptions that push an error code onto the stack and ones that don't are handled the same way with the same exception_handler() function, which I will have to eventually change. The exception_handler() function just hangs the computer right now. One issue I faced was with defining data types in my libc; I created a stdbool.h but it turns out stdbool.h is already included in a freestanding environment, and the resulting error broke code that was working before and wasn't changed.

My next step is probably to enable an interrupt controller, most likely PIC instead of APIC, because it's simpler and I want to learn the fundamentals. I did some reading about master and slave PICs but I have to look into it more. Hopefully I can get keyboard input soon. When I have time, I might also clean up the build process for the project because there are a bunch of scripts in the root right now. Even though executing the qemu.sh script is enough to build and test the project, having a Makefile in the root will look neater, but this is lower priority.

Resources:

8/2/25

I finished reading about the 8259 PIC chips in the x86 architecture and successfully (I think) initialized the master and slave PICs. The code for that is pretty much just boilerplate and when I was debugging using GDB, I didn't see anything that suggested anything was wrong. I also made sure that the CPU exceptions are working as intended. I originally included a division-by-zero line in kernel_main, so I had a line with "int x = 5 / 0;" and the exception handler was supposed to print a "CPU EXCEPTION" message to the terminal. However, this message wasn't printed when I tested in QEMU regularly, and it worked sometimes when testing using GDB (depending on whether I used si or something like n 100). This sent me on a witch hunt trying to figure out why my exception handler wasn't being called, and I rechecked my IDT initialization code and the ISR stubs. I tried manually triggering interrupts in kernel_main with int $0 assembly instructions and it turned out that my exceptions were being handled. The issue was that for a statement like "int x = 5 / 0;", the compiler most likely optimizes it in some way (still not sure exactly how) so the exception isn't triggered. I reworked this to use assembly instructions in kernel_main to force the machine division, and the "CPU EXCEPTION" message printed correctly.

My next step is to finally write a PS/2 keyboard driver so I can get keyboard input. I'm pretty sure I have all the prerequisites, like initializing the IDT and PIC. I think I'll have to add 16 more entries to the IDT for the hardware interrupts (IRQs). Hopefully I don't run into any issues with the PIC or any of the code I wrote for the I/O ports. I still have to make sure to save all registers at the start of the interrupt handlers and restore them at the end. I should also probably initialize a timer (PIT), as it will eventually be important for implementing a scheduler or triggering interrupts. I'm eager to add creative features to this project, but right now it's a lot of boilerplate and setting up stuff that has to be done for any OS. I think I'm doing a good job of getting a somewhat in-depth understanding of the topics instead of mindlessly copying code.

image

Resources:

About

🦛hippOS is a hobby OS kernel that I will attempt to implement from scratch during Summer 2025.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors