Skip to content

mateuszmidor/OsDev

Repository files navigation

PhobOS

This is a study project for operating systems development for x86-64. Based on:

Credits to the authors!

Showcase

Booting
Logo

Simple dir tree demo
Logo

Simple plot demo
Logo

Simple arkanoid demo
Logo

Features

  • GRUB2 bootable
  • 64 bit kernel
  • memory paging (2MB pages) and on-page-fault allocator
  • stack guard page
  • managed dynamic memory
  • higher-half kernel
  • multitasking
  • kernel/user space
  • ELF64 support (statically linked only) - some basic syscalls implemented, see: syscalls.h
  • virtual filesystem
  • MBR/Fat32 driver (no long names)
  • PS/2 mouse driver
  • Keyboard driver
  • VGA driver (90x30 text mode, 320x200 graphics mode for now)
  • Simple terminal emulator (with TAB auto-completion) and a few basic system commands like cd, cat, cp, mkdir

Need install

  • cmake, at least v3.10
  • xorriso (for building bootable iso PhobOS image)
  • mtools (for fat32 formatting of PhobOS virtual drive)
  • qemu-system-x86_64, with qemu-nbd (for running PhobOS, for mounting virtual phobos drive in linux)

Run it (tested on ubuntu 16.04 & manjaro 17.1.12)

sudo ./remount_hdd.sh
./build_kernel.sh && ./build_user.sh && ./run.sh

Debug it in terminal

sudo ./remount_hdd.sh
./build_kernel.sh -DCMAKE_BUILD_TYPE=DEBUG && ./build_user.sh && ./rungdb.sh
gdb -symbols=build/kernel/kernel/phobos-x86_64.bin -ex "set arch i386:x86-64:intel" -ex "target remote localhost:1234"
(gdb) break kmain
(gdb) continue
(gdb) ^a + ^x

Debug in Eclipse

Run->Debug Configurations... ->C/C++ Remote Application->add
Set Project to PhobOS
Set "Using GDB(DSF) Manual Remote Debugging Launcher" instead of Automatic one
Under Debugger->Connection tab set:

  • Stop on startup at: kmain
  • Port number to 1234

(terminal) ./build_kernel.sh -DCMAKE_BUILD_TYPE=DEBUG && ./build_user.sh && ./rungdb.sh
(eclipse) Debug->our newly created configuration

Debug in VS Code

Install Native Debug from market
launch.json:
{
"version": "0.2.0",
"configurations": [
{
"type": "gdb",
"request": "attach",
"name": "Attach to QEMU",
"executable": "${workspaceRoot}/build/kernel/kernel/phobos-x86_64.bin",
"target": ":1234",
"remote": true,
"cwd": "${workspaceRoot}"
}
]
}
(terminal) ./build_kernel.sh -DCMAKE_BUILD_TYPE=DEBUG && ./build_user.sh && ./rungdb.sh
(vscode) Debug->"Attach to QEMU"

GDB pretty printing of STL containers

  • Install python3
  • Create .gdbinit in project folder with following contents:
    python
    import sys
    sys.path.insert(0, '/home/mateusz/gdb_printers/python')
    from libstdcxx.v6.printers import register_libstdcxx_printers
    register_libstdcxx_printers (None)
    end

Download contents of https://gcc.gnu.org/svn/gcc/trunk/libstdc++-v3/python/libstdcxx/ under:
/home/mateusz/gdb_printers/python/libstdcxx

Should work now.

Tools

  • sudo ./remount_hdd.sh - mount build/hdd.vdi partitions as p1, p2, p3, p4 in current directory. Requires qemu-nbd
  • objdump -f - entry point logical address
  • objdump -h - elf headers
  • grub-file --is-x86-multiboot2 build/kernel-x86_64.bin; echo $? - check if kernel is multiboot2 compliant, (0 means yes)

About

OS development study

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published