Skip to content

Repository files navigation

Logo

Completion

bloodmoon

WIP Os for my twitch series: https://www.twitch.tv/damebanda

Current memory usage:

6MB

State:

  • Basic boot services
  • Interface with limine
  • Basic print functionality
  • Page frame allocator
  • CPU Structures (GDT, IDT, TSS, LDT) (needs improvements for multi ring)
  • Paging and mappings
  • Memory sectoring and protection
  • Advanced print functionality
  • Heap
  • I/O Basic interfaces
  • Keyboard drivers
  • ACPI structures
  • Clocks and signal lines (signal lines moved forward)
  • Proces structures
  • EXT2 filesystem
  • VFS
  • Serial communication
  • TTY
  • Task switching
  • Basic concurrency
  • Process loading
  • Syscalls
  • Userspace
  • mLibc (sorta)
  • Basic software utilities
  • Network drivers
  • Network stack (In progress)
  • Bootstrapping (Compiling from the own OS)
  • Mouse drivers
  • Graphical interface
  • Advanced device drivers (USB)

Requirements

  • binutils, gcc 13.1 and nasm default toolchain stuff

  • xorriso

  • gdisk

  • fdisk

  • mtools

  • dosfstools

  • tree

  • qemu (optional)

  • virtuabox (optional)

  • Limine. Inside the folder:

    git clone https://github.com/limine-bootloader/limine.git --branch=v3.0-branch-binary --depth=1
    

Networking

Bloodmoon is a network oriented OS, so you cannot run it without a NIC!

I have tested it with openvpn tap interfaces and it works fine. (NDIS6)

Just rename the nic to tap and give it the mac that you want.

On real systems you depend on compatibility with the intel e1000 driver... (I have another for a generic i825 but it is unfinished atm)

How to configure

Modify GNUmakefile paths to point to your toolchain. Yo will have to modify:

  • QEMU Path to a qemu binary
  • GDB Path to a gdb binary (required only for debug target)
  • CMDNEWSCREEN In WSL2 pops up a new terminal (required only for debug target)
  • WSLHOSTIP In WSL2 gets the windows host ip (required only for debug target)

Makefile targets

To create required files (only do this once):

make setup

To compile (and run) just run:

make

You can cleanup garbage with the classic:

make clean

If setup correctly you can start a debugging session with:

make debug

You can modify the file debug.gdb in order to change the starting symbol. Remember that you need the port 1234 open in your host firewall.

Note: go.sh is redundant with make, used only to automate from vscode through a build task (ctrl+shift+b).

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "make",
            "type": "shell",
            "command": "./go.sh",
            "problemMatcher": [],
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ]
}

Driver support

For adding drivers simply create a file in the drivers folder with at least the following

#include "../dev/devices.h"

//Add here your functions
uint64_t my_read(struct file *file, uint64_t offset, uint64_t size, uint8_t *buffer) {
    //True read operation
    return 0;
}

struct file_operations fops = {
    .read = my_read
};

void init_dummy_driver(void) {
    //8 is the major number for SCSI devices, use your own.
    register_block(8, "DRIVER NAME", &fops);
}

void exit_dummy_driver(void) {unregister_block(8);}

Then, at some time you must call the init function of your driver:

init_dummy_driver();

Now you are ready to call generic functions like:

    device_read("/dev/sda", 8, 0, buffer);

As long as /dev/sda is a valid device with major=8, the function will call your driver.

Some debug help

I cancelled the gpt build:

Now you probably have spurious mounted drives in your system, you will have to:

  • Unmount everything under /mnt/bloodmoon
  • Delete the /mnt/bloodmoon folder
  • delete every loop device used by the build (losetup -a) and delete them (losetup -d /dev/loopX)
  • delete everything with sudo cleansetup
  • rebuild

TODO

VFS

Okay, so the idea is the following:

  • Implement the ext2 format functions
  • Implement the ext2 link functions
  • Allocate a chunk of memory for the filesystem
  • Format it with ext2
  • Create folders for /dev /sys /proc /bin /etc /home /mnt /tmp /var /usr and whatever else i feel like
  • Link the devices to the /dev folder
  • ¿What does mount mean in this context?
  • Chroot this virtual filesystem to /

Acknoledgements and credits

  • Keep-Konect github
  • Marco Paland (info@paland.com)
  • Lukás Chmela
  • Absurd Poncho
  • The Limine project
  • strawberryhacker
  • ToAruOS
  • Roen
  • ChickenOS
  • JsonParser github

About

Cool kernel with a pedantic name (Uses limine)

Resources

Stars

6 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages