Skip to content
This repository has been archived by the owner on Nov 26, 2023. It is now read-only.
/ yet-another-kernel Public archive

Trying to understand how an operating system works through experimentations...

Notifications You must be signed in to change notification settings

gthvn1/yet-another-kernel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 

Repository files navigation

Yet Another Kernel

The goal is to try to understand the differents steps from switching your computer on until executing kernel. For this we will follow OSDev tutorials.

Babysteps

Steps to create a basic kernel in assembly are in Babysteps.

How to create a basic kernel in assembly:

Babystep1

  • To debug and check that everything is working as expected you can start qemu as follow:
    • qemu-system-i386 -s -S -fda boot.bin
  • And in another terminal attach gdb:
gdb -ex 'target remote localhost:1234' -ex 'set disassembly-flavor intel'
(gdb) b *0x7c00
(gdb) c
Breakpoint 1, 0x00007c00 in ?? ()
(gdb) x/2i $pc
=> 0x7c00:	cli
   0x7c01:	jmp    0x7c01
  • As you see it is our code that it is running...

Babystep2

  • Just run qemu-system-i386 -hda boot.bin and you should see the famous Hello, World!.
    • -fda is working as well.

Babystep3

  • We use hexdump to see binary file:
# hexdump -C boot.bin
00000000  fa 31 c0 8e d8 be 16 7c  fc ac 08 c0 74 06 b4 0e  |.1.....|....t...|
00000010  cd 10 eb f5 eb fe 48 65  6c 6c 6f 2c 20 57 6f 72  |......Hello, Wor|
00000020  6c 64 21 00 00 00 00 00  00 00 00 00 00 00 00 00  |ld!.............|
00000030  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
000001f0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 55 aa  |..............U.|
00000200
  • We see for example fa that is the opcode for cli.
  • Then 31 that is the opcode for xor register. To decode the instruction completely we need to check the instruction format.

Babystep4

Nothing really special.

Babystep5

Now you can press a key and you will see the value read from the keyboard... Cool no?

Babysteps 6 to 8

They are not really interesting. It is said that we need to setup the GDT to be able to jump to protected mode. We already wrote a blog about this and it is almost done in ZigOS.

YaK (Yet another Kernel) vs CrashTOS...

YaK has been superseded by CrashTOS.

YaK was our first project that we did in parallel of babysteps. Then few weeks after starting it we found cool videos done by Queso Fuego and available on youtube: Amateur Makes an OS. After seeing these videos we started CrashTOS.

Some interesting links

About

Trying to understand how an operating system works through experimentations...

Topics

Resources

Stars

Watchers

Forks