{"id":13836454,"url":"https://github.com/aesophor/valkyrie","last_synced_at":"2025-04-12T09:40:38.591Z","repository":{"id":43363255,"uuid":"341518807","full_name":"aesophor/valkyrie","owner":"aesophor","description":"🔮 A UNIX-like toy kernel built from scratch which runs on a real rpi3b+, with preemptive multithreading, CoW fork(), VM, VFS, FAT32","archived":false,"fork":false,"pushed_at":"2023-03-19T11:04:07.000Z","size":4708,"stargazers_count":77,"open_issues_count":0,"forks_count":8,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-06T16:50:38.130Z","etag":null,"topics":["aarch64","cpp","cpp20","kernel","nctu","nycu","osdev","osdi"],"latest_commit_sha":null,"homepage":"https://grasslab.github.io/NYCU_Operating_System_Capstone/","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aesophor.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2021-02-23T10:39:32.000Z","updated_at":"2025-03-22T16:55:55.000Z","dependencies_parsed_at":"2024-01-13T17:06:21.618Z","dependency_job_id":null,"html_url":"https://github.com/aesophor/valkyrie","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aesophor%2Fvalkyrie","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aesophor%2Fvalkyrie/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aesophor%2Fvalkyrie/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aesophor%2Fvalkyrie/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aesophor","download_url":"https://codeload.github.com/aesophor/valkyrie/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248548989,"owners_count":21122808,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aarch64","cpp","cpp20","kernel","nctu","nycu","osdev","osdi"],"created_at":"2024-08-04T15:00:45.837Z","updated_at":"2025-04-12T09:40:38.566Z","avatar_url":"https://github.com/aesophor.png","language":"C++","readme":"\u003cdiv align=\"center\"\u003e\n\n\u003ch3\u003eVALKYRIE\u003c/h3\u003e\n\u003cp\u003eA UNIX-like toy kernel built from scratch (for AArch64)\u003c/p\u003e\n\n\u003cimg src=\"/Documentation/cover.png\"\u003e\n\u003c/div\u003e\n\n## Kernel Features\n* Capable of running on a real Raspberry Pi 3B+\n* AArch64 kernel with (user \u0026 kernel) preemptive multi-threading\n* Copy-on-write `fork()`\n* Virtual memory\n* Virtual filesystem (VFS)\n* FAT32 filesystem (supports long filenames)\n* /dev, /proc, /tmp filesystem\n* [Self-made C++ standard library](https://github.com/aesophor/valkyrie/tree/master/include/lib)\n\n## Syscalls\n```cpp\nint sys_read(int fd, void __user *buf, size_t count);\nint sys_write(int fd, const void __user *buf, size_t count);\nint sys_open(const char __user *pathname, int options);\nint sys_close(int fd);\nint sys_fork();\nint sys_exec(const char __user *name, const char __user *argv[]);\n[[noreturn]] void sys_exit(int error_code);\nint sys_getpid();\nint sys_wait(int __user *wstatus);\nint sys_sched_yield();\nlong sys_kill(pid_t pid, int signal);\nint sys_signal(int signal, void(__user *handler)());\nint sys_access(const char __user *pathname, int options);\nint sys_chdir(const char __user *pathname);\nint sys_mkdir(const char __user *pathname);\nint sys_rmdir(const char __user *pathname);\nint sys_unlink(const char __user *pathname);\nint sys_mount(const char __user *device_name, const char __user *mountpoint,\n              const char __user *fs_name);\nint sys_umount(const char __user *mountpoint);\nint sys_mknod(const char __user *pathname, mode_t mode, dev_t dev);\nint sys_getcwd(char __user *buf);\nvoid __user *sys_mmap(void __user *addr, size_t len, int prot, int flags, int fd,\n                      int file_offset);\nint sys_munmap(void __user *addr, size_t len);  // unfinished\n```\n\n## User Programs\n* init\n* login\n* sh\n* ls\n* cat\n* mkdir\n* touch\n* fork_test\n* page_fault_test\n* procfs_test\n* vfs_test_dev\n* vfs_test_mnt\n* vfs_test_orw\n* mmap_illegal_read\n* mmap_illegal_write\n\n## Build valkyrie\n### Build requirements\n* GNU make\n* aarch64 (cross) compiler toolchain\n* qemu-system-aarch64\n\n### Installing ARMv8 (cross) compiler toolchain and QEMU\n```sh\n# Arch Linux (x86_64)\nsudo pacman -S aarch64-linux-gnu-gcc aarch64-linux-gnu-gdb qemu-arch-extra\n\n# macOS (x86_64)\nbrew tap messense/macos-cross-toolchains\nbrew install aarch64-unknown-linux-gnu qemu\n\n# macOS (Apple Silicon)\nbrew install aarch64-elf-gcc aarch64-elf-binutils qemu\n```\n\n### Building valkyrie\n```\ngit clone https://github.com/aesophor/valkyrie\ncd valkyrie\nmake\n```\n\n## Run valkyrie\n### Download `sd.img` from [here](https://drive.google.com/file/d/1oF4iG1EFJrHJnOFz9PepB5tiL2tyRfOY/view?usp=share_link).\nThe `sd.img` file contains:\n* The boot partition (in which `kernel8.img` resides).\n* The root partition (consists of `/bin`, `/usr`, etc).\n* If you wish to run valkyrie in QEMU, then place `sd.img` under the project's root dir.\n* If you wish to run valkyrie on a real rpi3b+, then flash it to your SD card with `dd`.\n\n### Running valkyrie in QEMU\n```\nmake run\n```\n\n### Running valkyrie on a real rpi3b+\nSet up the USB-TO-TTL (USB-TO-SERIAL) Converter\n| RPI3 Pin | USB-TO-TTL Pin |\n| --- | --- |\n| GND | GND |\n| UART0 TX | RXD |\n| UART0 RX | TXD |\n\n![](https://docs.microsoft.com/en-us/windows/iot-core/media/pinmappingsrpi/rp2_pinout.png)\n\n1. Flash `sd.img` to the SD card ([download](https://github.com/aesophor/valkyrie/#download-sdimg-from-here))\n2. Mount the SD card and replace the `kernel8.img` on the SD card with the latest build.\n3. Eject the SD card and plug it into RPI3.\n4. Plug in the USB-TO-TTL converter to your computer\n   - for macOS, run `screen /dev/tty.usbserial-0001 115200`\n   - for linux, run `screen /dev/ttyUSB0 115200`\n\n## References\n* [國立陽明交通大學 資訊科學與工程研究所, Operating System Capstone, Spring 2021](https://grasslab.github.io/NYCU_Operating_System_Capstone/)\n* [Linux](https://github.com/torvalds/linux)\n* [SerenityOS](https://github.com/SerenityOS/serenity)\n* [OS67](https://github.com/SilverRainZ/OS67)\n\n## License\n[GNU General Public License v3](https://github.com/aesophor/valkyrie/blob/309551004/LICENSE)\n","funding_links":[],"categories":["C++"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faesophor%2Fvalkyrie","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faesophor%2Fvalkyrie","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faesophor%2Fvalkyrie/lists"}