GithubHelp home page GithubHelp logo

riojax / mos Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mquy/mos

0.0 0.0 0.0 2.38 MB

A hobby operating system developed from scratch

License: MIT License

Shell 0.97% C 97.59% Assembly 1.15% Makefile 0.29%

mos's Introduction

mOS

license MIT By Vietnamese

mOS is the UNIX-like operating system developed from scratch and aims to be POSIX compliant.

Work-in-process features

  • Filesystem
  • Program loading
  • UI (X11)
  • Log
  • Networking
  • Signal
  • Terminal
  • mOS toolchain
  • Port figlet
  • Libc
  • Port GNU Bash, Coreutils
  • Unit testing
  • Dynamic linker
  • Port GCC (the GNU Compiler Collection)
  • Browser
  • Sound
  • Symmetric multiprocessing

๐Ÿ€ Optional features

  • Setup 2-level paging in boot.asm

Get started

MacOS

  • install packages

    $ brew install qemu nasm gdb i386-elf-gcc i386-elf-grub bochs e2fsprogs xorriso
    
  • open your bash config and add lines below. Depending on your bash config, the file might be different. I use ohmyzsh, so it is .zshrc

    # .zshrc
    alias grub-file=i386-elf-grub-file
    alias grub-mkrescue=i386-elf-grub-mkrescue
    
  • run emulator

    $ cd src && mkdir logs
    $ ./create_image.sh && ./build.sh qemu iso
    
  • open another terminal

    $ cd src
    $ gdb isodir/boot/mos.bin
    # in gdb
    (gdb) target remote localhost:1234
    (gdb) c
    

โœ๐Ÿป If you get this error hdiutil: attach failed - no mountable file systems, installing extFS for MAC might help

Ubuntu

  • Install packakges

    $ sudo apt install build-essential autopoint bison gperf texi2html texinfo qemu automake-1.15 nasm xorriso qemu-system-i386
  • Install gcc cross compilier via https://wiki.osdev.org/GCC_Cross-Compiler#The_Build

  • Install GCC (Version 9.1.0) & Binutils (Version 2.32).

  • Open src/toolchain/build.sh and modify SYSROOT and PREFIX variables to fit in your case

    PREFIX="$HOME/opt/cross"
    TARGET=i386-pc-mos
    # SYSROOT cannot locate inside PREFIX
    SYSROOT="$HOME/Projects/mos/src/toolchain/sysroot"
    JOBCOUNT=$(nproc)
    
  • Install mos toolchain

    $ cd src/toolchain
    $ ./build.sh
    
  • Run Emulator

    $ cd src && mkdir logs
    $ ./create_image.sh
    $ cd ports/figlet && ./package.sh && cd ../..
    $ cd ports/bash && ./package.sh make && cd ../..
    $ cd ports/coreutils && ./package.sh make && cd ../..
    $ ./build.sh qemu iso
    
  • Open another terminal

    $ cd src
    $ gdb isodir/boot/mos.bin
    # in gdb
    (gdb) target remote localhost:1234
    (gdb) c
    

โœ๏ธ To get userspace address for debugging

$ i386-mos-readelf -e program
# find the line below and copy Addr
# [Nr] Name              Type            Addr     Off    Size   ES Flg Lk Inf Al
# [ x] .text             PROGBITS        xxx      xxx    xxx    00 AX   0   0  4

Unit Test

$ cd test && git clone https://github.com/ThrowTheSwitch/Unity.git unity
$ make clean && make

Debugging

in build.sh, adding -s -S right after qemu to switch to debug mode. Currently, I use vscode + native debug -> click Run -> choose "Attach to QEMU"

Monitoring

by default, mOS logs output to terminal. If you want to monitor via file, doing following steps

# src/build.sh#L71
-serial stdio
โ†“
-serial file:logs/uart1.log
$ tail -f serial.log | while read line ; do echo $line ; done

โœ๐Ÿป Using tail in pipe way to color the output (like above) causes a delay -> have to manually save in the IDE to get latest changes

References

Tutorials

Ebooks

mos's People

Contributors

cristeigabriel avatar d3var5h avatar mquy avatar optimisticside avatar sxmxr avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.