GithubHelp home page GithubHelp logo

vinc / moros Goto Github PK

View Code? Open in Web Editor NEW
778.0 9.0 30.0 1.94 MB

MOROS: Obscure Rust Operating System πŸ¦‰

Home Page: http://moros.cc

License: MIT License

Rust 86.73% Shell 1.25% Makefile 0.42% Python 1.60% Assembly 0.40% HTML 7.92% NewLisp 0.40% Common Lisp 1.08% CSS 0.20%
rust os toy-os hobby-os osdev x86-64 operating-system

moros's Introduction

MOROS: Obscure Rust Operating System

screenshot

MOROS is a hobby operating system written in Rust by Vincent Ollivier.

It targets computers with a x86-64 architecture and a BIOS, so mostly from 2005 to 2020, but it also runs well on most emulators (Bochs, QEMU, and VirtualBox).

This project started from the seventh post of the second edition of Writing an OS in Rust by Philipp Oppermann and by reading the OSDev wiki along with many open source kernels.

GitHub Actions Crates.io

Features

  • External bootloader (using bootloader)
  • x86 CPU support (using x86_64)
  • Hardware interrupts (using pic8259)
  • PS/2 Keyboard with customizable layout (using pc-keyboard)
  • VGA Text mode with customizable font and color palette
  • Serial output (using uart_16550)
  • Paging
  • Heap allocation (using linked_list_allocator)
  • ACPI shutdown (using acpi and aml)
  • RTC clock
  • PCI devices
  • ATA PIO mode
  • Random number generator (using rand_hc)
  • Intel PRO/1000, RTL8139, and AMD PCNET network cards
  • DHCP/IP/TCP/UDP/DNS/HTTP network protocols (using smoltcp)
  • Basic filesystem
  • Basic shell
  • Basic text editor
  • Basic lisp interpreter
  • Basic userspace for NASM and Rust programs
  • Some file and network commands
  • Some games

Documentation

Documentation is available here

Setup

You will need git, gcc, make, curl, qemu-img, and qemu-system-x86_64 on the host system.

Clone the repo:

$ git clone https://github.com/vinc/moros
$ cd moros

Install the required tools with make setup or the following commands:

$ curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain none
$ rustup show
$ cargo install bootimage

Usage

Build the image to disk.img:

$ make image output=video keyboard=qwerty

Run MOROS in QEMU:

$ make qemu output=video nic=rtl8139

Run natively on a x86 computer by copying the bootloader and the kernel to a hard drive or USB stick (but there is currently no USB driver so the filesystem will not be available in that case):

$ sudo dd if=target/x86_64-moros/release/bootimage-moros.bin of=/dev/sdx

MOROS will open a console in diskless mode after boot if no filesystem is detected. The following command will setup the filesystem on a hard drive, allowing you to exit the diskless mode and log in as a normal user:

> install

Be careful not to overwrite the hard drive of your OS when using dd inside your OS, and install or disk format inside MOROS if you don't use an emulator.

Tests

Run the test suite in QEMU:

$ make test

License

MOROS is released under MIT.

moros's People

Contributors

dependabot-preview[bot] avatar dependabot[bot] avatar kamilaborowska avatar kidharb avatar toguyc avatar vinc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

moros's Issues

FS doesn't work after install

Hi, thanks for a good project!
Everything works fine but after I use an 'install' command in diskless mode, and restart my qemu - I got the looped boot.sh with errors.
screenshot - https://drive.google.com/file/d/1iuLKhwqLN3CppegeGOa6RbSPfITV8kdl/view?usp=sharing
So I have a solution but that's not good.
My solution:

  1. make image output=video keyboard=qwerty
  2. make qemu output=video nic=rtl8139
  3. disk format /dev/ata/0/0
  4. goto /
  5. write ini/
  6. edit boot.sh (wrote user login /n shell)
  7. write usr/
  8. user create admin
  9. then "install" command and change again boot.sh file for theme and banner ;/

Taking code from Redox: ReLibC(Rust port of std C)

relibc is a portable POSIX C standard library written in Rust. It is under heavy development, and currently supports Redox(Entirely rust written OS) and Linux.

I think we could take some code from relibc for the LibC implementation of MOROS, there are some other things in their repo I think would be great additions to MOROS, also, their bootloader seems mature enough, though I think Limine also suits for the job pretty well.
Code is at: https://gitlab.redox-os.org/redox-os/relibc
Some awesome code also here: https://gitlab.redox-os.org/redox-os/binutils

Add `-n` and `-e` options to `print`

We could add the -n option (from Unix v7) to avoid printing a trailing newline, and the -e option (from Unix v8) to interpret escape characters like Bash. The latter could also be done automatically by the command (and disabled with -E) like Zsh or by the shell.

https://www.gnu.org/software/bash/manual/bash.html#Bash-Builtins
https://zsh.sourceforge.io/Doc/Release/Shell-Builtin-Commands.html
https://www.cs.dartmouth.edu/~doug/reader.pdf
https://www.everything2.com/title/The+UNIX+and+the+Echo

This should simplify scripting of the socket command:

print -e -n "GET / HTTP/1.1\r\nHost: moros.cc\r\n\r\n" => /tmp/http.cmd
socket moros.cc 80 <= /tmp/http.cmd

Or when pipes will be implemented:

print -e -n "GET / HTTP/1.1\r\nHost: moros.cc\r\n\r\n" -> socket moros.cc 80

Error: MFS is not mounted to '/'

I tried running MOROS in qemu and got this error:

MFS is not mounted to '/'
Running console in diskless mode

Cargo: 1.63.0-nightly (8d42b0e87 2022-06-17)
OS: Ubuntu 22.10
QEMU: 7.0.0 (Debian 1:7.0+dfsg-7ubuntu2)

Freeze when typing

There seems to be a bug introduced recently that freeze the OS when typing sometimes. It may be related to change to the interrupts during sleep.

Should shell redirections truncate or append?

Should print foo => /tmp/bar truncate the file or append to its content?

At the moment we do the former and have no way of doing the latter. We could either introduce a print foo =>> /tmp/bar syntax like in Unix to append to the file, or do it by default and require a delete /tmp/bar first to truncate.

In the first case we will need a seek syscall to move the file offset to the end of the file or OpenFlag::Append to avoid the extra syscall.

Network card error in VirtualBox

A successfully transmitted DHCPDISCOVER message in QEMU looks like this:

> dhcp
DHCP Discover transmitted
------------------------------------------------------------------
[11.543242] NET PCNET Transmitting:
CSR0: 0000000110110011
00000000: FFFF FFFF FFFF 5254 0012 3456 0800 4500 ......RT..4V..E.
00000010: 011D 0000 4000 4011 39D1 0000 0000 FFFF ....@[email protected].......
00000020: FFFF 0044 0043 0109 B92C 0101 0600 0000 ...D.C. .,......
00000030: 0002 0000 0001 0000 0000 0000 0000 0000 ................
00000040: 0000 0000 0000 5254 0012 3456 0000 0000 ......RT..4V....
00000050: 0000 0000 0000 0000 0000 0000 0000 0000 ................
00000060: 0000 0000 0000 0000 0000 0000 0000 0000 ................
00000070: 0000 0000 0000 0000 0000 0000 0000 0000 ................
00000080: 0000 0000 0000 0000 0000 0000 0000 0000 ................
00000090: 0000 0000 0000 0000 0000 0000 0000 0000 ................
000000A0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
000000B0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
000000C0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
000000D0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
000000E0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
000000F0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
00000100: 0000 0000 0000 0000 0000 0000 0000 0000 ................
00000110: 0000 0000 0000 6382 5363 3501 013D 0701 ......c.Sc5..=..
00000120: 5254 0012 3456 3902 0384                RT..4V9...
CSR0: 0000011110110011

And it will look the same in a virtual machine configured with a PCnet-PCI II card in VirtualBox, although with a different MAC address, except the value of CSR0 is not the same after the transmission:

CSR0: 1010001110110011

Bit 13 corresponds to CERR with the following meaning:

Collision Error indicates that the collision inputs to the AUI port failed to activate within 20 network bit times after the chip terminated transmission (SQE Test). This feature is a transceiver test feature. In 10BASE-T mode, CERR will be set after a transmission if the T-MAU is in link fail state. CERR assertion will not result in an interrupt being generated. CERR assertion will set the ERR

UEFI Support

Will it be possible to run the system on uefi in the future?

Userspace & Processes

Hi, i really like your project, I'm also writing a Rust OS based on the Philipp's blog.
Are you waiting like me the posts of userspace and processes/threads or you want to implement them by yourself?

Keep it up.
Marco

Executing a user process breaks network statistics

> net stat
rx: 2 packets (1180 bytes)
tx: 2 packets (620 bytes)

> /bin/hello
Hello, World!

> net stat
rx: 36254196902658239 packets (16192026705920 bytes)
tx: 6278066737626506568 packets (7390416128 bytes)

how to generate dsk/bin files?

I am trying to build a toy OS using rust and wanted to know how did you generate custom reboot/halt binaries? Did you build it from source cause i can see you adding something like MOROS has come to its fate..., How were you able to achieve this?

What's the M

Hi,
I was looking at the code and it's really neat. I just have one question: what's the M in MOROS?

How to use `install` in MOROS

Hello,
I got really afraid after reading

"""

Be careful not to overwrite the hard drive of your OS when using dd
inside your OS, and install or disk format inside MOROS

"""

How should I use install to properly install MOROS in my ~/moros running the image with qemu directory and, by the way, what does dd mean?

MOROS v0.8.0 don't boot on qemu

MOROS
Hi! I'm an osdev too and I have an OS project. I found your project, and when testing, using qemu, with all the necessary parameters, after the second stage of booting, I was already met with a panic. As I tested it over FreeBSD, I don't have KVM, but I don't believe that could have interfered. Are there any specific parameters (such as RAM) needed to start correctly?

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.