Need help with mos?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

MQuy
155 Stars 12 Forks MIT License 371 Commits 0 Opened issues

Description

A hobby operating system developed from scratch

Services available

!
?

Need anything else?

Contributors list

# 33,178
fake-co...
faker-g...
C
Webpack
356 commits
# 40,319
shell-s...
Shell
Bash
bible
2 commits

mOS

license MIT By Vietnamese

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

Work-in-process features

  • [x] Filesystem
  • [x] Program loading
  • [x] UI (X11)
  • [x] Log
  • [x] Networking
  • [x] Signal
  • [x] Terminal
  • [x] mOS toolchain
  • [x] Port figlet
  • [x] Libc
  • [x] 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. Depends on your bash, config 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 gcc cross compilier via https://wiki.osdev.org/GCCCross-Compiler#TheBuild

  • 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
  • Run Emulator
  $ cd src && mkdir logs
  $ ./create_image.sh
  $ cd src/ports/bash && ./package.sh
  $ cd src/ports/coreutils && ./package.sh
  $ ./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

Debuging

in

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

Monitoring

by default mOS log outputs 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 saving in ide to get latest changes

References

Tutorials

  • http://www.brokenthorn.com/Resources
  • http://www.jamesmolloy.co.uk/tutorial_html/
  • https://wiki.osdev.org

Ebooks

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.