top | item 42331270

Show HN: Banan-OS, an Unix-like operating system written from scratch

333 points| Bananymous | 1 year ago |github.com

This is my operating system that I've been working for the past 2 years. All of the code is written exclusively by me except from ported software. banan-os has a monolithic kernel targeting x86 (i686) and x86_64 architectures. The project consists of bootloader, kernel and userspace libraries (libc, libGUI, libFont, ...). It also uses my custom C++ standard library partly based on stdc++.

Currently I have basic TTY and GUI environment with some of the basic UNIX utilities like cp, ls and stat. I have basic support for USB (keyboard/mouse/storage), disks (NVMe, AHCI), custom networking stack with TCP and UDP support, and a UNIX-like filesystem with /dev /tmp /proc filesystems.

The whole project is written in C++ except for my BIOS bootloader that is written in 16-bit real mode assembly. I have been testing the OS mainly on virtual machines but also frequently on real hardware.

63 comments

order

DigiEggz|1 year ago

This is really cool! I like the name, too. Of all the things you've implemented for this, what has been the most difficult part? And have you hit any serious roadblocks along the way?

Bananymous|1 year ago

There hasn't been any overly difficult parts. I'd say the most difficult one has to be either AML interpreter because the ACPI specs are very badly written or the USB stack just because the size of the specifications is so large with a lot of cross referencing.

There hasn't been any major roadblocks. Sometimes I give up on a feature and come back to it maybe month or two later though.

bsimpson|1 year ago

I read it thinking "banyan tree" until I saw the ASCII art and realized it's a banana reference.

sedatk|1 year ago

This is so cool! I especially applaud you for managing to implement USB drivers from scratch! By the way, I broke it by typing "cat doom1.wad" :)

Bananymous|1 year ago

Thank you! Yeah there isn't really any data serialization done to data written into the TTY, so can break if you feed it arbitrary binary data :D

dvh|1 year ago

There is a certain customary sentence to be put in new os kernels announcements and your announcement lacks this sentence.

bityard|1 year ago

You surely mean that it's a hobby project and probably won't be big and professional like GNU?

38|1 year ago

oh fun, a guessing game :|

spiffyk|1 year ago

Very cool! How much time do you dedicate to this, in terms of hours per week? Looks like a lot of work has gone into it!

You say you're a student on your profile - does that mean university? If so, have you also worked on the OS directly as part of your studies?

Bananymous|1 year ago

Yeah I am a student at an university. I have managed to "skip" some courses like operating systems and concurrency just by showing my project to the professor. Otherwise my project is not integrated to my studies in any way. I also got a part time job in my university's embedded side because of my project.

How much time I put to this really depends on what else is happening in my life at the moment. There has been months where I've put total of 5 hours into this and some weeks alone I may reach close to 40 hours.

mrbungie|1 year ago

Cool project!, alternative name for a fork: PlatanOS

p0w3n3d|1 year ago

PlátanOS with stressed first a

whartung|1 year ago

Very nice. Lot of work.

What stand out challenges have you encountered?

Bananymous|1 year ago

I think biggest challenges have to be with reading large specifications. I've never really done that before so it took some time to get used to.

savgore|1 year ago

This is awesome! Can I ask what development looks like? Do you run this in a VM or on bare metal? When you sit down and work on this, what does it look like?

I bet you learned a lot with this - how do you keep notes and track your development? Or is the OS your live journal. Thanks

Bananymous|1 year ago

I do maybe 95% of testing on a VM. It is way faster and much more convenient. I do test on real hardware regularly though. It's always cool to see stuff actually running on bare metal and bare metal is not as forgiving as VMs can be.

Generally I decide a feature I want to add. Then I do a general overview of the corresponding specifications and sometimes look at how already existing OSs handle that. I try to make some kind of mental model about the system and what it needs. Then I basically just write what ever I come up on the spot.

I have a really bad habit of not writing docs or taking notes. Basically I just hold everything in my head (and forget about it when I would need that information again). For some more complex stuff I do draw diagrams and write notes but I pretty much only keep those locally for myself.

kortex|1 year ago

How does one even begin to write drivers for nvme, ata, rtl nics, etc? I know mice and keyboards use HID which is a standard, but are there similar standard protocols for all other devices?

Is this how linux manages to avoid needing to "install drivers" in the vast majority of cases? And if there are standard device APIs, why does windows have to go through that whole install driver routine every time I plug something in?

Bananymous|1 year ago

Yeah basically every commonly used device has its protocol standardized. Although there exist some devices where the manufacturer has to provide the drivers. All of the devices I have written drivers have had their specifications publicly available for free (e.g. NVMe at https://nvmexpress.org/specifications).

I'm not really familiar with how Linux nor Windows handle drivers. While compiling the Linux kernel you specify which drivers you want to build into the kernel and which ones you want as modules. Usually most common ones compiled along side the kernel so there isn't really need to install them later, just load the driver modules. There are also devices that work with just a generic driver but would have more features with a specific one (e.g. led settings on a gaming mouse). I think Windows is maybe installing these optional drivers.

notawolf|1 year ago

This a very cool side project, congratulations! Any tips for anyone that also would like to attempt something similar ? Like where to start or or sources etc

torlok|1 year ago

OSDev Wiki for practical knowledge, operating system design and computer architecture books for the theory.

VagabundoP|1 year ago

Awesome. I was not expecting something with that feature set.

Do you plan on porting more software?

Bananymous|1 year ago

I do plan to port more! I want to keep the base OS free of 3rd party code, but ports are really nice way to get things running that I have not yet written.

I have some ports locally that are not yet working. I have git, binutils, gcc, make all compiling but they are giving some weird errors. Probably a bug in my libc or syscalls.

stevekemp|1 year ago

A minor bug-report, if you run "cd /proc/3" you cannot "cd .." afterwards.

It looks like ".." entries don't exist beneath /proc.

MomsAVoxell|1 year ago

I think it’s going to be quite important to address portability and general flexibility when it comes to architectures.

What do you think it will take to target RISC-V?

Bananymous|1 year ago

I've tried to abstract everything architecture dependent but there is still a lot of x86 specific code outside of archutecure specific directories. I've been planning on adding support for new platforms, but I've not yet had the motivation to start doing it.

I'm not familiar with other architectures than x86 so I can't really say what it will take. At least a lot of work :D

nunobrito|1 year ago

Really enjoyed that you just run and fun from the browser.

Doom wasn't loading for me (Brave browser on Ubuntu without javascript disablers).

Very good work. It was fun without doubt.

Bananymous|1 year ago

Oh yeah, sorry. I'm missing documentation on how to access the GUI environment. You have to enter the GUI environment using `start-gui` command. After that doom should start by running `doom` in the GUI terminal. Performance in the web emulator is really bad though, so don't expect much :D

ajxs|1 year ago

Really impressive achievement! I love the name too!

jart|1 year ago

Rename the project UHHNIX or OOHNIX. Great work!

PTOB|1 year ago

Are you trying to start a flame war?? :-D

keyvank|1 year ago

can you compile and run smth like gcc in your OS?

Bananymous|1 year ago

I've managed to compile the GNU toolchain (binutils + gcc). gcc seems to work fine, it can properly compile source code into assembly. There are some problems with binutils that make it not able to create object files or link. I'm haven't dug deeper to see where the problem actually is.