{"id":13626181,"url":"https://github.com/mark-i-m/os2","last_synced_at":"2025-04-11T21:22:56.028Z","repository":{"id":84994924,"uuid":"97073620","full_name":"mark-i-m/os2","owner":"mark-i-m","description":"x86_64 OS kernel with completely async userspace and single address space [WIP; but basic kernel functionality implemented]","archived":false,"fork":false,"pushed_at":"2020-05-24T20:39:04.000Z","size":206,"stargazers_count":31,"open_issues_count":0,"forks_count":4,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-25T17:21:59.561Z","etag":null,"topics":["async","kernel","message-passing","os","osdev","rust","x86-64"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mark-i-m.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":"2017-07-13T02:54:35.000Z","updated_at":"2024-12-14T09:45:27.000Z","dependencies_parsed_at":null,"dependency_job_id":"74d487b8-65ef-44c8-b746-fcae3ca3d2cb","html_url":"https://github.com/mark-i-m/os2","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mark-i-m%2Fos2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mark-i-m%2Fos2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mark-i-m%2Fos2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mark-i-m%2Fos2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mark-i-m","download_url":"https://codeload.github.com/mark-i-m/os2/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248480923,"owners_count":21111044,"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":["async","kernel","message-passing","os","osdev","rust","x86-64"],"created_at":"2024-08-01T21:02:12.329Z","updated_at":"2025-04-11T21:22:56.001Z","avatar_url":"https://github.com/mark-i-m.png","language":"Rust","funding_links":[],"categories":["Rust"],"sub_categories":[],"readme":"# OS2 [WIP]\n\nThis is a small hobby OS to play around with stuff I have never done before...\nit's not intended to be functional, useful, secure, or reliable. It is meant to\nbe approximately fun to implement.\n\nIf you want to see the latest things I am up to, check out the `dev` branch on\nthis repo. Generally, `master` should compile and run.\n\n# WIP\n\n- Start on `librs` (the equivalent of libc for this project).\n    - See `user/src/main.rs` as an example userspace program.\n    - Compile userspace progs with `cargo xbuild --target target.json`\n\n- Paging\n    - `memory::paging::map_region`\n    - Need some way of registering valid memory mappings.\n    - Page fault handler should check that register and allocate a new page if needed.\n\n- Zero-copy message passing for IPC. To send a message,\n    - Remove from sender page tables\n    - Remove from sender TLB\n    - Insert page into receiver page tables\n    - Allow the receiver to fault to map the page. Process receives message via\n      the normal future polling.\n\n- I am toying with the idea of not having processes at all, just DAGs of\n  continuations which may or may not choose to pass on their capabilities.\n\n# Already implemented\n\nCurrently its a little over 1500 LOC (not including comments + whitespace +\ndependencies). Not bad!\n\n- The kernel itself is continuation-based, rather than using something like\n  kthreads. In the first pass, I am just making things work. Later, I might\n  go back and make it efficient.\n\n- No timer-based preemption in kernelspace or userspace (though timer\n  interrupts do occur so that timers can work). No locks, no multi-threading in\n  userspace. Every process is single-threaded and continuation-based. Each\n  `Continuation` can return a set of additional continuations to be run in any\n  order, an error, or nothing. Continuations can also wait for events, such as\n  I/O or another process's termination.\n\n- Single address space. Everything lives in the same address space. Page table\n  entry bits are used to disable certain portions of the address space for some\n  continuations.\n\n- Small kernel heap for dynamic memory allocation.\n\n- Buddy allocator for physical frame allocation.\n\n- Buddy allocator for virtual address space regions.\n\n- Simple capability system for managing access to resources in the system, such\n  as memory regions.\n\n- Switching to usermode and back.\n\n- System calls via `syscall` and `sysret` instructions.\n\n- Loading a position-independent ELF binary as a user-mode task, running it,\n  and exiting via a syscall.\n\n# TODO\n\nNow that I have a mostly functioning basic kernel, I can start playing around\nwith stuff!\n\n- Need a coherent programming model... how does a user process load other tasks?\n- Need to fill out the set of reasonable events.\n- Networking? I've never done that before...\n\n# Building\n\n- rust, nightly\n\n  ```txt\n  rustc 1.45.0-nightly (99cb9ccb9 2020-05-11)\n  ```\n\n- `llvm-tools-preview` rust distribution component via `rustup component add llvm-tools-preview`\n\n- `cargo xbuild` and `cargo bootimage` via `cargo install cargo-xbuild bootimage`\n\n- `build-essentials` and standard utils: `gcc`, `make`, `ld`, `objcopy`, `dd`\n\n- `qemu` to run\n\nTo build and run\n```console\n$ cd os2/user\n$ cargo xbuild --target x86_64-unknown-elf.json --release\n$ cd ../kernel\n$ bootimage run\n```\n\n`bootimage` can optionally be passed `--release` for optimized builds.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmark-i-m%2Fos2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmark-i-m%2Fos2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmark-i-m%2Fos2/lists"}