toaruos/README.md

167 lines
9.9 KiB
Markdown
Raw Normal View History

2018-10-06 15:28:43 +03:00
# ToaruOS
2018-02-25 11:18:09 +03:00
2021-08-05 04:30:41 +03:00
ToaruOS is a "complete" operating system for x86-64 PCs with plans for ports to other platforms.
2018-10-08 10:56:26 +03:00
2021-08-05 04:30:41 +03:00
While many independent, hobby, and research OSes aim to experiment with new designs, ToaruOS is intended as an educational resource, providing a representative microcosm of functionality found in major desktop operating systems.
The OS includes a kernel, bootloader, dynamic shared object linker, C standard library, its own composited windowing system, a dynamic bytecode-compiled programming language, advanced code editor, and dozens of other utilities and example applications.
2021-10-29 04:57:54 +03:00
There are no external runtime dependencies and all required source code, totalling roughly 100k lines of (primarily) C, is included in this repository, save for [Kuroko](https://github.com/kuroko-lang/kuroko), which lives separately.
2021-08-05 04:30:41 +03:00
2021-10-29 04:57:54 +03:00
![Screenshot](https://klange.dev/s/Screenshot%20from%202021-10-29%2010-44-22.png)
2021-06-17 14:00:08 +03:00
*Demonstration of ToaruOS's UI and some applications.*
2018-10-08 10:56:26 +03:00
## History
2018-02-25 11:18:09 +03:00
2021-08-05 04:30:41 +03:00
ToaruOS has been in development for over ten years, and the goals of the project have changed through out its life time.
When it was initiated in December 2010, the OS was a personal project, and its focus was on the individual learning of its author.
With time, ToaruOS's relatively advanced graphical interface and other features have inspired new hobby OSes, and the goals of the project shifted towards providing a reliable learning resource.
From its initial release through the middle of 2018, ToaruOS's userspace was built on top of the Newlib C standard library implementation as well as various third-party libraries such as Cairo and Freetype.
2018-10-08 10:56:26 +03:00
2021-10-29 04:57:54 +03:00
Since the release of 1.6.x, all third-party runtime dependencies have been removed or replaced, and ToaruOS has been entirely "in-house".
2018-11-01 07:28:29 +03:00
2021-08-05 04:30:41 +03:00
In April 2021, work began on ToaruOS 2.0, which brings a rewritten kernel for x86-64 (and potentially other architectures) and support for SMP. The new "Misaka" kernel was merged upstream at the end of May.
2021-05-31 05:25:37 +03:00
2018-08-21 17:15:29 +03:00
## Features
2021-11-02 01:44:39 +03:00
- **Dynamically linked userspace** with shared libraries and `dlopen`.
2021-06-17 14:00:08 +03:00
- **Composited graphical UI** with software acceleration and a late-2000s design inspiration.
2018-10-14 07:41:29 +03:00
- **VM integration** for absolute mouse and automatic display sizing in VirtualBox and VMware Workstation.
- **Unix-like terminal interface** including a feature-rich terminal emulator and several familiar utilities.
2021-06-07 16:13:01 +03:00
- **Optional third-party ports** including GCC 10.3, Binutils, SDL1.2, Quake, and more.
2018-10-08 10:56:26 +03:00
### Notable Components
2021-08-05 04:30:41 +03:00
- **Misaka** (kernel), [kernel/](kernel/), a hybrid modular kernel, and the core of the operating system.
2021-06-17 14:00:08 +03:00
- **Yutani** (window compositor), [apps/compositor.c](apps/compositor.c), manages window buffers, layout, and input routing.
2021-11-02 01:44:39 +03:00
- **Bim** (text editor), [apps/bim.c](apps/bim.c), is a Vim-inspired editor with syntax highlighting.
- **Terminal**, [apps/terminal.c](apps/terminal.c), xterm-esque terminal emulator with 24-bit color support.
2018-10-08 10:56:26 +03:00
- **ld.so** (dynamic linker/loader), [linker/linker.c](linker/linker.c), loads dynamically-linked ELF binaries.
2021-11-02 01:44:39 +03:00
- **Esh** (shell), [apps/sh.c](apps/sh.c), supports pipes, redirections, variables, etc.
2021-06-17 14:00:08 +03:00
- **Kuroko** (interpreter), [kuroko/](https://kuroko-lang.github.io/), a dynamic bytecode-compiled programming language.
2018-10-08 10:56:26 +03:00
2018-10-08 11:13:38 +03:00
## Current Goals
The following projects are currently in progress:
2021-06-07 16:13:01 +03:00
- **Rewrite the network stack** for greater throughput, stability, and server support.
2021-08-16 12:31:07 +03:00
- **Improve SMP performance** with better scheduling and smarter userspace synchronization functions.
2021-05-31 05:25:37 +03:00
- **Support more hardware** with new device drivers for AHCI, USB, virtio devices, etc.
2021-06-07 16:13:01 +03:00
- **Bring back ports** from ToaruOS "Legacy", like muPDF and Mesa.
2018-11-01 07:28:29 +03:00
- **Improve POSIX coverage** especially in regards to signals, synchronization primitives, as well as by providing more common utilities.
2018-10-08 11:13:38 +03:00
- **Continue to improve the C library** which remains quite incomplete compared to Newlib and is a major source of issues with bringing back old ports.
- **Replace third-party development tools** to get the OS to a state where it is self-hosting with just the addition of a C compiler.
2018-11-01 07:28:29 +03:00
- **Implement a C compiler toolchain** in [toarucc](https://github.com/klange/toarucc).
2018-10-08 11:13:38 +03:00
2018-10-08 10:56:26 +03:00
## Building / Installation
2018-11-16 08:40:01 +03:00
### Building With Docker
2021-06-17 14:00:08 +03:00
General users hoping to build ToaruOS from source are recommended to use our prebuilt Docker image, which contains all the necessary tools:
2018-11-16 08:40:01 +03:00
git clone --recursive https://github.com/klange/toaruos
2018-11-16 09:06:32 +03:00
cd toaruos
2021-05-31 05:25:37 +03:00
docker pull toaruos/build-tools:1.99.x
2021-05-31 09:07:01 +03:00
docker run -v `pwd`:/root/misaka -w /root/misaka -e LANG=C.UTF-8 -t toaruos/build-tools:1.99.x util/build-in-docker.sh
2018-11-16 08:40:01 +03:00
2021-06-17 14:00:08 +03:00
After building like this, you can run the various utility targets (`make run`, etc.). Try `make shell` to run a ToaruOS shell using a serial port with QEMU.
2018-11-16 08:40:01 +03:00
2018-10-08 10:56:26 +03:00
### Build Process Internals
2021-06-17 14:00:08 +03:00
The `Makefile` uses a Kuroko tool, `auto-dep.krk`, to generate additional Makefiles for the userspace applications and libraries, automatically resolving dependencies based on `#include` directives.
2019-01-10 04:30:41 +03:00
2021-06-17 14:00:08 +03:00
In an indeterminate order, the C library, kernel, userspace librares and applications are built, combined into a compressed archive for use as a ramdisk, and then packaged into an ISO9660 filesystem image.
2019-01-10 04:30:41 +03:00
2018-10-08 10:56:26 +03:00
### Project Layout
- **apps** - Userspace applications, all first-party.
- **base** - Ramdisk root filesystem staging directory. Includes C headers in `base/usr/include`, as well as graphical resources for the compositor and window decorator.
- **boot** - BIOS and EFI loader with interactive menus.
2021-11-02 01:44:39 +03:00
- **build** - Auxiliary build scripts for platform ports.
2021-05-31 05:33:34 +03:00
- **kernel** - The Misaka kernel.
2021-06-17 14:00:08 +03:00
- **kuroko** - Submodule checkout of the Kuroko interpreter.
2018-10-08 10:56:26 +03:00
- **lib** - Userspace libraries.
- **libc** - C standard library implementation.
- **linker** - Userspace dynamic linker/loader, implements shared library support.
2021-11-02 01:44:39 +03:00
- **modules** - Loadable driver modules for the kernel.
2018-10-08 10:56:26 +03:00
- **util** - Utility scripts, staging directory for the toolchain (binutils/gcc).
- **.make** - Generated Makefiles.
## Running ToaruOS
2021-11-02 01:44:39 +03:00
### VirtualBox and VMware Workstation
The best end-user experience with ToaruOS will be had in either of these virtual machines, as ToaruOS has support for their automatic display sizing and absolute mouse positioning.
Set up a new VM for an "other" 64-bit guest, supply it with at least 1GiB of RAM, attach the CD image, remove or ignore any hard disks, and select an Intel Gigabit NIC. Two or more CPUs are recommended, as well.
2021-11-02 03:47:37 +03:00
![VirtualBox screenshot](https://klange.dev/s/Screenshot%20from%202021-11-02%2009-44-42.png)
2021-11-02 03:48:24 +03:00
*ToaruOS running in VirtualBox on a Linux host.*
2021-11-02 03:47:37 +03:00
2021-11-02 01:44:39 +03:00
![VMware screenshot](https://klange.dev/s/Screenshot%202021-11-02%20072852.png)
*ToaruOS running in VMware Workstation on a Windows host.*
By default, the bootloader will pass a flag to the VirtualBox device driver to disable "Seamless" support as our implementation has a performance overhead. To enable Seamless mode, use the bootloader menu to check the "VirtualBox Seamless" option before booting. The menu also has options to disable automatic guest display sizing if you experience issues with this feature.
2018-10-08 10:56:26 +03:00
### QEMU
2018-07-21 19:43:58 +03:00
2021-11-02 01:44:39 +03:00
Most development of ToaruOS happens in QEMU, as it provides the most flexibility in hardware and the best debugging experience. A recommended QEMU command line in an Ubuntu 20.04 host is:
2018-07-21 19:43:58 +03:00
```
2021-11-02 01:44:39 +03:00
qemu-system-x86_64 -enable-kvm -m 1G -soundhw ac97 -cdrom image.iso -smp 2
2018-07-22 06:20:25 +03:00
```
2021-11-02 01:44:39 +03:00
Replace `-enable-kvm` with `-accel hvm` or `-accel haxm` as appropriate on host platforms without KVM, or remove it to try under QEMU's TCG software emulation.
Note that QEMU command line options are not stable and these flags may produce warnings in newer versions.
The option `-M q35` will replace the PIIX chipset emulation with a newer one, which has the side effect of switching the IDE controller for a SATA one. This can result in faster boot times at the expense of ToaruOS not being able to read its own CD at runtime until we get around to finishing our AHCI driver.
2021-05-31 05:33:34 +03:00
### Other
2021-11-02 01:44:39 +03:00
ToaruOS has been successfully tested on real hardware. If the native BIOS or EFI loaders fail to function, try booting with Grub. ToaruOS complies with the "Multiboot" and "Multiboot 2" specs so it may be loaded with either the `multiboot` or `multiboot2` commands as follows:
2021-06-17 14:00:08 +03:00
2021-11-02 01:44:39 +03:00
```
multiboot2 /path/to/misaka-kernel root=/dev/ram0 migrate vid=auto start=live-session
module2 /path/to/ramdisk.igz
set gfxpayload=keep
```
2018-10-08 10:56:26 +03:00
2021-11-02 03:47:37 +03:00
![Native photo](https://klange.dev/s/IMG_8387.jpg)
*ToaruOS running natively from a USB stick on a ThinkPad T410.*
2018-10-08 10:56:26 +03:00
## Community
2018-04-23 02:30:05 +03:00
2018-10-08 10:56:26 +03:00
### Mirrors
2018-04-23 02:30:05 +03:00
2018-10-08 10:56:26 +03:00
ToaruOS is regularly mirrored to multiple Git hosting sites.
2018-09-21 07:37:38 +03:00
2018-10-08 10:56:26 +03:00
- Gitlab: [toaruos/toaruos](https://gitlab.com/toaruos/toaruos)
- GitHub: [klange/toaruos](https://github.com/klange/toaruos)
- Bitbucket: [klange/toaruos](https://bitbucket.org/klange/toaruos)
- ToaruOS.org: [klange/toaruos](https://git.toaruos.org/klange/toaruos)
2018-09-21 07:37:38 +03:00
2018-10-08 10:56:26 +03:00
### IRC
2018-09-22 16:37:53 +03:00
2021-05-31 05:25:37 +03:00
`#toaruos` on Libera (`irc.libera.chat`)
2018-09-22 16:37:53 +03:00
2018-10-08 10:56:26 +03:00
## FAQs
2018-07-23 14:11:22 +03:00
2018-10-08 10:56:26 +03:00
### Is ToaruOS self-hosting?
2018-03-19 06:20:40 +03:00
2021-05-31 05:33:34 +03:00
Currently, in the development of ToaruOS 2.0, self-hosting builds have not been tested and some utilities may be missing.
Previously, with a capable compiler toolchain, ToaruOS 1.x was able to build its own kernel, userspace, libraries, and bootloader, and turn these into a working ISO CD image.
2019-01-02 10:34:27 +03:00
2021-05-31 05:33:34 +03:00
ToaruOS is not currently capable of building most of its ports, due to a lack of a proper POSIX shell and Make implementation. These are eventual goals of the project.
2018-03-19 06:20:40 +03:00
2018-10-08 10:56:26 +03:00
### Is ToaruOS a Linux distribution?
2018-08-10 02:26:24 +03:00
2019-01-02 10:34:27 +03:00
ToaruOS is a completely independent project, and all code in this repository - which is the entire codebase of the operating system, including its kernel, bootloaders, libraries, and applications - is original, written by the ToaruOS developers over the course of eight years. The complete source history, going back to when ToaruOS was nothing more than a baremetal "hello world" can be tracked through this git repository.
ToaruOS has taken inspiration from Linux in its choice of binary formats, filesystems, and its approach to kernel modules, but is not derived in any way from Linux code. ToaruOS's userspace is also influenced by the GNU utilities, but does not incorporate any GNU code.
2018-08-10 02:26:24 +03:00