All Projects → brenns10 → Sos

brenns10 / Sos

Home-made almost operating system

Programming Languages

c
50402 projects - #5 most used programming language
assembly
5116 projects

Labels

Projects that are alternatives of or similar to Sos

Mylinux
myLinux is a small UNIX like OS for embedded systems based on Westermo NetBox
Stars: ✭ 53 (-7.02%)
Mutual labels:  arm, qemu
Shecc
A self-hosting and educational C compiler
Stars: ✭ 286 (+401.75%)
Mutual labels:  arm, qemu
m3forth
m3forth is a forth cross-compiler for cortex-m3 ARM microcontrollers
Stars: ✭ 16 (-71.93%)
Mutual labels:  arm, qemu
mdepx
MDEPX — A BSD-style RTOS
Stars: ✭ 17 (-70.18%)
Mutual labels:  arm, qemu
Floppybird
Floppy Bird (OS)
Stars: ✭ 836 (+1366.67%)
Mutual labels:  os, qemu
how-to-qemu-arm-gdb-gtest
How to run, debug, and unit test ARM code on X86 ubuntu
Stars: ✭ 19 (-66.67%)
Mutual labels:  arm, qemu
Efifs
EFI FileSystem drivers
Stars: ✭ 272 (+377.19%)
Mutual labels:  arm, qemu
tupai
Tupai is a multi-tasking operating system I wrote for my degree that focuses on safety and design, targeting a variety of platforms.
Stars: ✭ 21 (-63.16%)
Mutual labels:  arm, os
Arm now
arm_now is a qemu powered tool that allows instant setup of virtual machines on arm cpu, mips, powerpc, nios2, x86 and more, for reverse, exploit, fuzzing and programming purpose.
Stars: ✭ 719 (+1161.4%)
Mutual labels:  arm, qemu
30daymakeos
《30天自制操作系统》源码中文版。自己制作一个操作系统(OSASK)的过程
Stars: ✭ 4,127 (+7140.35%)
Mutual labels:  os, qemu
kernel
Main kernel tree
Stars: ✭ 28 (-50.88%)
Mutual labels:  arm, os
Prettyos
A Preemptive Hard Real Time kernel for embedded devices.
Stars: ✭ 36 (-36.84%)
Mutual labels:  arm, os
chaos-2
A hand-made SMP-aware kernel
Stars: ✭ 20 (-64.91%)
Mutual labels:  os, qemu
nixos-on-arm
Cross Compiling NixOS to ARM as a replacement for Yocto
Stars: ✭ 129 (+126.32%)
Mutual labels:  arm, os
DemOS
Free, simple, extremely lightweight, stackless, cooperative, co-routine system (OS) for microcontrollers
Stars: ✭ 18 (-68.42%)
Mutual labels:  arm, os
GENADEV OS
An AArch64 hobbyist OS for the Raspberry Pi 3 B+
Stars: ✭ 14 (-75.44%)
Mutual labels:  arm, os
toddler
Toddler is a well-designed usable and portable microkernel OS
Stars: ✭ 70 (+22.81%)
Mutual labels:  arm, os
Aqeous
(Inactive, Checkout AvanaOS, Rewrite of this) This is a New Operating System (Kernel right now). Made completely from scratch, We aim to make a complete OS for Learning purpose
Stars: ✭ 23 (-59.65%)
Mutual labels:  os, qemu
Frankenstein
Broadcom and Cypress firmware emulation for fuzzing and further full-stack debugging
Stars: ✭ 285 (+400%)
Mutual labels:  arm, qemu
Fasmg Ebc
An EFI Byte Code (EBC) assembler, based on fasmg
Stars: ✭ 17 (-70.18%)
Mutual labels:  arm, qemu

SOS (Stephen's OS)

builds.sr.ht status

This is my personal operating system project. It targets the 32-bit ARMv7-A architecture. The main target board is qemu, but progress is being made on the Raspberry Pi 4B target! Despite being very imited, this one-person project has actually made a great deal of progress and continues to improve.

Instructions

To build and run this, you need two important pieces of software: QEMU 4.2+, and an ARM cross compiler. These dependencies are straightforward on Arch Linux, but Ubuntu users should see more detailed setup instructions in Ubuntu.md.

Some additional dependencies which get installed by the following command:

  • pytest: a python testing framework, used to implement integration tests. You can skip this if you're not planning to run integration tests.
  • mtools: tools which create and manage MS-DOS FAT12/16/32 volumes. These are automatically used by the integration test framework, but also are useful for creating your own filesystem image. However, a few dummy FS images are included in this repo, so it is not strictly necessary.
# Arch Linux
$ sudo pacman -Sy arm-none-eabi-gcc arm-none-eabi-binutils arm-none-eabi-gdb \
      qemu qemu-arch-extra python-pytest mtools

With these dependencies satisfied, you can do the following:

# First, configure SOS to run in a VM:
make config_qemu

# Then, either build & run the OS in a VM:
make run
# or...

# Run in debug mode, which allows stepping through code in GDB:
make debug
# (in another terminal)
make gdb
# or...

# Run unit tests (which exercise just the C code) plus integration tests
# (which start SOS in a VM and then test command functionality)
make test

Raspberry Pi 4B

This OS is growing support for the Raspberry Pi 4B. So far, SOS can boot into a simple kernel shell (which is not backed by kernel threads or a scheduler yet). For more information on setup and running, see [docs/RaspberryPi.md][].

Demo

After starting up the VM, you should see something like this:

SOS: Startup
Stephen's OS (user shell, pid=2)
ush>

This is a shell running as a user-space process. It has very few features, except to launch rudimentary processes. The best demonstration of what the OS can do is to look at the output of the "demo" command. The "demo" command starts up 10 instances of the same program, which looks like this:

int main()
{
        uint32_t i, j;
        int pid = getpid();

        for (i = 0; i < 8; i++) {
                printf("[pid=%u] Hello world, via system call, #%u\n", pid, i);

                /* do some busy waiting so we see more context switching */
                for (j = 0; j < 300000; j++) {
                        asm("nop");
                }
        }

        return 0;
}

In other words, each process starts up, prints a message (including it's identifier), and busy-waits a while. This is the (partial) output of the demo:

[pid=11] Hello world, via system call, #0
[pid=11] Hello world, via system call, #1
[pid=10] Hello world, via system call, #0
[pid=10] Hello world, via system call, #1
[pid=10] Hello world, via system call, #2
[pid=9] Hello world, via system call, #0
[pid=9] Hello world, via system call, #1
[pid=9] Hello world, via system call, #2
[pid=8] Hello world, via system call, #0
[pid=8] Hello world, via system call, #1
[pid=8] Hello world, via system call, #2
[pid=8] Hello world, via system call, #3

As each process executes, occasionally the operating system's timer interrupt will trigger a context switch to a different process. We see this by the fact that messages from multiple processes are interleaved. This demonstrates, at a high level, that this OS can do pre-emptive multi-tasking.

Some Features

Here is a longer list of things my OS can do:

  • Text I/O over PL011 UART. (see kernel/uart.c)
    • Input is interrupt driven, to avoid polling & busy waiting
  • A small, limited printf implementation. (see lib/format.c)
  • ARM MMU configured to provide separate address space for each process. (see both kernel/startup.s and kernel/kmem.c)
  • A simple first-fit memory allocator for allocating pages of memory (see lib/alloc.c)
  • A few system calls: display(), getchar(), getpid(), exit(). (see kernel/syscall.c)
  • Driver for ARM generic timer, with a tick configured at 100Hz (kernel/timer.c)
  • Driver for ARM generic interrupt controller, and interrupt handling supported. (see kernel/gic.c)
  • Processes (if that wasn't already clear), with the following attributes:
    • Run in ARM user mode
    • Memory layout:
      • 0x0-0x40000000 - kernel space - no access
      • 0x40000000+ - userspace
      • Each process has a separate user address space
    • Interact with the world via system calls
    • Pre-emptive multi tasking (thanks to timer interrupt)
    • Scheduled via a round-robin scheduler
  • Driver for a virtio block device (see kernel/virtio-net.c) and some very basic functionality which uses it.
  • Driver for a virtio network device (see kernel/virtio-net.c) and some very basic functionality which uses it.
  • FAT filesystem driver (currently only supports FAT12)

Some Limitations

Here are some odd limitations:

  • Only one process can read from the UART at a time. If two processes try to read and are put in the waiting state, the first one will be put to sleep and never re-scheduled.
  • Most memory aborts are handled by some form of kernel panic, so a userspace segfault will bring down the whole system.
  • There's no filesystem, so every possible program is compiled into the kernel, and copied into userspace.
  • Processes cannot expand their address space.

Here are a bunch of things to add support for, or improve:

  • Implement a filesystem
  • Dynamic memory for processes
  • ELF parsing
  • Better DTB parsing, use it to determine peripherals
  • Decent networking subsystem
  • Implement UDP sockets
  • Implement TCP?

Editor config

For editing code, I would recommend running the following periodically to generate a compile_commands.json file:

pip install --user compiledb  # do this just once
compiledb -n make all

With this done, you should be able to use a C language server (e.g. clangd, which I've verified to work) and client (e.g. vim-lsp, emacs, vscode). This will enable things like jump-to-definition, code completion, and renaming.

Resources

Here are some non-official resources I have found useful during this project:

  • Baking Pi is a series of tutorials about writing bare metal programs for Raspberry Pi. I followed this for a while before starting this project, so it influenced me a lot. It's a lot of fun and has lots of great information.
  • This Stanford course website has a lot of labs and references. For some of my earlier questions, it just kept popping up on Google, and it's really good.
  • Bare-metal programming for ARM helped a me get interrupts working. This book has a fairly narrow focus, but I found it quite well-written and helpful for the topics it did cover.

Here are some of the official standards and specifications I've relied on:

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].