What is Escape?
Escape is a 32-Bit Microkernel Operating System for X86, on which I'm working since october 2008. It's implemented in ANSI C, C++ and a bit assembler and most parts of it are UNIX-like. Except that I'm using the bootloader GRUB and some functions for 64-division and -modulo which I borrowed from GCC, the whole OS is developed by myself.The characteristic of Escape is IMO that the kernel provides a VFS (virtual filesystem) that is used for many things. You can get information about the state of the OS (statistics, CPU, memory-usage, ...), access the "real" filesystem, communicate with drivers/services and use pipes. The userspace can't really distingish between virtual files and real files, so the user-applications don't need to worry about the difference.
My goal is not to write an OS that can be used productivly some time (although I don't want to exclude that ;)), but the project is rather an experiment to see what works well and what doesn't and to learn much about operating systems, hardware and in particular the X86-architecture. Of course the OS is not finished yet and therefore not all concepts and implementations are stable.
The name
The name has no real meaning. It came to my mind during the development and I thought it's not bad (at least better than "hrniels-OS" or similar ;)), so I kept it.License
I publish the operating system as open-source under the GPL2Changelog
Version 0.3 (03/04/2010)
- The kernel logs now to /system/log
- The GUI supports 16, 24 and 32 bit colordepth (and arbitrary resolutions)
- GUI-Windows are movable out of the screen (left, right, bottom) and can be resized
- Added a nicer mouse-cursor and font
- The VM86-task is used to query the BIOS for the available VESA-modes and setting a mode => works on all emulators and real machines :)
- Added a VM86-task
- Added a stupid game (raptor) ^^
- German umlaute etc. are usable now
- Added a keymap-driver that acts on top of the keyboard-driver
- The ATAPI-drive used for booting is automatically detected
- Built a simple CLI-editor
- Added a small shell-scripting-language (the syntax isn't perfect yet...I'll try to improve it)
- Added a VESA-textmode (hardcoded atm, no mode-detection)
- Changed pipe-implementation so that pipes are "unlimited" now
- Added a PCI-detection service
- Threads can get arguments now
- Added the ability to retrieve the exit-state of a process
- Added a power-manager for reset and shutdown (shutdown isn't implemented yet)
- Added a ISO9660-fs. Means we can boot from cd and hdd now :)
- Its possible to read from ATAPI now
Version 0.2 (09/16/2009)
- Added the user-apps link, unlink, mkdir, mount and umount
- Mounts are supported now
- Added write-support in the ext2-driver
- Rewrote the escape-code-handling
- Added an idle-thread that uses hlt
- Changed the filesystem-layout: "/foo/bar" instead of "foo:/bar". The URL-like scheme introduced to many special cases
- Added /drivers/zero, null and random
- Rewrote service-system: No "single-pipe"-services anymore, special system-calls for sending and receiving messages, a fixed driver-interface, ...
- Added CPU-detection
- Added multi-threading-support
- Started to build a GUI, based on a C++-GUI-library. Some controls are available and a "GUI-shell" that has the same functionality as the text-shell.
- Added Text-sharing
Version 0.1 (04/10/2009)
- Initial release
General structure
Escape consists of a kernel, that is responsible for processes, threads, memory-management, interrupt-handling, the VFS and so on, services and user-applications. There are three kind of services:- Drivers: The only difference is that they are found at /dev/<name> instead of /services/<name> and that their message-interface is fixed. That means they have to implement this interface in a specific way and the kernel will talk to them via messages. This way the file-operations open,read,write,ioctl and close are passed as messages by the kernel to the corresponding driver, so that the user-applications can use drivers as "normal" files.
- FS: This is a special service because the interface is fixed, too, but different from drivers. Because we need commands like mkdir, rmdir etc., which the drivers don't need. ATM there can be just one of it, which manages mounts, multiple filesystem-types and so on. I not sure if I will change that some time...
- Services: The default ones. They have a custom message-interface and should not be architecture-dependend (ok, ATM there are some that violate this rule, but I'm going to change that ^^). An example is "env" that manages environment-variables for all processes.
Features
Escape has currently the following features:- Kernel
- Kernel-Heap
- Paging (supports copy-on-write)
- Shared memory
- Sharing of code
- Process-management
- Thread-management
- FPU-management
- CPU-detection
- Writing to serial ports
- VM86-task
- Timer, to put threads to sleep and wake them up after a specified number of ms. And of course, preempt threads.
- Round-Robin Scheduler
- IO-port permissions
- Signals. Interrupts are sent to processes via signals, too
- System-calls
- Writing to video-memory (text-mode) for debugging
- VFS
The VFS abstracts the differences between all the stuff you can do with it away so that many similar things can be done with open/read/write/... without user-apps having to worry about what they are talking with. The root-directory consists of virtual and real files/directories. If the kernel notices that a file/dir doesn't exist in the virtual filesystem it assumes that it's a real file/dir (which of course might not be the case, either). The management of the real filesystem is done by the service "fs". The kernel talks to fs via messages if something refers to the real filesystem.
- libc
Many parts of the C-standard-library exists by now. But Escape provides his own API because IMO many functions of the traditional cstdlib have very unintuitive names. Some of the functions/modules that exist:- Strings
- Singly linked list
- Ringbuffer
- Escape-codes
- Time- und date
- opendir, readdir, closedir
- Reading, changing and creating of environment-variables
- Buffered/formated IO: printf, fprintf, scanf, sprintf, fopen, fwrite, fread, ...
- Unbuffered IO: open, read, write, ...
- Heap
- Access to IO-ports
- Process-related: fork, exec, exit, getpid, ...
- Thread-related: startThread, gettid, ...
- Service-related: register, unregister, getWork, ...
- Message-related: send, receive
- Signal-handling
- Reading constant configuration values from the kernel (timer frequency, ...)
- VM86
- libcpp
I've started to build a C++-standard-library but its far from finished :) However, some basic stuff like string, iostreams and vector exists. Additionally I've started to write a GUI-library (that was the main reason for adding C++-support. Because it makes IMO more sense to use OOP for the control-elements etc.). - services/drivers
Currently there are the following services/drivers:- ata: Reading and writing from/to ATA/ATAPI-devices. ATM it supports PIO-mode only (no DMA), LBA28 and LBA48
- cmos: Provides the current date
- env: Manages environment-variables for all processes. They are inherited to child-processes.
- fs: The filesystem. Has a nearly complete ext2-rev0 fs and a iso9660 fs. Additionally it manages mount-points.
- keyboard: Gets notified about keyboard-interrupts, converts the scancodes to keycodes and stores them in a ringbuffer. Other processes can read them
- kmmanager: Keymap-manager. Knows the current keymap (can be changed), reads from keyboard, translates the keycodes to characters and provides them for other processes
- mouse: Gets notified about mouse-interrupts, stores the information in a ring-buffer and gives other processes read-access to them.
- null: Like /dev/null in e.g. Linux
- pci: Checks for available PCI-devices and writes the found ones in the VFS. But the information is not used yet
- powermng: The power-manager for rebooting and shutting down
- random: Like /dev/random in e.g. Linux
- speaker: Produces beeps with the PC-speaker with a specified frequency and duration
- vesa: Reads the supported VESA-modes from BIOS (via VM86), determines the best matching mode and sets it. It creates a shared-memory-region which all GUI-processes use directly. On demand it copies a part of it to the VESA-memory. Additionally one can let VESA draw the mouse-cursor at a specified position
- vesatext: VESA driver for text-mode. Can be used as an alternative to the video-driver (VGA-text)
- video: Can be used to write to the VGA-textmode-memory
- vterm: An abstraction-layer for user-processes. It reads from kmmanager, writes to video and registers multiple virtual terminals as devices. They can be used to read characters or write characters (terminal-like).
- winmanager: Manages all existing windows. Reads from kmmanager and mouse and passes it to the corresponding application. Additionally it can move and resize windows and is responsible for setting the corresponding mouse-cursor (default, resize, ...)
- zero: Like /dev/zero in e.g. Linux
- user
There are quite a few user-programs so that you can do something with Escape ;) The most important ones are:- initloader: Is included in the kernel and is used as the first process. Loads the multiboot-modules (ata and fs because we need them to load other services, drivers and user-apps from the disk). After that it replaces itself with init.
- init: Is responsible for loading the services and shells. Which services should be loaded and which one depends on which other ones is determined by /etc/services. It starts one shell for each vterm.
- shell: The shell creates, if used interactivly, STDIN, STDOUT and STDERR. After that it simply reads commands and executes them. Well, I guess you've expected that ;) It shell implements a small shell-scripting-language-interpreter with pipes, io-redirection, path-expansion, background-jobs, arithmetic, loops, if-statements and variables. Not perfect yet, but a nice to play with :). The interpreter is realized with flex and bison.
- cat, cut, date, dd, dump, grep, kill, less, ln, ls, mkdir, mount, ps, rm, rmdir, sort, stat, sync, time, umount, wc and write: The well-known UNIX-tools. They don't do exactly the same and are, of course, much simpler, but in principle they are intended for the same things.
- edit: A small and simple CLI-editor
- raptor: A game I added just for fun. Yes, I know, its boring ;)
- calc: A small calculator (added to play around with flex&bison before implementing the shell-interpreter :))
- power: for reboot / shutdown. But shutdown isn't finished yet
- keymap: A tool to change the current keymap (us and german are keymaps available)
There are a few C++-apps, too, but they are mostly for testing only atm. Just the GUI-shell can be considered as a more or less serious program.
Additionally there are some libraries that are used by multiple user-apps or services.
Try Escape
If you just want to try it, all you need is a X86-virtualisation/-emulation-software (or a real machine, of course). For example VirtualBox, VMWare, Qemu, Bochs, ...You simply give them the disk- or cd-image and the fun can begin ;)
I have tested Escape in Bochs, Qemu, VMWare, VirtualBox and several real machines.
Qemu
You can start it with Qemu in the following way (or similar):qemu -hda escape-hdd.img
qemu -cdrom escape-cd.img
VirtualBox / VMWare
You have to create a virtual machine and use the VDMK-image or CD-image.Compile/change Escape
Linux or similar is required for it (I'm using Ubuntu 9.10 2.6.31-19-generic). You need the following tools:gcc, nasm, ld, make, gawk and probably some more that I've forgotten :)
You can build and start it with:
make qemu
or:
make bochs
and so on. Take a look at the Makefile for further options.
Downloads
Version 0.1
- Source-Code (449 KiB)
- HDD-Image (520 KiB)
- VMDK-Image (520 KiB)
Version 0.2
- Source-Code (824 KiB)
- HDD-Image (1714 KiB)
- VMDK-Image (1657 KiB)
Version 0.3
- Source-Code (1279 KiB)
- CD-Image (1462 KiB)
- HDD-Image (1445 KiB)
- VMDK-Image (1422 KiB)
Screenshots
Version 0.1
|
After the start: |
Help - part1: |
Help - part2: |
Running processes: |
|
The program ls: |
Playing with the shell ;): |
Read information from VFS: |
Version 0.2
|
Colortable piped through cat: |
Read from driver: |
The root-directory: |
Running processes: |
|
Recursive mounting ^^: |
The GUI (oops..the mouse-pointer is not mine :)): |
The GUI - combobox: |
Version 0.3
|
ATAPI & ISO9660: |
PCI-info: |
VBE-info: |
Processes: |
|
dump /dev/random | less: |
Raptor: |
The shell-scripting-language: |
GUI-shell: |
|
GUI-controls: |
Resizing of windows: |