pyOS-kernel 0.2.0__tar.gz → 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pyos_kernel-1.0.0/LICENSE +21 -0
- pyos_kernel-1.0.0/PKG-INFO +474 -0
- pyos_kernel-1.0.0/README.md +424 -0
- pyos_kernel-1.0.0/pyOS_kernel.egg-info/PKG-INFO +474 -0
- pyos_kernel-1.0.0/pyOS_kernel.egg-info/SOURCES.txt +82 -0
- pyos_kernel-1.0.0/pyos/__init__.py +50 -0
- pyos_kernel-1.0.0/pyos/api/__init__.py +38 -0
- pyos_kernel-1.0.0/pyos/api/errors.py +35 -0
- pyos_kernel-1.0.0/pyos/api/fs.py +46 -0
- {pyos_kernel-0.2.0/pyos/memory → pyos_kernel-1.0.0/pyos/api}/gdt.py +8 -7
- pyos_kernel-1.0.0/pyos/api/idt.py +1 -0
- pyos_kernel-1.0.0/pyos/api/interrupts.py +97 -0
- pyos_kernel-1.0.0/pyos/api/kernel.py +271 -0
- pyos_kernel-1.0.0/pyos/api/keyboard.py +136 -0
- pyos_kernel-1.0.0/pyos/api/memory.py +178 -0
- pyos_kernel-1.0.0/pyos/api/process.py +42 -0
- pyos_kernel-1.0.0/pyos/api/screen.py +235 -0
- pyos_kernel-1.0.0/pyos/api/syscalls.py +82 -0
- {pyos_kernel-0.2.0 → pyos_kernel-1.0.0}/pyos/boot/bootloader.asm +41 -18
- pyos_kernel-1.0.0/pyos/build/__init__.py +7 -0
- {pyos_kernel-0.2.0/pyos → pyos_kernel-1.0.0/pyos/build}/builder.py +91 -86
- pyos_kernel-1.0.0/pyos/build/codegen.py +337 -0
- {pyos_kernel-0.2.0 → pyos_kernel-1.0.0}/pyos/cli.py +5 -5
- {pyos_kernel-0.2.0 → pyos_kernel-1.0.0}/pyos/emulator.py +1 -1
- pyos_kernel-1.0.0/pyos/kernel/__init__.py +1 -0
- pyos_kernel-1.0.0/pyos/kernel/arch/x86/gdt.c +79 -0
- {pyos_kernel-0.2.0/pyos/runtime/src → pyos_kernel-1.0.0/pyos/kernel/arch/x86}/idt.c +2 -1
- pyos_kernel-1.0.0/pyos/kernel/arch/x86/paging.c +45 -0
- {pyos_kernel-0.2.0/pyos/runtime/src → pyos_kernel-1.0.0/pyos/kernel/arch/x86}/start.S +4 -0
- pyos_kernel-1.0.0/pyos/kernel/arch/x86/syscall.c +84 -0
- pyos_kernel-1.0.0/pyos/kernel/arch/x86/usercopy.c +32 -0
- pyos_kernel-1.0.0/pyos/kernel/drivers/floppy.c +19 -0
- {pyos_kernel-0.2.0/pyos/runtime/src → pyos_kernel-1.0.0/pyos/kernel/drivers}/keyboard.c +37 -3
- pyos_kernel-1.0.0/pyos/kernel/drivers/pit.c +54 -0
- {pyos_kernel-0.2.0/pyos/runtime/src → pyos_kernel-1.0.0/pyos/kernel/drivers}/screen.c +34 -0
- pyos_kernel-1.0.0/pyos/kernel/drivers/shell.c +103 -0
- pyos_kernel-1.0.0/pyos/kernel/fs/fat12.c +34 -0
- pyos_kernel-1.0.0/pyos/kernel/fs/ramfs.c +2 -0
- pyos_kernel-1.0.0/pyos/kernel/fs/vfs.c +108 -0
- pyos_kernel-1.0.0/pyos/kernel/include/elf.h +8 -0
- pyos_kernel-1.0.0/pyos/kernel/include/fat12.h +9 -0
- pyos_kernel-1.0.0/pyos/kernel/include/floppy.h +12 -0
- pyos_kernel-1.0.0/pyos/kernel/include/gdt.h +9 -0
- {pyos_kernel-0.2.0/pyos/runtime → pyos_kernel-1.0.0/pyos/kernel}/include/heap.h +4 -0
- {pyos_kernel-0.2.0/pyos/runtime → pyos_kernel-1.0.0/pyos/kernel}/include/kernel.h +10 -2
- {pyos_kernel-0.2.0/pyos/runtime → pyos_kernel-1.0.0/pyos/kernel}/include/keyboard.h +3 -1
- pyos_kernel-1.0.0/pyos/kernel/include/paging.h +11 -0
- {pyos_kernel-0.2.0/pyos/runtime → pyos_kernel-1.0.0/pyos/kernel}/include/pic.h +2 -0
- pyos_kernel-1.0.0/pyos/kernel/include/pmm.h +10 -0
- {pyos_kernel-0.2.0/pyos/runtime → pyos_kernel-1.0.0/pyos/kernel}/include/screen.h +6 -2
- pyos_kernel-1.0.0/pyos/kernel/include/shell.h +11 -0
- pyos_kernel-1.0.0/pyos/kernel/include/string.h +12 -0
- pyos_kernel-1.0.0/pyos/kernel/include/syscall.h +22 -0
- pyos_kernel-1.0.0/pyos/kernel/include/task.h +35 -0
- pyos_kernel-1.0.0/pyos/kernel/include/timer.h +12 -0
- pyos_kernel-1.0.0/pyos/kernel/include/usercopy.h +10 -0
- pyos_kernel-1.0.0/pyos/kernel/include/vfs.h +26 -0
- pyos_kernel-1.0.0/pyos/kernel/kmain.c +78 -0
- {pyos_kernel-0.2.0/pyos/runtime/src → pyos_kernel-1.0.0/pyos/kernel/lib}/debug.c +3 -1
- pyos_kernel-1.0.0/pyos/kernel/lib/string.c +34 -0
- pyos_kernel-1.0.0/pyos/kernel/mm/heap.c +110 -0
- pyos_kernel-1.0.0/pyos/kernel/mm/pmm.c +40 -0
- pyos_kernel-1.0.0/pyos/kernel/proc/elf.c +11 -0
- pyos_kernel-1.0.0/pyos/kernel/proc/task.c +90 -0
- {pyos_kernel-0.2.0 → pyos_kernel-1.0.0}/pyproject.toml +10 -9
- pyos_kernel-0.2.0/PKG-INFO +0 -143
- pyos_kernel-0.2.0/README.md +0 -116
- pyos_kernel-0.2.0/pyOS_kernel.egg-info/PKG-INFO +0 -143
- pyos_kernel-0.2.0/pyOS_kernel.egg-info/SOURCES.txt +0 -56
- pyos_kernel-0.2.0/pyos/__init__.py +0 -22
- pyos_kernel-0.2.0/pyos/compiler/__init__.py +0 -8
- pyos_kernel-0.2.0/pyos/compiler/codegen.py +0 -204
- pyos_kernel-0.2.0/pyos/drivers/__init__.py +0 -8
- pyos_kernel-0.2.0/pyos/drivers/keyboard.py +0 -319
- pyos_kernel-0.2.0/pyos/drivers/screen.py +0 -310
- pyos_kernel-0.2.0/pyos/interrupts/__init__.py +0 -8
- pyos_kernel-0.2.0/pyos/interrupts/handler.py +0 -237
- pyos_kernel-0.2.0/pyos/interrupts/idt.py +0 -165
- pyos_kernel-0.2.0/pyos/kernel.py +0 -295
- pyos_kernel-0.2.0/pyos/memory/__init__.py +0 -8
- pyos_kernel-0.2.0/pyos/memory/manager.py +0 -397
- pyos_kernel-0.2.0/pyos/runtime/include/syscall.h +0 -13
- pyos_kernel-0.2.0/pyos/runtime/src/heap.c +0 -48
- pyos_kernel-0.2.0/pyos/runtime/src/kmain.c +0 -50
- pyos_kernel-0.2.0/pyos/runtime/src/syscall.c +0 -43
- pyos_kernel-0.2.0/pyos/syscalls/__init__.py +0 -7
- pyos_kernel-0.2.0/pyos/syscalls/handler.py +0 -179
- pyos_kernel-0.2.0/tests/test_build.py +0 -83
- {pyos_kernel-0.2.0 → pyos_kernel-1.0.0}/pyOS_kernel.egg-info/dependency_links.txt +0 -0
- {pyos_kernel-0.2.0 → pyos_kernel-1.0.0}/pyOS_kernel.egg-info/entry_points.txt +0 -0
- {pyos_kernel-0.2.0 → pyos_kernel-1.0.0}/pyOS_kernel.egg-info/requires.txt +0 -0
- {pyos_kernel-0.2.0 → pyos_kernel-1.0.0}/pyOS_kernel.egg-info/top_level.txt +0 -0
- {pyos_kernel-0.2.0 → pyos_kernel-1.0.0}/pyos/boot/__init__.py +0 -0
- {pyos_kernel-0.2.0/pyos/compiler → pyos_kernel-1.0.0/pyos/build}/assembler.py +0 -0
- {pyos_kernel-0.2.0/pyos → pyos_kernel-1.0.0/pyos/build}/toolchain.py +0 -0
- {pyos_kernel-0.2.0 → pyos_kernel-1.0.0}/pyos/debug.py +0 -0
- {pyos_kernel-0.2.0/pyos/runtime/src → pyos_kernel-1.0.0/pyos/kernel/arch/x86}/isr.S +0 -0
- {pyos_kernel-0.2.0/pyos/runtime/src → pyos_kernel-1.0.0/pyos/kernel/arch/x86}/isr.asm +0 -0
- {pyos_kernel-0.2.0/pyos/runtime/src → pyos_kernel-1.0.0/pyos/kernel/arch/x86}/pic.c +0 -0
- {pyos_kernel-0.2.0/pyos/runtime/src → pyos_kernel-1.0.0/pyos/kernel/arch/x86}/start.asm +0 -0
- {pyos_kernel-0.2.0/pyos/runtime → pyos_kernel-1.0.0/pyos/kernel}/include/debug.h +0 -0
- {pyos_kernel-0.2.0/pyos/runtime → pyos_kernel-1.0.0/pyos/kernel}/include/idt.h +0 -0
- {pyos_kernel-0.2.0/pyos/runtime → pyos_kernel-1.0.0/pyos/kernel}/include/io.h +0 -0
- {pyos_kernel-0.2.0/pyos/runtime → pyos_kernel-1.0.0/pyos/kernel}/include/types.h +0 -0
- {pyos_kernel-0.2.0/pyos/runtime → pyos_kernel-1.0.0/pyos/kernel}/linker.ld +0 -0
- {pyos_kernel-0.2.0 → pyos_kernel-1.0.0}/setup.cfg +0 -0
- {pyos_kernel-0.2.0 → pyos_kernel-1.0.0}/setup.py +0 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 i87kxxzz
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,474 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pyOS-kernel
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Build real x86 operating systems with a Python DSL — freestanding C kernel + ASM bootloader
|
|
5
|
+
Author-email: i87kxxzz <redtgx32@gmail.com>
|
|
6
|
+
License: MIT License
|
|
7
|
+
|
|
8
|
+
Copyright (c) 2026 i87kxxzz
|
|
9
|
+
|
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
in the Software without restriction, including without limitation the rights
|
|
13
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
15
|
+
furnished to do so, subject to the following conditions:
|
|
16
|
+
|
|
17
|
+
The above copyright notice and this permission notice shall be included in all
|
|
18
|
+
copies or substantial portions of the Software.
|
|
19
|
+
|
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
|
+
SOFTWARE.
|
|
27
|
+
|
|
28
|
+
Project-URL: Homepage, https://github.com/i87kxxz/pyOS
|
|
29
|
+
Project-URL: Documentation, https://github.com/i87kxxz/pyOS#readme
|
|
30
|
+
Project-URL: Repository, https://github.com/i87kxxz/pyOS
|
|
31
|
+
Project-URL: Issues, https://github.com/i87kxxz/pyOS/issues
|
|
32
|
+
Keywords: operating-system,os,kernel,x86,bootloader,qemu,nasm,systems-programming,cybersecurity
|
|
33
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
34
|
+
Classifier: Intended Audience :: Developers
|
|
35
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
36
|
+
Classifier: Programming Language :: Python :: 3
|
|
37
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
38
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
39
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
40
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
41
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
42
|
+
Classifier: Topic :: System :: Operating System Kernels
|
|
43
|
+
Requires-Python: >=3.8
|
|
44
|
+
Description-Content-Type: text/markdown
|
|
45
|
+
License-File: LICENSE
|
|
46
|
+
Requires-Dist: click>=8.0.0
|
|
47
|
+
Provides-Extra: dev
|
|
48
|
+
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
49
|
+
Dynamic: license-file
|
|
50
|
+
|
|
51
|
+
# pyOS
|
|
52
|
+
|
|
53
|
+
**Build a real x86 operating system — in Python.**
|
|
54
|
+
|
|
55
|
+
You write a small, readable Python API.
|
|
56
|
+
pyOS turns it into a freestanding **C kernel** + **ASM bootloader**, then boots it in **QEMU**.
|
|
57
|
+
|
|
58
|
+
```text
|
|
59
|
+
Python DSL ──► C glue + C kernel ──► GCC -m32 ─┐
|
|
60
|
+
├─► os.bin ─► QEMU
|
|
61
|
+
bootloader.asm ──────────────────────► NASM ─┘
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
[](https://pypi.org/project/pyOS-kernel/)
|
|
65
|
+
[](https://pypi.org/project/pyOS-kernel/)
|
|
66
|
+
[](LICENSE)
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
## Table of contents
|
|
71
|
+
|
|
72
|
+
1. [What is pyOS?](#what-is-pyos)
|
|
73
|
+
2. [What it is not](#what-it-is-not)
|
|
74
|
+
3. [Features](#features)
|
|
75
|
+
4. [Requirements](#requirements)
|
|
76
|
+
5. [Install](#install)
|
|
77
|
+
6. [Quick start](#quick-start)
|
|
78
|
+
7. [CLI](#cli)
|
|
79
|
+
8. [API overview](#api-overview)
|
|
80
|
+
9. [Capabilities (flags)](#capabilities-flags)
|
|
81
|
+
10. [Project layout](#project-layout)
|
|
82
|
+
11. [Examples](#examples)
|
|
83
|
+
12. [Guest shell](#guest-shell)
|
|
84
|
+
13. [Debugging](#debugging)
|
|
85
|
+
14. [Tests](#tests)
|
|
86
|
+
15. [Architecture](#architecture)
|
|
87
|
+
16. [Roadmap](#roadmap)
|
|
88
|
+
17. [Security notes](#security-notes)
|
|
89
|
+
18. [Contributing](#contributing)
|
|
90
|
+
19. [License](#license)
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
## What is pyOS?
|
|
95
|
+
|
|
96
|
+
pyOS is a **Python DSL for building real OS kernels**.
|
|
97
|
+
|
|
98
|
+
| Layer | Role |
|
|
99
|
+
|-------|------|
|
|
100
|
+
| **Python** | Describe boot screens, handlers, and features at *build time* |
|
|
101
|
+
| **Codegen** | Emit honest C glue (no silent stubs) |
|
|
102
|
+
| **C kernel** | VGA, keyboard, heap, timer, IDT/PIC, syscalls, paging, tasks, VFS, shell |
|
|
103
|
+
| **ASM** | 16→32-bit bootloader only |
|
|
104
|
+
|
|
105
|
+
Typical flow:
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
pip install pyOS-kernel
|
|
109
|
+
# write main.py with Kernel + Screen
|
|
110
|
+
pyos build main.py -o myos.bin
|
|
111
|
+
pyos run myos.bin
|
|
112
|
+
pyos debug myos.bin
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
---
|
|
116
|
+
|
|
117
|
+
## What it is not
|
|
118
|
+
|
|
119
|
+
- **Not** CPython running inside the kernel
|
|
120
|
+
- **Not** a full Linux clone (no networking stack, no ext4, no SMP yet)
|
|
121
|
+
- **Not** “fake” APIs: unsupported calls raise `CapabilityError` / `UnsupportedOpError`
|
|
122
|
+
|
|
123
|
+
Boot functions run on your **host** during `build()`. Only recorded operations become C calls in the guest.
|
|
124
|
+
|
|
125
|
+
---
|
|
126
|
+
|
|
127
|
+
## Features
|
|
128
|
+
|
|
129
|
+
**Core**
|
|
130
|
+
|
|
131
|
+
- Freestanding **32-bit x86** kernel + floppy boot image
|
|
132
|
+
- VGA text mode (`Screen.clear`, `print`, colors, cursor, scroll)
|
|
133
|
+
- PS/2 keyboard IRQ + optional echo / shell input
|
|
134
|
+
- PIT timer + `@kernel.on_timer`
|
|
135
|
+
- Human-readable **serial panics** (`pyos debug`)
|
|
136
|
+
|
|
137
|
+
**Memory & syscalls**
|
|
138
|
+
|
|
139
|
+
- Free-list **heap** (`malloc` / `free` / `calloc` / `realloc`)
|
|
140
|
+
- Syscalls: `EXIT`, `READ`, `WRITE`, `OPEN`, `CLOSE`, `GETPID`, `MALLOC`, `FREE`, `SLEEP`, `TIME`, `YIELD`, `SPAWN`
|
|
141
|
+
|
|
142
|
+
**Security-oriented building blocks**
|
|
143
|
+
|
|
144
|
+
- Optional **GDT + TSS**
|
|
145
|
+
- Optional **paging** (identity map)
|
|
146
|
+
- `copy_from_user` / range checks when `enable_user_mode=True`
|
|
147
|
+
|
|
148
|
+
**OS services**
|
|
149
|
+
|
|
150
|
+
- Cooperative **process table** + round-robin on IRQ0
|
|
151
|
+
- **VFS / ramfs** + build-time `seed_file(...)`
|
|
152
|
+
- Built-in **shell**: `help`, `ls`, `cat`, `ps`, `free`, `clear`, `echo`
|
|
153
|
+
|
|
154
|
+
---
|
|
155
|
+
|
|
156
|
+
## Requirements
|
|
157
|
+
|
|
158
|
+
| Tool | Why | Install (Windows) |
|
|
159
|
+
|------|-----|-------------------|
|
|
160
|
+
| **Python 3.8+** | DSL + CLI | [python.org](https://www.python.org/) |
|
|
161
|
+
| **MinGW-w64 GCC** (`-m32`) | Compile the C kernel | `winget install -e --id BrechtSanders.WinLibs.POSIX.UCRT` |
|
|
162
|
+
| **NASM** | Assemble the bootloader | `winget install -e --id NASM.NASM` |
|
|
163
|
+
| **QEMU** | Run the OS | `winget install -e --id SoftwareFreedomConservancy.QEMU` |
|
|
164
|
+
|
|
165
|
+
Verify:
|
|
166
|
+
|
|
167
|
+
```bash
|
|
168
|
+
pyos check
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
---
|
|
172
|
+
|
|
173
|
+
## Install
|
|
174
|
+
|
|
175
|
+
**From PyPI**
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
pip install pyOS-kernel
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
**From source (dev)**
|
|
182
|
+
|
|
183
|
+
```bash
|
|
184
|
+
git clone https://github.com/i87kxxz/pyOS.git
|
|
185
|
+
cd pyOS
|
|
186
|
+
pip install -e ".[dev]"
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
---
|
|
190
|
+
|
|
191
|
+
## Quick start
|
|
192
|
+
|
|
193
|
+
```python
|
|
194
|
+
# main.py
|
|
195
|
+
from pyos import Kernel, Screen
|
|
196
|
+
|
|
197
|
+
kernel = Kernel(arch="x86")
|
|
198
|
+
|
|
199
|
+
@kernel.on_boot
|
|
200
|
+
def main():
|
|
201
|
+
Screen.clear()
|
|
202
|
+
Screen.set_color("green", "black")
|
|
203
|
+
Screen.print("Hello from pyOS!")
|
|
204
|
+
Screen.print("Python DSL -> C kernel -> QEMU", row=2)
|
|
205
|
+
|
|
206
|
+
if __name__ == "__main__":
|
|
207
|
+
kernel.build("myos.bin")
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
```bash
|
|
211
|
+
python main.py
|
|
212
|
+
pyos run myos.bin
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
Or with the CLI:
|
|
216
|
+
|
|
217
|
+
```bash
|
|
218
|
+
pyos build main.py -o myos.bin
|
|
219
|
+
pyos run myos.bin
|
|
220
|
+
pyos debug myos.bin
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
---
|
|
224
|
+
|
|
225
|
+
## CLI
|
|
226
|
+
|
|
227
|
+
| Command | Description |
|
|
228
|
+
|---------|-------------|
|
|
229
|
+
| `pyos check` | Verify gcc / nasm / qemu |
|
|
230
|
+
| `pyos new <name>` | Scaffold a new project |
|
|
231
|
+
| `pyos build <file.py> -o out.bin` | Build a bootable image |
|
|
232
|
+
| `pyos run <image.bin>` | Boot in QEMU |
|
|
233
|
+
| `pyos debug <image.bin>` | Headless serial log + panic translation |
|
|
234
|
+
| `pyos c <file.py> -o glue.c` | Inspect generated C glue |
|
|
235
|
+
|
|
236
|
+
---
|
|
237
|
+
|
|
238
|
+
## API overview
|
|
239
|
+
|
|
240
|
+
```python
|
|
241
|
+
from pyos import (
|
|
242
|
+
Kernel, Screen, Keyboard, Memory,
|
|
243
|
+
SysCall, Interrupts, GDT,
|
|
244
|
+
File, Process,
|
|
245
|
+
CapabilityError, UnsupportedOpError,
|
|
246
|
+
)
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
### Boot
|
|
250
|
+
|
|
251
|
+
```python
|
|
252
|
+
kernel = Kernel(arch="x86", heap_size=2*1024*1024)
|
|
253
|
+
|
|
254
|
+
@kernel.on_boot(priority=0)
|
|
255
|
+
def early():
|
|
256
|
+
Screen.clear()
|
|
257
|
+
Screen.print("booting...", row=0)
|
|
258
|
+
|
|
259
|
+
@kernel.on_boot(priority=1)
|
|
260
|
+
def later():
|
|
261
|
+
ptr = Memory.malloc(256)
|
|
262
|
+
Memory.memset(ptr, 0, 256)
|
|
263
|
+
Memory.free(ptr)
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
### Keyboard & timer
|
|
267
|
+
|
|
268
|
+
```python
|
|
269
|
+
@kernel.on_keypress(mode="echo")
|
|
270
|
+
def on_key(key=None):
|
|
271
|
+
pass # enables IRQ1 path; shell handles lines
|
|
272
|
+
|
|
273
|
+
@kernel.on_timer(interval_ms=1000)
|
|
274
|
+
def tick():
|
|
275
|
+
pass
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
### Files (build-time seeds)
|
|
279
|
+
|
|
280
|
+
```python
|
|
281
|
+
kernel = Kernel(arch="x86", enable_filesystem=True)
|
|
282
|
+
kernel.seed_file("motd.txt", "Welcome to pyOS\n")
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
Honest errors:
|
|
286
|
+
|
|
287
|
+
```python
|
|
288
|
+
# raises CapabilityError if filesystem is off
|
|
289
|
+
kernel.seed_file("x.txt", "nope")
|
|
290
|
+
|
|
291
|
+
# raises UnsupportedOpError / ValueError for bad ops / colors / non-ASCII VGA text
|
|
292
|
+
Screen.set_color("not_a_color")
|
|
293
|
+
Screen.print("عربي") # VGA text is ASCII/CP437 only
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
---
|
|
297
|
+
|
|
298
|
+
## Capabilities (flags)
|
|
299
|
+
|
|
300
|
+
Enable real kernel subsystems with constructor flags:
|
|
301
|
+
|
|
302
|
+
```python
|
|
303
|
+
kernel = Kernel(
|
|
304
|
+
arch="x86",
|
|
305
|
+
stack_size=32768,
|
|
306
|
+
heap_size=2 * 1024 * 1024,
|
|
307
|
+
enable_interrupts=True,
|
|
308
|
+
enable_paging=True,
|
|
309
|
+
enable_user_mode=True,
|
|
310
|
+
enable_processes=True,
|
|
311
|
+
enable_filesystem=True,
|
|
312
|
+
debug_level="lab", # or "quiet"
|
|
313
|
+
keypress_mode="echo", # or "custom"
|
|
314
|
+
)
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
| Flag | Effect |
|
|
318
|
+
|------|--------|
|
|
319
|
+
| `enable_interrupts` | IDT + PIC + PIT + syscalls |
|
|
320
|
+
| `enable_paging` | Identity-map paging |
|
|
321
|
+
| `enable_user_mode` | GDT rings + TSS + stricter user copy |
|
|
322
|
+
| `enable_processes` | Task table + IRQ0 round-robin |
|
|
323
|
+
| `enable_filesystem` | VFS/ramfs + `seed_file` |
|
|
324
|
+
|
|
325
|
+
Inspect:
|
|
326
|
+
|
|
327
|
+
```python
|
|
328
|
+
print(kernel.get_info())
|
|
329
|
+
print(kernel.capabilities)
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
---
|
|
333
|
+
|
|
334
|
+
## Project layout
|
|
335
|
+
|
|
336
|
+
```text
|
|
337
|
+
pyos/
|
|
338
|
+
api/ # Python DSL (Kernel, Screen, Memory, ...)
|
|
339
|
+
build/ # codegen, toolchain, floppy builder
|
|
340
|
+
boot/ # ASM bootloader
|
|
341
|
+
kernel/ # freestanding C kernel
|
|
342
|
+
arch/x86/ # GDT, IDT, PIC, paging, syscalls
|
|
343
|
+
mm/ # heap, pmm
|
|
344
|
+
drivers/ # VGA, keyboard, PIT, shell
|
|
345
|
+
proc/ # tasks, ELF helper
|
|
346
|
+
fs/ # VFS, ramfs, seed loader
|
|
347
|
+
lib/ # debug, string
|
|
348
|
+
examples/
|
|
349
|
+
basic/ # hello world, keyboard
|
|
350
|
+
advanced/ # shell, full flags demo
|
|
351
|
+
lab/ # probes (outputs gitignored)
|
|
352
|
+
tests/
|
|
353
|
+
unit/
|
|
354
|
+
integration/
|
|
355
|
+
docs/
|
|
356
|
+
ARCHITECTURE.md
|
|
357
|
+
ROADMAP.md
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
---
|
|
361
|
+
|
|
362
|
+
## Examples
|
|
363
|
+
|
|
364
|
+
```bash
|
|
365
|
+
python examples/basic/hello_world.py
|
|
366
|
+
python examples/basic/keyboard_input.py
|
|
367
|
+
python examples/advanced/shell_echo.py
|
|
368
|
+
python examples/advanced/advanced_os.py
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
---
|
|
372
|
+
|
|
373
|
+
## Guest shell
|
|
374
|
+
|
|
375
|
+
With `@kernel.on_keypress` enabled, type in the QEMU window:
|
|
376
|
+
|
|
377
|
+
| Command | Action |
|
|
378
|
+
|---------|--------|
|
|
379
|
+
| `help` | List commands |
|
|
380
|
+
| `ls` | List VFS files |
|
|
381
|
+
| `cat motd.txt` | Print a seeded file |
|
|
382
|
+
| `ps` | Show tasks |
|
|
383
|
+
| `free` | Heap hint |
|
|
384
|
+
| `clear` | Clear VGA |
|
|
385
|
+
| `echo hi` | Print text |
|
|
386
|
+
|
|
387
|
+
---
|
|
388
|
+
|
|
389
|
+
## Debugging
|
|
390
|
+
|
|
391
|
+
```bash
|
|
392
|
+
pyos debug myos.bin
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
Panics look like:
|
|
396
|
+
|
|
397
|
+
```text
|
|
398
|
+
========== pyOS PANIC ==========
|
|
399
|
+
Where : @kernel Screen.print
|
|
400
|
+
Why : Print position is outside the VGA text screen (0..24 rows, 0..79 cols)
|
|
401
|
+
Hint : Pass a valid row/col, or omit them to use the cursor
|
|
402
|
+
================================
|
|
403
|
+
```
|
|
404
|
+
|
|
405
|
+
Also emitted: `*.symbols.json` and linker `*.map` beside the image.
|
|
406
|
+
|
|
407
|
+
---
|
|
408
|
+
|
|
409
|
+
## Tests
|
|
410
|
+
|
|
411
|
+
```bash
|
|
412
|
+
pip install -e ".[dev]"
|
|
413
|
+
python -m pytest tests/ -q
|
|
414
|
+
```
|
|
415
|
+
|
|
416
|
+
Includes codegen honesty tests and QEMU serial smoke tests.
|
|
417
|
+
|
|
418
|
+
---
|
|
419
|
+
|
|
420
|
+
## Architecture
|
|
421
|
+
|
|
422
|
+
```text
|
|
423
|
+
┌─────────────┐ build-time ┌─────────────┐
|
|
424
|
+
│ Python API │ ──────────────────► │ glue.c │
|
|
425
|
+
└─────────────┘ └──────┬──────┘
|
|
426
|
+
│
|
|
427
|
+
┌─────────────┐ ┌──────▼──────┐
|
|
428
|
+
│ bootloader │ ──────────────────► │ C kernel │
|
|
429
|
+
└─────────────┘ └──────┬──────┘
|
|
430
|
+
│
|
|
431
|
+
┌──────▼──────┐
|
|
432
|
+
│ QEMU i386 │
|
|
433
|
+
└─────────────┘
|
|
434
|
+
```
|
|
435
|
+
|
|
436
|
+
More detail: [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md)
|
|
437
|
+
|
|
438
|
+
---
|
|
439
|
+
|
|
440
|
+
## Roadmap
|
|
441
|
+
|
|
442
|
+
Shipped in **1.0**: honest API, free-list heap, timer, syscalls, paging/GDT hooks, tasks, VFS, shell.
|
|
443
|
+
|
|
444
|
+
Next (Linux-like direction): per-process address spaces, `fork`/`exec`, ELF userland, virtio disk/net, x86_64.
|
|
445
|
+
|
|
446
|
+
See [docs/ROADMAP.md](docs/ROADMAP.md).
|
|
447
|
+
|
|
448
|
+
---
|
|
449
|
+
|
|
450
|
+
## Security notes
|
|
451
|
+
|
|
452
|
+
pyOS is a **lab / teaching / research** kernel:
|
|
453
|
+
|
|
454
|
+
- Default builds are still largely ring0-centric unless you enable user-mode flags
|
|
455
|
+
- Serial debug can leak EIP and boot traces (`debug_level="lab"`)
|
|
456
|
+
- Do not treat guest images as a hardened production OS
|
|
457
|
+
|
|
458
|
+
Report issues: [GitHub Issues](https://github.com/i87kxxz/pyOS/issues)
|
|
459
|
+
|
|
460
|
+
---
|
|
461
|
+
|
|
462
|
+
## Contributing
|
|
463
|
+
|
|
464
|
+
1. Fork & clone
|
|
465
|
+
2. `pip install -e ".[dev]"`
|
|
466
|
+
3. Keep the API **honest** (no silent stubs)
|
|
467
|
+
4. Add tests for new codegen / QEMU behavior
|
|
468
|
+
5. Open a PR
|
|
469
|
+
|
|
470
|
+
---
|
|
471
|
+
|
|
472
|
+
## License
|
|
473
|
+
|
|
474
|
+
MIT © 2026 i87kxxzz — see [LICENSE](LICENSE).
|