SwiftOS 是一个完全用 Swift 编写的真实操作系统,包含裸机 aarch64 内核和类似 Linux 的 GUI 桌面,运行在 QEMU virt(Raspberry Pi 5 配置)上。

Stars

84

7 天增长

0

Fork 数

1

开放 Issue

0

开源协议

暂无数据

最近更新

2026-07-18

AI 仓库情报摘要
FR-AI / ANALYSIS

为什么值得关注

它展示了仅用 Swift 从零构建完整操作系统内核和用户空间的可行性,无需任何 Apple 框架或 Linux,包括 SMP、自定义文件系统、网络栈和完整 GUI 桌面环境。

适合谁使用

  • 对基于 Swift 的内核感兴趣的 OS 开发者
  • 探索系统编程的 Swift 爱好者
  • 寻找动手项目的嵌入式系统学习者
  • 希望拥有自包含 OS 学习平台的爱好者

典型使用场景

  • 学习使用 Swift 进行 OS 内核开发
  • 实验自定义文件系统和调度算法
  • 为教育目的构建简单 GUI 桌面环境
  • 测试裸机网络和设备驱动

项目优势

  • 完全自定义的 Swift 代码,从引导到 GUI,无外部依赖
  • 真正的 SMP,支持 4 核抢占式调度
  • 持久化文件系统(SwiftFS)带有元数据日志
  • 完整的网络栈,包括 ARP/IPv4/ICMP/UDP 和 DNS 解析

使用前须知

  • 目前仅支持 QEMU virt(Pi 5 配置),不支持真实硬件
  • 用户空间和驱动仅在 cpu0 上运行;EL0 用户进程和跨核 TLB 刷新为未来工作
  • Unicode 支持仅限于 ASCII,尚无 TCP

README 快速开始

SwiftOS

A real operating system written entirely in Swift — a bare-metal aarch64 kernel (Embedded Swift, no stdlib runtime) with a Linux-feel GUI desktop running on top. Boots on QEMU's virt machine configured to match a Raspberry Pi 5 (8 GB): Cortex-A76, 4 cores, 8 GiB RAM. No Linux, and in the kernel/userland no Apple frameworks at all: every driver, the scheduler, the filesystem, the window manager, the shell, and the renderer are our own Swift.

SwiftOS kernel 1.0.0-aarch64 (Embedded Swift, bare metal)
[boot] exception level EL1
[boot] heap 248 MB
[boot] heap self-test ok
[mmu] identity map on, caches enabled
[gic] timer irq 30 at 100 Hz
[fb] ramfb 1280x800 @ 0x0000000044804000
[blk] virtio-blk (slot 29): 65536 sectors (32 MiB)
[disk] persistent storage online
[sched] scheduler up: main + idle + kworker, quantum 50 ms
[input] virtio tablet (slot 30)
[input] virtio keyboard (slot 31)
[boot] login session started — compositor running

Features

Kernel

  • Device-tree machine discovery (FDT parser): RAM size, CPUs, GIC, UART, fw_cfg, virtio-mmio slots, PSCI method — no hardcoded platform addresses
  • Boot at EL2→EL1, FP/SIMD bring-up on all 4 cores, PL011 UART console
  • Real SMP: all 4 cores schedule threads off a global run queue (baton-locked context switch, per-core 100 Hz ticks and idles, cross-core kill/reap, Linux-style %CPU — smpdemo 3 shows ~300% across cores)
  • Panic broadcast: any core's panic halts the others via IPI
  • MMU + caches identity-mapping the full 8 GiB, 1 GiB kernel heap
  • MMU + caches (identity map), page-bitmap physical allocator + boundary-tag heap backing the Swift runtime's posix_memalign/free
  • GICv2 + ARM generic timer (100 Hz tick), full exception vector table
  • Preemptive round-robin kernel threads (50 ms quantum, context switch in the timer IRQ) with real per-thread CPU accounting
  • Scheduled EL0 user processes (urun): real user-mode threads with per-process L2/L3 page tables, SVC syscall ABI, preemption and migration across cores (per-core page-table pairs + switch-time TLB flush), containment on faults, kill/reap with full teardown
  • virtio-blk storage + SwiftFS, our own filesystem — now with a metadata journal (sector-level redo log, mount-time replay): verified consistent after SIGKILL mid-write, three cycles
  • Networking: virtio-net

相关仓库与替代方案

根据分类、Topic 和编程语言匹配的相似项目。

Blaizzy
精选
Blaizzy GitHub avatar

nativ

Nativ is a native macOS app that lets you run AI models locally on Apple silicon, offering chat, model management, performance analytics, and an OpenAI/Anthropic-compatible API server.

AI 与机器学习AI 视觉与语音
985
uzairansaruzi
精选
uzairansaruzi GitHub avatar

hermex

Hermex is a native SwiftUI iPhone app that lets you control a self-hosted Hermes AI agent directly from your phone, with no subscriptions, tracking, or third-party relay.

AI 与机器学习大语言模型
941
simonw
精选
simonw GitHub avatar

speech-analyzer-cli

A macOS command-line tool that uses Apple's on-device speech APIs to transcribe prerecorded audio into plain text, JSON, JSONL, SRT, or WebVTT.

开发者工具CLI 与终端
20