RISC-V Meaty Skeleton with QEMU virt board

From OSDev.wiki
Jump to navigation Jump to search

This tutorial assumes you have completed RISC-V Bare Bones on the QEMU virt board, or alternatively, HiFive-1 Bare Bones. If not, you should complete them first for an overview of how to boot your own operating system on RISC-V. This tutorial is deliberately brief on concepts that have already been covered in the bare bones tutorials and their transitive prerequisites.

The bare bones tutorials provide minimal examples that are not structured to enable sustainable mid- to long-term development of the codebase. This tutorial attempts to rectify that by providing a well-structured project that should serve you well through your OSDev journey with the following features:

  • Hierarchical project structure with make build system for sustainable mid- to long-term development
  • Includes debug target for debugging with GDB (requires cross-debugger targeting riscv64-elf)
  • Basic console output through NS16550A UART
  • Convenience wrappers for powering off and rebooting the device
  • Working kprintf supporting base format specifiers (no floating point support; no sub-specifiers; no n specifier) to facilitate printf debugging
  • panic function for kernel panics

RISC-V Bare Bones

Main article: RISC-V Bare Bones

It is assumed you have completed RISC-V Bare Bones or another comparable bare bones tutorial. Though not a strict requirement, it is useful for confirming that your development environment works and explaining a few basic things.

We won't be reusing any code from those tutorials though, so throw it away (or save it to an archive) and we'll start over again.