Skip to content

A teaching operating system (TOS), ported from MIT's xv6, for the kernel experiments at Fudan University.

License

Notifications You must be signed in to change notification settings

SOARingLab/TOS-arm

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

84 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Teaching Operating System (TOS) - arm version

Yet another Unix-like teaching (or toy, if you prefer) operating system kernel for the ARM ISA (named as TOS-arm). It was initially ported from MIT's xv6 for OS Labs at Fudan University (Fall, 2020-2021). It will be maintained and developed for the OS teaching at Fudan.

Tested on Raspberry Pi 3A+, 3B+, 4B, and QEMU.

Reference

What's different?

  • We use musl as user programs libc instead of reinventing one.
  • The set of syscalls supported by our kernel is a subset of linux's.
  • Compared to xv6, we use a queue-based scheduler and hash pid for process sleeping and waking.

Features

  • AArch64 only
  • Basic multi-core support
  • Memory management
  • Virtual memory without swapping
  • Process management
  • Disk driver(EMMC): ported from circle
  • File system: ported from xv6
  • C library: musl
  • Shell: ported from xv6
    • Support argc, envp
    • Support pipe

Prerequisite

For Ubuntu 20.04 on x86, just run make init and skip rest words of this section.

GCC toolchain

If your Linux is running natively on ARMv8 CPU, change CROSS := aarch64-linux-gnu- in config.mk to CROSS := to use local gcc.

If your aarch-linux-gnu-gcc(or gcc) version is less than 9.3.0, remove -mno-outline-atomics from Makefile.

QEMU

You can install QEMU from your package manager or compile it from source such as

git clone https://github.com/qemu/qemu.git
mkdir -p qemu/build
(cd qemu/build && ../configure --target-list=aarch64-softmmu && make -j8)

On some OS such as openEuler or CentOS, you may also need to install the following dependencies

yum install ninja-build
yum install pixman-devel.aarch64

Then add the generated qemu-system-aarch64 to PATH or just modify the QEMU variable in config.mk.

Build musl

First, fetch musl by git submodule update --init --recursive.

Then if you are cross compiling, run (cd libc && export CROSS_COMPILE=aarch64-linux-gnu- && ./configure --target=aarch64). Otherwise, run (cd libc && ./configure).

Development

  • make qemu: Emulate the kernel at obj/kernel8.img.
  • make: Create a bootable sd card image at obj/sd.img for Raspberry Pi 3, which can be burned to a tf card using Raspberry Pi Imager.
  • make lint: Lint source code of kernel and user programs.

Raspberry Pi 4

It works on Pi 4 as well. Change RASPI := 3 to RASPI := 4 in Makefile, run make clean && make and have fun with your Pi 4.

Logging level

Logging level is controlled via compiler option -DLOG_XXX in Makefile, where XXX can be one of

  • ERROR
  • WARN
  • INFO
  • DEBUG
  • TRACE

Defaults to -DLOG_INFO.

Debug mode

Enabling debug mode via compiler option -DDEBUG in Makefile will incorportate runtime assertions, testing and memory usage profiling(see below). Defaults to -DNOT_DEBUG.

Profile

We can inspect the information of processes and memory usage(shown when -DDEBUG) by Ctrl+P. This may output something like

1 sleep  init
2 run    idle
3 runble idle
4 run    idle
5 run    idle
6 sleep  sh fa: 1  

where each row contains the pid, state, name and father's pid of each process.

Project structure

.
├── Makefile
├── mksd.mk: Part of Makefile for generating bootable image.
|
├── boot: Official boot loader.
├── libc: C library musl.
|
├── inc: Kernel headers.
├── kern: Kernel source code.
└── usr: User programs.

Credit

  • Originally ported by: Hongqing LI, ZhifengHU (2020-2021)
  • Maintained by: Xiaoyu HAN, Runyu Peng, Yifan TAN, Zhenliang XUE, Liang ZHANG (2021-2022)

About

A teaching operating system (TOS), ported from MIT's xv6, for the kernel experiments at Fudan University.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 93.9%
  • Assembly 3.8%
  • Makefile 2.0%
  • Other 0.3%