[HN Gopher] Show HN: Banan-OS, an Unix-like operating system wri...
       ___________________________________________________________________
        
       Show HN: Banan-OS, an Unix-like operating system written from
       scratch
        
       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.
        
       Author : Bananymous
       Score  : 315 points
       Date   : 2024-12-05 18:54 UTC (1 days ago)
        
 (HTM) web link (github.com)
 (TXT) w3m dump (github.com)
        
       | DigiEggz wrote:
       | 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?
        
         | bsimpson wrote:
         | I read it thinking "banyan tree" until I saw the ASCII art and
         | realized it's a banana reference.
        
         | Bananymous wrote:
         | 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.
        
           | ksp-atlas wrote:
           | Good work using a custom AML interpreter instead of a premade
           | one!
        
             | Bananymous wrote:
             | My current one is really bad. It does work on maybe 50% of
             | the hardware I have tested. I am in the middle on writing a
             | new proper one, it is already way better but still missing
             | some necessary parts before I can integrate it.
        
           | Findecanor wrote:
           | I would anticipate that you only have support for boot-mode
           | keyboard and mouse now, considering the complexity of the
           | full USB-HID spec. Otherwise I'd be very impressed.
        
             | Bananymous wrote:
             | I do actually support USB keyboard and mouse with USB-HID.
             | There are some parts I don't support, like mouse specifying
             | its movement with physical units (I haven't encountered any
             | of those yet). Also I only have support for xHCI USB
             | controller so PC's with older UHCI, EHCI or AHCI
             | controllers are not yet supported.
        
       | whartung wrote:
       | Very nice. Lot of work.
       | 
       | What stand out challenges have you encountered?
        
         | Bananymous wrote:
         | 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.
        
           | convolvatron wrote:
           | good for you. it gets easier. and being able to actually get
           | down the meat of things is a real superpower. totally agree
           | with you about ACPI though.
        
           | eismeer wrote:
           | Could you link a random specification you were working
           | against? I'm curious how there are written
        
             | Bananymous wrote:
             | Yeah sure!
             | 
             | NVMe base specification https://nvmexpress.org/wp-
             | content/uploads/NVM-Express-Base-S...
             | 
             | xHCI (USB controller) https://www.intel.com/content/dam/www
             | /public/us/en/documents...
        
       | dvh wrote:
       | There is a certain customary sentence to be put in new os kernels
       | announcements and your announcement lacks this sentence.
        
         | bityard wrote:
         | You surely mean that it's a hobby project and probably won't be
         | big and professional like GNU?
        
           | ASalazarMX wrote:
           | I can't see anyone seriously suggesting to management that
           | they run Banan-OS. Probably the same self-inflicted handicap
           | of CockroachDB.
        
             | GTP wrote:
             | It's because we learnt the lesson and know that management
             | wouldn't run it anyway. Otherwise they would go bananas.
        
             | coldpie wrote:
             | Agreed. We run a respectable Freax shop around here.
        
         | 38 wrote:
         | oh fun, a guessing game :|
        
           | xandrius wrote:
           | The other poster already answered...
        
             | readyplayernull wrote:
             | ...that the word iiis...
        
               | drivers99 wrote:
               | "just a hobby, won't be big and professional like gnu"
               | which is a quote from Linus's Linux announcement on
               | Usenet in 1991.[1] He didn't know it was going to be big
               | at the time, making it an ironic statement after the
               | fact, and that could also be the case for any new OS from
               | scratch such as this one.
               | 
               | [1] https://www.cs.cmu.edu/~awb/linux.history.html
        
               | caspper69 wrote:
               | There was a _need_ for linux, and that 's why it took
               | off. The Unix wars, the provenance of the 4.3 BSD code,
               | the _cred_ of running a Unix (or Unix-alike).
               | 
               | Not to trash this guy's project, but there's no similar
               | perfect storm going on right now.
        
               | Imustaskforhelp wrote:
               | I don't think it was a perfect storm going on , but
               | rather since today Linux is popular & strong , you are
               | retracing it to it having a perfect storm and nothing can
               | come close to it .
               | 
               | That being said , I still think that this wouldn't reach
               | mass adoption "just for being an alternative to linux"
               | and that this has to have a specific purpose
               | 
               | For example serenity os has a really cool old - ui and
               | some people think its a fun os in general , out of which
               | came the ladybird project.
               | 
               | Redox os is trying to write it in rust , something which
               | can have some practical meaning in my opinion
        
               | caspper69 wrote:
               | Not really. I don't see how Linux being popular & strong
               | today had any bearing on people's willingness to
               | contribute 33 years ago.
               | 
               | Writing an operating system is challenging. Not as
               | challenging as a compiler, but certainly more work (so
               | much hardware, so many specifications ugh).
               | 
               | In 91-92, people were clamoring for a free, unencumbered
               | 386 Unix. Enter Linux.
               | 
               | Every successful (non-commercial) OS undertaking needs
               | and has a hook.
               | 
               | Redox? Rust (enough said).
               | 
               | Serenity? Live coding and mental health (no knock there).
               | 
               | And on the flip side, look at ReactOS. Languishing.
               | Painfully slow 15+ years in development, and people would
               | still rather pay Microsoft or roll the dice running
               | applications under Wine. It's hook just isn't strong
               | enough.
               | 
               | Again, not to knock this guy, because just the fact that
               | he wrote his own AML interpreter is super impressive to
               | me (I've floundered around in those same ACPI specs for
               | far, far (far, far) too many sleepless nights), and never
               | put out 1 line of AML code. So mad props.
               | 
               | But there's just no hook. C++? Passe. No microkernel /
               | hypervisor / <insert_feature_here>? No capability model?
               | 
               | It'll be tough. But I know that OS'ing is a labor of
               | love, even if not a single other person cares. Cheers.
        
       | spiffyk wrote:
       | 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 wrote:
         | 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.
        
           | spiffyk wrote:
           | Awesome, thanks!
           | 
           | One more set of questions: was there something you would call
           | an "it's alive!" moment in the beginning of the project? A
           | part where it would start to get _really_ fun for you? If so,
           | what was it and how long did it take you to get there?
        
             | Bananymous wrote:
             | There has been multiple really great moments during the
             | development. Its always cool to see some completely new
             | features working on real hardware, like first time getting
             | keyboard input, USB mouse input, running DOOM, reading from
             | disks, networking, and getting a compiler working!
             | 
             | I think it became actually fun after I got all the basic
             | requirements done and could start deviating from more or
             | less standard OS code. When I could actually decide what I
             | want to work on. Maybe after couple of months it was in
             | that state. It was also fun at the beginning. it was just
             | way harder as I didn't have any prior knowledge and I was
             | trying to wrap my head around some basic concepts :D
        
               | ryandrake wrote:
               | > first time getting keyboard input, USB mouse input,
               | running DOOM, reading from disks, networking, and getting
               | a compiler working
               | 
               | One of these is really a lot more impressive (and
               | indicates a far more mature and finished product) than
               | the rest. I love how it's just listed in there next to
               | the basics. Nice job.
        
           | breakfastduck wrote:
           | No doubt you've learned a hell of a lot from this.
           | 
           | I would imagine this will set you up incredibly well for a
           | career in the industry, arguably moreso than your actual
           | degree. Any reasonable prospective potential hirer is gonna
           | be super impressed by it I think.
        
             | Bananymous wrote:
             | > I would imagine this will set you up incredibly well for
             | a career in the industry, arguably moreso than your actual
             | degree.
             | 
             | That's what I hope at least. This is something I would want
             | to do for my career in the future. Good portfolio never
             | hurts :)
        
           | rossant wrote:
           | >xI have managed to "skip" some courses like operating
           | systems and concurrency just by showing my project to the
           | professor.
           | 
           | Love this! Well done. Best way to skip classes ever!
        
       | ajxs wrote:
       | Really impressive achievement! I love the name too!
        
       | savgore wrote:
       | 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 wrote:
         | 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.
        
           | johnisgood wrote:
           | > 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).
           | 
           | This was me for a very long time. I started making notes now,
           | knowing that I will most likely forget (some of it). I still
           | have all sorts of files scattered around though with my
           | notes, i.e. the notes are disorganized (to some extent). I
           | thought of using Obsidian for them and I have tried it but I
           | do not use it consistently, I just go for my XTerm window
           | with emacs or vim.
        
       | sedatk wrote:
       | 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 wrote:
         | 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
        
       | notawolf wrote:
       | 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 wrote:
         | OSDev Wiki for practical knowledge, operating system design and
         | computer architecture books for the theory.
        
         | udev4096 wrote:
         | There's https://os.phil-opp.com/ for rust,
         | https://github.com/tuhdo/os01 for general OS development and
         | make sure to read Operating Systems: Three Easy Pieces
        
         | Bananymous wrote:
         | Pretty much what others said. You should read through
         | https://wiki.osdev.org/Getting_Started and note that it will
         | take a lot time if you decide to go for developing an OS.
        
       | VagabundoP wrote:
       | Awesome. I was not expecting something with that feature set.
       | 
       | Do you plan on porting more software?
        
         | Bananymous wrote:
         | 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.
        
       | mrbungie wrote:
       | Cool project!, alternative name for a fork: PlatanOS
        
         | p0w3n3d wrote:
         | PlatanOS with stressed first a
        
       | nunobrito wrote:
       | 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 wrote:
         | 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
        
       | jart wrote:
       | Rename the project UHHNIX or OOHNIX. Great work!
        
         | PTOB wrote:
         | Are you trying to start a flame war?? :-D
        
           | jart wrote:
           | Just paying my respect for what Oskari pulled off. I tried
           | building my own hobby OS and didn't get nearly this far. I
           | just thought that, like Linux, this UNIX-like OS deserved a
           | name that's closer to the source. For example, Linus
           | originally wanted to name Linux "phreax" but Linux is what
           | stuck after his friend changed the folder name when hosting
           | it for him on an FTP server.
        
       | kortex wrote:
       | 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 wrote:
         | 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.
        
           | caspper69 wrote:
           | So here's the kicker.
           | 
           | Microsoft, having the resources it does, was able to design
           | and implement a stable driver ABI. In fact, they also have a
           | stable userspace ABI. Both have evolved, but that's not the
           | point.
           | 
           | Linux conversely (whether by design or by limitation) does
           | not have stable ABIs (although userspace compatibility isn't
           | terrible). Even though you can build kernel drivers as
           | modules (and then load/unload), those modules are unique to
           | each specific kernel build.
           | 
           | Remember those guys didn't write the compiler & linker
           | toolchains they were using like Microsoft was able to do.
           | 
           | I will be honest, I understand _why_ Linus  & Co. have
           | decided to keep it this way, because it encourages hardware
           | manufacturers to submit either their drivers or their
           | specifications to the upstream kernel, which promotes
           | software freedom. It is a noble goal and has served them
           | well.
           | 
           | BUT - thieir decision has caused me no small amount of
           | consternation over the years as a system administrator. Once
           | you use Linux for something that is not "server software" (be
           | it auth, file sharing, web, etc.), you are generally using it
           | to drive some piece of hardware (CNCs, industrial tools,
           | _cough_ phone systems _cough_ ). Vendors, especially those
           | that deal in low-volume / high-margin products, do _not_ want
           | to release their source code. They 're allergic to the idea
           | even. So I have gotten stuck in outdated kernel hell on
           | several occasions because the kernel devs have decided to
           | change internal interfaces in a point-point release that my
           | driver software relied upon.
           | 
           | I so wish that Linux would move to a stable driver ABI. It
           | would make administration & upgrades so much easier,
           | especially on the embedded side.
           | 
           | But I also know that it'll never happen.
           | 
           | FWIW, the "no stable kernel ABI" is unique to Linux, although
           | no one really does this like Microsoft (i.e. the BSDs can
           | break between releases, but I do believe NetBSD is superior
           | to FreeBSD in this respect).
        
       | stevekemp wrote:
       | A minor bug-report, if you run "cd /proc/3" you cannot "cd .."
       | afterwards.
       | 
       | It looks like ".." entries don't exist beneath /proc.
        
       | MomsAVoxell wrote:
       | 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?
        
       ___________________________________________________________________
       (page generated 2024-12-06 23:02 UTC)