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.
- linux: a real world operating system
- xv6: a simple teaching operating system
- circle: contains lots of portable drivers
- s-matyukevich's
- bztsrc's
- 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.
- 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
For Ubuntu 20.04 on x86, just run make init
and skip rest words of this section.
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.
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.
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)
.
make qemu
: Emulate the kernel atobj/kernel8.img
.make
: Create a bootable sd card image atobj/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.
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 is controlled via compiler option -DLOG_XXX
in Makefile, where XXX
can be one of
ERROR
WARN
INFO
DEBUG
TRACE
Defaults to -DLOG_INFO
.
Enabling debug mode via compiler option -DDEBUG
in Makefile will incorportate runtime assertions,
testing and memory usage profiling(see below). Defaults to -DNOT_DEBUG
.
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.
.
├── 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.
- Originally ported by: Hongqing LI, ZhifengHU (2020-2021)
- Maintained by: Xiaoyu HAN, Runyu Peng, Yifan TAN, Zhenliang XUE, Liang ZHANG (2021-2022)