8000 GitHub - reymontero/Dreamos64: My experiments with osdev... again
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

reymontero/Dreamos64

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DreamOS64

C/C++ CI Discord Chat

DreamOS64 is just my recent attempt to write a kernel again after many years far from osdev, But this time in 64bit.

It is not a real replacement of the original DreamOS, and i don't really have any long term plans for it at the moment.

I started this project because i was missing the excitement of low-level programming :)

What it does

Actually nothing! :D

It just prints the OS name and another string.

What i have implemented so far:

  • Long mode
  • Kernel load in higher half
  • Basic i/o functions (using the VGA bios)
  • Basic framebuffer support (it can print strings on the screen, but only on the first half of the screen, the second half will cause a #PF for now)
  • IDT Support
  • It can load the kernel using 4kb pages or 2Mb pages
  • Added support to access paging data structures with recursion tecnique.
  • Implemented basic physical memory manager
  • Enabled paging
  • Added basic kmalloc
  • Local Apic support
  • IO-Apic support (Keyboard IRQ enable)

Prerequisites:

These are the packages you need to build and run it:

  • nasm
  • qemu and qemu-kvm
  • grub-mkrescue
  • grub-pc-bin
  • xorriso
  • mtools
  • Gcc cross compiler - Instructions coming soon

Build

Building the cross compiler

These instructions needs to be completed only the first time (if you already have a x86_64 cross-compiler already configured you probably can skip them, but you need to update the Makefile with your cross-compiler prefix) To build the cross compiler you need the following packages:

  • build-essential (on debian derivatives)
  • bison
  • flex
  • libgmp3-dev
  • libmpc-dev
  • libmpfr-dev
  • texinfo
  • libcloog

Then you need to download sources of:

Decide where to install the tools and declare the environment variables:

export PREFIX="$HOME/opt/cross"
export TARGET=x86_64-elf
export PATH="$PREFIX/bin:$PATH"

The three exports above should be copied in your ~/.bashrc file as convenience (otherwise you need always to invoke them using their full path) Now create a new folder and enter into it:

mkdir build-binutils
cd build-binutils

Let's assume that this folder is in the same level of the binutils sources.

Then you can compile the tools using the custom PREFIX and TARGET:

../binutils-x.y.z/configure --target=$TARGET --prefix="$PREFIX" --with-sysroot --disable-nls --disable-werror
make
make install
  • --disable-nls disable national language support, it helps to reduce compile time.
  • --with-sysroot Tells binutils to enable sysroot support in the cross-compiler by pointing it to a default empty directory.

If everything goes ok, you can see in your $PREFIX folder the output of the build. Now is time for gcc, we will use a similar approach. First create a build dir:

mkdir build-gcc
cd build-gcc

Again i assume that it is on the same level of the gcc sources folder. To compile:

../gcc-x.y.z/configure --target=$TARGET --prefix="$PREFIX" --disable-nls --enable-languages=c,c++ --without-headers
make all-gcc
make all-target-libgcc
make install-gcc
make install-target-libgcc
  • --enable-languages=c,c++ we tell gcc to enable only those languages
  • --without-headers We tell to ignore all the C libraries present for the target.

Now if you want you can make permanent the $PATH update:

Build the OS

Before building the os you need to copy a PsfV2 font in the fonts folder, called default.ps (even if building with framebuffer off) To build just run:

    make

It will create an output file called DreamOs64.iso

Run

To run just execute:

    make run

If you use instead:

   make debug

It will output logging information on a logfile.

Finally:

   make gdb

Will compile the OS with debug symbol, and launch qemu with remote debugging enabled (it will wait connection from gdb to start).

There are couple of flags that you can set on the Makefile in order to configure some features:

  • USE_FRAMEBUFFER if set to 1 it will enable framebuffer support (still experimental and probably will not work everywhere since is in very early stage of development), in addition you need a PSF v2 font file in the location fonts/default.psf, if set to 0 (default) it will use the legacy VGA driver.
  • SMALL_PAGES if set to 1 it will use 4kb pages (this feature is new, and there are still some problems/unmapped parts that will cause #PF to be generated), if 0 (default) will use 2MB pages.

Unit tests

There is a small set of tests implemented using asserts, if you want to run them just run:

make tests

Known issues

  • If at boot with qemu you get the following error message:
	Booting from DVD/CD...
	Boot failed: Could not read from CDROM (code 0009)

This means you are missing the grub-pc-bin package, and you need to install it.

  • If the linking steps fail with several errors message like:
src/kernel/framebuffer/framebuffer.c:122: undefined reference to `_binary_fonts_default_psf_start'

This means that the fonts folder is missing (you need a psfv2 font file in the fonts folder, the file has to be called default.psf)

About

My experiments with osdev... again

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 86.3%
  • Assembly 10.9%
  • Makefile 2.8%
0