moros/README.md

107 lines
3.4 KiB
Markdown
Raw Normal View History

2020-01-29 22:16:15 +00:00
# MOROS: Obscure Rust Operating System
2019-12-28 17:08:11 +00:00
![screenshot](doc/moros.png)
MOROS is a hobby operating system written in Rust by [Vincent Ollivier](https://vinc.cc).
2020-11-14 21:09:08 +00:00
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).
Add network stack (#12) * Display MAC address * Add kernel::pci::find_device * Mask lower bits of 16-bit Memory Space BAR * Use array instead of vector for MAC address * Split interrupts module * Use IRQ constants instead of InterruptIndex enum * Replace kernel::sleep by kernel::time * Add kernel::idt::set_irq_handler * Add interrupt handler for RTL8139 * Enable bus mastering for RTL8139 * Setup NIC * Add features for vga/serial and qwerty/dvorak * Add smoltcp crate * Use EthernetAddress from smoltcp * Add RTL8139 struct to implement smoltcp Device * Save detected device * Add kernel::mem::translate_addr * Use physical address of rx_buffer * Add command to read raw network data * Parse packet header and length * Fix missing ascii on last line * Take CRC into account for packet length * Fix compilation error * Move buffer pointers after packet received * Use buffer slice instead of clone in RxToken * Add packet transmission and dhcp client * Configure network interface with DHCP client * Add debug mode to network interface * Clean dhcp command output * Add ip command * Clean up commands output * Count number of packets transmitted and received * Add route command * Add kernel::random::rand16 * Handle carriage return char * Add HTTP client * Improve http command output * Add DNS resolver command * Parse DNS responses to A IN queries * Resolve http host * Check if interface is ready before operations * Add timeout to polling loops * Fix sleep during polling * Add verbose arg to http command * Add State struct to Device struct * Add subcommand config and dump to net command * Add MTU to RX_BUFFER_LEN when using WRAP * Fix first transmission index * Refactor TxToken implementation * Add user agent to http requests * Add more comments to code * Add llvm-tools-preview component to readme * Add method to translate IRQ into system interrupt * Clear IRQ mask in set_irq_handler * Refactor driver code * Sleep less rather than more * Add rand32 * Disable RTL8139 interrupts * Use arrays instead of vectors for buffers * Add minimum sleep duration * Add phy_addr to dry init * Use CAPR and CBR to compute rx buffer offset * Add debug for alloc issue with continuous physical memory * Fix timeout in loops * Add unused buffer to push the rx buffer into contiguous memory * Add doc about network * Update readme * Add read /net/<proto>/<host>/<path> subcommand
2020-02-02 17:55:20 +00:00
2020-02-02 18:22:27 +00:00
This project started from the [seventh post][1] of the second edition of
[Writing an OS in Rust][2] by Philipp Oppermann and by reading the
[OSDev wiki][3] along with many open source kernels.
[![Travis](https://img.shields.io/travis/vinc/moros/master.svg)](https://travis-ci.org/vinc/moros/branches)
[![Crates.io](https://img.shields.io/crates/v/moros.svg)](https://crates.io/crates/moros)
2022-08-28 15:26:13 +00:00
2020-02-02 18:22:27 +00:00
## Features
Add network stack (#12) * Display MAC address * Add kernel::pci::find_device * Mask lower bits of 16-bit Memory Space BAR * Use array instead of vector for MAC address * Split interrupts module * Use IRQ constants instead of InterruptIndex enum * Replace kernel::sleep by kernel::time * Add kernel::idt::set_irq_handler * Add interrupt handler for RTL8139 * Enable bus mastering for RTL8139 * Setup NIC * Add features for vga/serial and qwerty/dvorak * Add smoltcp crate * Use EthernetAddress from smoltcp * Add RTL8139 struct to implement smoltcp Device * Save detected device * Add kernel::mem::translate_addr * Use physical address of rx_buffer * Add command to read raw network data * Parse packet header and length * Fix missing ascii on last line * Take CRC into account for packet length * Fix compilation error * Move buffer pointers after packet received * Use buffer slice instead of clone in RxToken * Add packet transmission and dhcp client * Configure network interface with DHCP client * Add debug mode to network interface * Clean dhcp command output * Add ip command * Clean up commands output * Count number of packets transmitted and received * Add route command * Add kernel::random::rand16 * Handle carriage return char * Add HTTP client * Improve http command output * Add DNS resolver command * Parse DNS responses to A IN queries * Resolve http host * Check if interface is ready before operations * Add timeout to polling loops * Fix sleep during polling * Add verbose arg to http command * Add State struct to Device struct * Add subcommand config and dump to net command * Add MTU to RX_BUFFER_LEN when using WRAP * Fix first transmission index * Refactor TxToken implementation * Add user agent to http requests * Add more comments to code * Add llvm-tools-preview component to readme * Add method to translate IRQ into system interrupt * Clear IRQ mask in set_irq_handler * Refactor driver code * Sleep less rather than more * Add rand32 * Disable RTL8139 interrupts * Use arrays instead of vectors for buffers * Add minimum sleep duration * Add phy_addr to dry init * Use CAPR and CBR to compute rx buffer offset * Add debug for alloc issue with continuous physical memory * Fix timeout in loops * Add unused buffer to push the rx buffer into contiguous memory * Add doc about network * Update readme * Add read /net/<proto>/<host>/<path> subcommand
2020-02-02 17:55:20 +00:00
2020-02-02 18:22:27 +00:00
- [x] External bootloader (using [bootloader](https://github.com/rust-osdev/bootloader))
- [x] x86 CPU support (using [x86_64](https://crates.io/crates/x86_64))
2021-06-27 14:32:47 +00:00
- [x] Hardware interrupts (using [pic8259](https://crates.io/crates/pic8259))
- [x] PS/2 Keyboard with customizable layout (using [pc-keyboard](https://crates.io/crates/pc-keyboard))
- [x] VGA Text mode with customizable font and color palette
2020-02-02 18:22:27 +00:00
- [x] Serial output (using [uart_16550](https://crates.io/crates/uart_16550))
Add network stack (#12) * Display MAC address * Add kernel::pci::find_device * Mask lower bits of 16-bit Memory Space BAR * Use array instead of vector for MAC address * Split interrupts module * Use IRQ constants instead of InterruptIndex enum * Replace kernel::sleep by kernel::time * Add kernel::idt::set_irq_handler * Add interrupt handler for RTL8139 * Enable bus mastering for RTL8139 * Setup NIC * Add features for vga/serial and qwerty/dvorak * Add smoltcp crate * Use EthernetAddress from smoltcp * Add RTL8139 struct to implement smoltcp Device * Save detected device * Add kernel::mem::translate_addr * Use physical address of rx_buffer * Add command to read raw network data * Parse packet header and length * Fix missing ascii on last line * Take CRC into account for packet length * Fix compilation error * Move buffer pointers after packet received * Use buffer slice instead of clone in RxToken * Add packet transmission and dhcp client * Configure network interface with DHCP client * Add debug mode to network interface * Clean dhcp command output * Add ip command * Clean up commands output * Count number of packets transmitted and received * Add route command * Add kernel::random::rand16 * Handle carriage return char * Add HTTP client * Improve http command output * Add DNS resolver command * Parse DNS responses to A IN queries * Resolve http host * Check if interface is ready before operations * Add timeout to polling loops * Fix sleep during polling * Add verbose arg to http command * Add State struct to Device struct * Add subcommand config and dump to net command * Add MTU to RX_BUFFER_LEN when using WRAP * Fix first transmission index * Refactor TxToken implementation * Add user agent to http requests * Add more comments to code * Add llvm-tools-preview component to readme * Add method to translate IRQ into system interrupt * Clear IRQ mask in set_irq_handler * Refactor driver code * Sleep less rather than more * Add rand32 * Disable RTL8139 interrupts * Use arrays instead of vectors for buffers * Add minimum sleep duration * Add phy_addr to dry init * Use CAPR and CBR to compute rx buffer offset * Add debug for alloc issue with continuous physical memory * Fix timeout in loops * Add unused buffer to push the rx buffer into contiguous memory * Add doc about network * Update readme * Add read /net/<proto>/<host>/<path> subcommand
2020-02-02 17:55:20 +00:00
- [x] Paging
2020-02-02 18:22:27 +00:00
- [x] Heap allocation (using [linked_list_allocator](https://crates.io/crates/linked_list_allocator))
- [x] ACPI shutdown (using [acpi](https://crates.io/crates/acpi) and [aml](https://crates.io/crates/aml))
Add network stack (#12) * Display MAC address * Add kernel::pci::find_device * Mask lower bits of 16-bit Memory Space BAR * Use array instead of vector for MAC address * Split interrupts module * Use IRQ constants instead of InterruptIndex enum * Replace kernel::sleep by kernel::time * Add kernel::idt::set_irq_handler * Add interrupt handler for RTL8139 * Enable bus mastering for RTL8139 * Setup NIC * Add features for vga/serial and qwerty/dvorak * Add smoltcp crate * Use EthernetAddress from smoltcp * Add RTL8139 struct to implement smoltcp Device * Save detected device * Add kernel::mem::translate_addr * Use physical address of rx_buffer * Add command to read raw network data * Parse packet header and length * Fix missing ascii on last line * Take CRC into account for packet length * Fix compilation error * Move buffer pointers after packet received * Use buffer slice instead of clone in RxToken * Add packet transmission and dhcp client * Configure network interface with DHCP client * Add debug mode to network interface * Clean dhcp command output * Add ip command * Clean up commands output * Count number of packets transmitted and received * Add route command * Add kernel::random::rand16 * Handle carriage return char * Add HTTP client * Improve http command output * Add DNS resolver command * Parse DNS responses to A IN queries * Resolve http host * Check if interface is ready before operations * Add timeout to polling loops * Fix sleep during polling * Add verbose arg to http command * Add State struct to Device struct * Add subcommand config and dump to net command * Add MTU to RX_BUFFER_LEN when using WRAP * Fix first transmission index * Refactor TxToken implementation * Add user agent to http requests * Add more comments to code * Add llvm-tools-preview component to readme * Add method to translate IRQ into system interrupt * Clear IRQ mask in set_irq_handler * Refactor driver code * Sleep less rather than more * Add rand32 * Disable RTL8139 interrupts * Use arrays instead of vectors for buffers * Add minimum sleep duration * Add phy_addr to dry init * Use CAPR and CBR to compute rx buffer offset * Add debug for alloc issue with continuous physical memory * Fix timeout in loops * Add unused buffer to push the rx buffer into contiguous memory * Add doc about network * Update readme * Add read /net/<proto>/<host>/<path> subcommand
2020-02-02 17:55:20 +00:00
- [x] RTC clock
- [x] PCI devices
Add network stack (#12) * Display MAC address * Add kernel::pci::find_device * Mask lower bits of 16-bit Memory Space BAR * Use array instead of vector for MAC address * Split interrupts module * Use IRQ constants instead of InterruptIndex enum * Replace kernel::sleep by kernel::time * Add kernel::idt::set_irq_handler * Add interrupt handler for RTL8139 * Enable bus mastering for RTL8139 * Setup NIC * Add features for vga/serial and qwerty/dvorak * Add smoltcp crate * Use EthernetAddress from smoltcp * Add RTL8139 struct to implement smoltcp Device * Save detected device * Add kernel::mem::translate_addr * Use physical address of rx_buffer * Add command to read raw network data * Parse packet header and length * Fix missing ascii on last line * Take CRC into account for packet length * Fix compilation error * Move buffer pointers after packet received * Use buffer slice instead of clone in RxToken * Add packet transmission and dhcp client * Configure network interface with DHCP client * Add debug mode to network interface * Clean dhcp command output * Add ip command * Clean up commands output * Count number of packets transmitted and received * Add route command * Add kernel::random::rand16 * Handle carriage return char * Add HTTP client * Improve http command output * Add DNS resolver command * Parse DNS responses to A IN queries * Resolve http host * Check if interface is ready before operations * Add timeout to polling loops * Fix sleep during polling * Add verbose arg to http command * Add State struct to Device struct * Add subcommand config and dump to net command * Add MTU to RX_BUFFER_LEN when using WRAP * Fix first transmission index * Refactor TxToken implementation * Add user agent to http requests * Add more comments to code * Add llvm-tools-preview component to readme * Add method to translate IRQ into system interrupt * Clear IRQ mask in set_irq_handler * Refactor driver code * Sleep less rather than more * Add rand32 * Disable RTL8139 interrupts * Use arrays instead of vectors for buffers * Add minimum sleep duration * Add phy_addr to dry init * Use CAPR and CBR to compute rx buffer offset * Add debug for alloc issue with continuous physical memory * Fix timeout in loops * Add unused buffer to push the rx buffer into contiguous memory * Add doc about network * Update readme * Add read /net/<proto>/<host>/<path> subcommand
2020-02-02 17:55:20 +00:00
- [x] ATA PIO mode
2022-07-02 05:16:58 +00:00
- [x] Random number generator (using [rand_hc](https://crates.io/crates/rand_hc))
Add network stack (#12) * Display MAC address * Add kernel::pci::find_device * Mask lower bits of 16-bit Memory Space BAR * Use array instead of vector for MAC address * Split interrupts module * Use IRQ constants instead of InterruptIndex enum * Replace kernel::sleep by kernel::time * Add kernel::idt::set_irq_handler * Add interrupt handler for RTL8139 * Enable bus mastering for RTL8139 * Setup NIC * Add features for vga/serial and qwerty/dvorak * Add smoltcp crate * Use EthernetAddress from smoltcp * Add RTL8139 struct to implement smoltcp Device * Save detected device * Add kernel::mem::translate_addr * Use physical address of rx_buffer * Add command to read raw network data * Parse packet header and length * Fix missing ascii on last line * Take CRC into account for packet length * Fix compilation error * Move buffer pointers after packet received * Use buffer slice instead of clone in RxToken * Add packet transmission and dhcp client * Configure network interface with DHCP client * Add debug mode to network interface * Clean dhcp command output * Add ip command * Clean up commands output * Count number of packets transmitted and received * Add route command * Add kernel::random::rand16 * Handle carriage return char * Add HTTP client * Improve http command output * Add DNS resolver command * Parse DNS responses to A IN queries * Resolve http host * Check if interface is ready before operations * Add timeout to polling loops * Fix sleep during polling * Add verbose arg to http command * Add State struct to Device struct * Add subcommand config and dump to net command * Add MTU to RX_BUFFER_LEN when using WRAP * Fix first transmission index * Refactor TxToken implementation * Add user agent to http requests * Add more comments to code * Add llvm-tools-preview component to readme * Add method to translate IRQ into system interrupt * Clear IRQ mask in set_irq_handler * Refactor driver code * Sleep less rather than more * Add rand32 * Disable RTL8139 interrupts * Use arrays instead of vectors for buffers * Add minimum sleep duration * Add phy_addr to dry init * Use CAPR and CBR to compute rx buffer offset * Add debug for alloc issue with continuous physical memory * Fix timeout in loops * Add unused buffer to push the rx buffer into contiguous memory * Add doc about network * Update readme * Add read /net/<proto>/<host>/<path> subcommand
2020-02-02 17:55:20 +00:00
- [x] RTL8139 network card
- [x] AMD PCNET network card
- [x] DHCP/IP/TCP/UDP/DNS/HTTP network protocols (using [smoltcp](https://crates.io/crates/smoltcp))
- [x] Basic [filesystem](doc/filesystem.md)
- [x] Basic [shell](doc/shell.md)
- [x] Basic [text editor](doc/editor.md)
- [x] Basic [lisp](doc/lisp.md) interpreter
- [x] Basic file and [network](doc/network.md) commands
2022-06-16 17:42:10 +00:00
- [x] Basic userspace for NASM and Rust programs without alloc
- [ ] Multitasking
- [ ] C standard library port
## Documentation
Documentation is available [here](doc/index.md)
2019-12-29 10:16:59 +00:00
2020-02-03 20:18:06 +00:00
## Setup
2019-12-28 17:08:11 +00:00
Clone the repo:
$ git clone https://github.com/vinc/moros
$ cd moros
Install the required tools with `make setup` or the following commands:
2019-12-28 17:08:11 +00:00
$ curl https://sh.rustup.rs -sSf | sh
$ rustup install nightly
$ rustup default nightly
$ cargo install bootimage
2019-12-28 17:08:11 +00:00
2020-02-03 20:18:06 +00:00
## Usage
2020-11-14 21:05:05 +00:00
Build the image to `disk.img`:
2020-01-15 21:33:48 +00:00
$ make image output=video keyboard=qwerty
2020-01-15 21:33:48 +00:00
2020-11-14 21:05:05 +00:00
Run MOROS in QEMU:
2020-01-15 21:33:48 +00:00
$ make qemu output=video nic=rtl8139
2020-02-03 20:18:06 +00:00
2020-11-14 21:05:05 +00:00
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):
2020-01-15 21:33:48 +00:00
$ sudo dd if=target/x86_64-moros/release/bootimage-moros.bin of=/dev/sdx && sync
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
2019-12-29 10:16:59 +00:00
2020-02-15 09:52:49 +00:00
**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.**
2019-12-29 10:16:59 +00:00
2020-11-14 21:05:05 +00:00
## Tests
Run the test suite in QEMU:
$ make test
2022-08-28 15:26:13 +00:00
## License
2019-12-29 10:16:59 +00:00
MOROS is released under MIT.
[1]: https://github.com/phil-opp/blog_os/tree/post-07
[2]: https://os.phil-opp.com
2020-02-02 18:22:27 +00:00
[3]: https://wiki.osdev.org