Kernel that only runs an NES emulator
摘要
这是一个极简内核项目,只包含运行 NES 模拟器所需的最小功能,无需操作系统即可启动,没有分页、用户态或任何保护机制,只能运行一个程序,且程序代码与内核一同编译。项目提供 make 构建方式,需 i686 交叉编译器,并附有 mandelbrot、paleta、corazon 三个示例程序。安装可通过 GRUB2 引导 kernel.elf,测试用 QEMU 运行磁盘镜像,可选依赖包括 GRUB2、QEMU、Doxygen 等。文档还说明了启动调用栈、文件夹结构,并包含一份西班牙语的大学报告。
荐读理由
这个极简内核把 NES 模拟器直接编译进内核、无分页无用户态,可作为你研究裸机启动与最小内核设计的现成参考,动手改改就能跑
原文
Introduction
Nintendo Entertainment Kernel is a very basic kernel with only the minimun to run a NES emulator. This means that it can be run without any OS. It does not have pagging nor userspace nor any kind of protection at all. Only one program can be run. It is embedded in the kernel, which means the program's code is compiled alongside the kernel.
Screenshots
Building
You should use make and provide the cross compiler:
PATH=/path/to/crosscompiler/bin:$PATH make kernel program=emulador
If there are not errors, kernel.elf should be in the bin folder.
Examples
Besides "emulador" there are three other working programs:
mandelbrot (shows a explorable fractal)
paleta (shows nes avalaible colors)
corazon (a heart animation using math functions)
All of them can be compiled with the kernel using make.
Ej: make program=examples/mandelbrot
Installing
You may copy kernel.elf to /boot/ and add an entry at /etc/grub.d/40_custom like:
menuentry "nek" {
multiboot /boot/kernel.elf module /boot/initrd.img
}
Remember to update the config file:
sudo grub-mkconfig -o /boot/grub/grub.cfg
Testing
The makefile should run QEMU using the disk image disk.img. A loop device to this file must have been set up in the mount folder.
Dependencies
i686 cross compiler (both C and ASM), like GCC and nasm
GRUB2(optional): Generates .iso (cd image)
QEMU(optional): Emulation
Doxygen and Graphviz (optional): For generating the documentation
grub-mkrescue (optional): For generating a booteable cd image (.iso)
Boot call stack
GRUB (multiboot standard)
kernel/arch/x86/init/boot.s <-- calls c code, initializes stack
kernel_entry() at kernel/arch/x86/init/kernel_entry.c <--base system initilization
kmain() at kernel/kmain.c <--- some services are started
main() at program/main.(c|cpp) <--- main program
Folder Structure
kernel folder has all related to the kernel
kernel/arch code that depends on the architecture
kernel/fs file system(currently only vfs implemented)
fdlibm: a math library downloaded from internet
util/specs: Some useful documents
informe: University report (in spanish)
iso: a few files to generate an .iso with the kernel
util: contains the program to generate the initrd and a few other things
util/fuente: Tools/file used to generate the console font
这条对你有帮助吗?

