| kernel | initial commit | |
| .gdbinit | initial commit | |
| Makefile | feat: specify c23 as the c standard in makefile | |
| README.md | doc: added links to sh manuals in README.md | |
SUX: Superh Unix
This is a simple unix-like operating system for the superh CPU architecture. It currently supports only the r2d qemu board.
Roadmap
- Serial Output
- Virtual Memory
- Traps & System Calls
- Scheduling
- Filesystem
- Graphics
- Networking
- Dreamcast port
- Porting software
- GCC Toolchain
- Text editor eg. vi, ed
- Doom
Building
First, you will need a sh4-elf cross-compiler
$ make
To run the OS in qemu:
$ make qemu-run
Cross-Compiler
Prerequisites
In order to build GNU binutils and GCC, you need the following dependencies:
autotoolsandmakebisonflexlibgmp3-devlibmpc-devlibmpfr-devtexinfolibcloog
Dowonload and extract the latest versions of binutils, gcc, and gdb if you plan to build it, see [#GDB].
The PREFIX environment variable is the location where gcc & binutils will be
installed.
export PREFIX="/your/path/to/cross/compiler"
You can set it to $HOME/.local/cross, and load it in your .profile like
this: Note, putting in in .profile, will require you to re-login. To avoid
this, you can place it in .bashrc, .zshrc, or whatever shell config you
have.
export PATH="$HOME/.local/cross:$PATH"
Binutils
Create a build directory alongside the extracted binutils source code. Do not create it in the binutils source code directory.
mkdir binutils-objdir
cd binutils-objdir
Replace $version with the binutils version you have dowonloaded.
../binutils-$version/configure -v --target=sh4-elf --prefix="$PREFIX" --with-sysroot --disable-werror --disable-libssp --disable-tls --disable-shared --enable-static --disable-nls
make -j$(nproc)
make install
GCC
As with binutils, we create a build directory alongside the source code of gcc.
mkdir gcc-objdir
cd gcc-objdir
Then, compile gcc. Replace $version with your gcc version.
../gcc-$version/configure -v --target=sh4-elf --prefix="$PREFIX" --enable-checking=release --enable-languages=c --with-cpu=m4-single-only --with-multilib-list=m4-single-only,m4-nofpu,m4 --with-endian=little --without-headers --disable-libssp --disable-tls --disable-shared --enable-static --disable-nls
make all-gcc -j$(nproc)
make all-target-libgcc -j$(nproc)
make install-gcc
make install-target-libgcc
GDB
Some linux distributions provide a gdb-multiarch package that you can use
instead. Just set set architecture sh when you start it. The provided
.gdbinit file already sets it.
If you want to compile gdb, the process is similar to gcc.
You will need some extra dependencies:
libncurses-devlibsource-highlight-dev
mkdir gdb-objdir
cd gdb-objdir
../gdb-$version/configure --target=sh4-elf --host=x86_64-linux-gnu --prefix="$PREFIX" --disable-werror --enable-tui --enable-source-highlight
make all-gdb -j$(nproc)
make install-gdb
See also
- SH4 Software Manual
- SH7750 Series Hardware Manual
- Xv6 The primary inspiration for this project
- 50 years in filesystems: 1974