pyOS-kernel 0.1.0__tar.gz → 0.2.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-0.2.0/PKG-INFO +143 -0
- pyos_kernel-0.2.0/README.md +116 -0
- pyos_kernel-0.2.0/pyOS_kernel.egg-info/PKG-INFO +143 -0
- {pyos_kernel-0.1.0 → pyos_kernel-0.2.0}/pyOS_kernel.egg-info/SOURCES.txt +27 -7
- {pyos_kernel-0.1.0 → pyos_kernel-0.2.0}/pyOS_kernel.egg-info/requires.txt +0 -2
- {pyos_kernel-0.1.0 → pyos_kernel-0.2.0}/pyos/__init__.py +1 -1
- pyos_kernel-0.2.0/pyos/boot/bootloader.asm +126 -0
- pyos_kernel-0.2.0/pyos/builder.py +266 -0
- pyos_kernel-0.2.0/pyos/cli.py +292 -0
- pyos_kernel-0.2.0/pyos/compiler/codegen.py +204 -0
- pyos_kernel-0.2.0/pyos/debug.py +89 -0
- pyos_kernel-0.2.0/pyos/emulator.py +147 -0
- {pyos_kernel-0.1.0 → pyos_kernel-0.2.0}/pyos/interrupts/handler.py +1 -1
- {pyos_kernel-0.1.0 → pyos_kernel-0.2.0}/pyos/kernel.py +29 -22
- pyos_kernel-0.2.0/pyos/runtime/include/debug.h +20 -0
- pyos_kernel-0.2.0/pyos/runtime/include/heap.h +13 -0
- pyos_kernel-0.2.0/pyos/runtime/include/idt.h +10 -0
- pyos_kernel-0.2.0/pyos/runtime/include/io.h +32 -0
- pyos_kernel-0.2.0/pyos/runtime/include/kernel.h +23 -0
- pyos_kernel-0.2.0/pyos/runtime/include/keyboard.h +24 -0
- pyos_kernel-0.2.0/pyos/runtime/include/pic.h +12 -0
- pyos_kernel-0.2.0/pyos/runtime/include/screen.h +20 -0
- pyos_kernel-0.2.0/pyos/runtime/include/syscall.h +13 -0
- pyos_kernel-0.2.0/pyos/runtime/include/types.h +22 -0
- pyos_kernel-0.2.0/pyos/runtime/linker.ld +33 -0
- pyos_kernel-0.2.0/pyos/runtime/src/debug.c +130 -0
- pyos_kernel-0.2.0/pyos/runtime/src/heap.c +48 -0
- pyos_kernel-0.2.0/pyos/runtime/src/idt.c +156 -0
- pyos_kernel-0.2.0/pyos/runtime/src/isr.S +138 -0
- pyos_kernel-0.2.0/pyos/runtime/src/isr.asm +132 -0
- pyos_kernel-0.2.0/pyos/runtime/src/keyboard.c +110 -0
- pyos_kernel-0.2.0/pyos/runtime/src/kmain.c +50 -0
- pyos_kernel-0.2.0/pyos/runtime/src/pic.c +65 -0
- pyos_kernel-0.2.0/pyos/runtime/src/screen.c +134 -0
- pyos_kernel-0.2.0/pyos/runtime/src/start.S +17 -0
- pyos_kernel-0.2.0/pyos/runtime/src/start.asm +12 -0
- pyos_kernel-0.2.0/pyos/runtime/src/syscall.c +43 -0
- pyos_kernel-0.2.0/pyos/toolchain.py +196 -0
- {pyos_kernel-0.1.0 → pyos_kernel-0.2.0}/pyproject.toml +20 -23
- pyos_kernel-0.2.0/setup.py +3 -0
- pyos_kernel-0.2.0/tests/test_build.py +83 -0
- pyos_kernel-0.1.0/LICENSE +0 -21
- pyos_kernel-0.1.0/MANIFEST.in +0 -5
- pyos_kernel-0.1.0/PKG-INFO +0 -323
- pyos_kernel-0.1.0/README.md +0 -286
- pyos_kernel-0.1.0/examples/advanced_os.py +0 -76
- pyos_kernel-0.1.0/examples/hello_world.py +0 -40
- pyos_kernel-0.1.0/examples/keyboard_input.py +0 -42
- pyos_kernel-0.1.0/pyOS_kernel.egg-info/PKG-INFO +0 -323
- pyos_kernel-0.1.0/pyos/boot/bootloader.asm +0 -174
- pyos_kernel-0.1.0/pyos/builder.py +0 -177
- pyos_kernel-0.1.0/pyos/cli.py +0 -286
- pyos_kernel-0.1.0/pyos/compiler/codegen.py +0 -238
- pyos_kernel-0.1.0/pyos/emulator.py +0 -195
- pyos_kernel-0.1.0/requirements.txt +0 -1
- pyos_kernel-0.1.0/setup.py +0 -19
- {pyos_kernel-0.1.0 → pyos_kernel-0.2.0}/pyOS_kernel.egg-info/dependency_links.txt +0 -0
- {pyos_kernel-0.1.0 → pyos_kernel-0.2.0}/pyOS_kernel.egg-info/entry_points.txt +0 -0
- {pyos_kernel-0.1.0 → pyos_kernel-0.2.0}/pyOS_kernel.egg-info/top_level.txt +0 -0
- {pyos_kernel-0.1.0 → pyos_kernel-0.2.0}/pyos/boot/__init__.py +0 -0
- {pyos_kernel-0.1.0 → pyos_kernel-0.2.0}/pyos/compiler/__init__.py +0 -0
- {pyos_kernel-0.1.0 → pyos_kernel-0.2.0}/pyos/compiler/assembler.py +0 -0
- {pyos_kernel-0.1.0 → pyos_kernel-0.2.0}/pyos/drivers/__init__.py +0 -0
- {pyos_kernel-0.1.0 → pyos_kernel-0.2.0}/pyos/drivers/keyboard.py +0 -0
- {pyos_kernel-0.1.0 → pyos_kernel-0.2.0}/pyos/drivers/screen.py +0 -0
- {pyos_kernel-0.1.0 → pyos_kernel-0.2.0}/pyos/interrupts/__init__.py +0 -0
- {pyos_kernel-0.1.0 → pyos_kernel-0.2.0}/pyos/interrupts/idt.py +0 -0
- {pyos_kernel-0.1.0 → pyos_kernel-0.2.0}/pyos/memory/__init__.py +0 -0
- {pyos_kernel-0.1.0 → pyos_kernel-0.2.0}/pyos/memory/gdt.py +0 -0
- {pyos_kernel-0.1.0 → pyos_kernel-0.2.0}/pyos/memory/manager.py +0 -0
- {pyos_kernel-0.1.0 → pyos_kernel-0.2.0}/pyos/syscalls/__init__.py +0 -0
- {pyos_kernel-0.1.0 → pyos_kernel-0.2.0}/pyos/syscalls/handler.py +0 -0
- {pyos_kernel-0.1.0 → pyos_kernel-0.2.0}/setup.cfg +0 -0
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pyOS-kernel
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Build operating systems in Python — freestanding C runtime + ASM bootloader
|
|
5
|
+
Author-email: i87kxxzz <redtgx32@gmail.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/i87kxxz/pyOS
|
|
8
|
+
Project-URL: Documentation, https://github.com/i87kxxz/pyOS#readme
|
|
9
|
+
Project-URL: Repository, https://github.com/i87kxxz/pyOS
|
|
10
|
+
Project-URL: Issues, https://github.com/i87kxxz/pyOS/issues
|
|
11
|
+
Keywords: operating-system,os,kernel,x86,bootloader,qemu,nasm,systems-programming,cybersecurity
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Topic :: System :: Operating System Kernels
|
|
22
|
+
Requires-Python: >=3.8
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
Requires-Dist: click>=8.0.0
|
|
25
|
+
Provides-Extra: dev
|
|
26
|
+
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
27
|
+
|
|
28
|
+
# pyOS
|
|
29
|
+
|
|
30
|
+
**Build operating systems in Python.** You write a simple Python API; pyOS builds a real freestanding **C kernel** and an **ASM bootloader**, then runs it in QEMU.
|
|
31
|
+
|
|
32
|
+
```text
|
|
33
|
+
Your Python → C glue + C runtime → GCC -m32 ┐
|
|
34
|
+
├→ os.bin → QEMU
|
|
35
|
+
ASM bootloader → NASM ┘
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Requirements (Windows)
|
|
39
|
+
|
|
40
|
+
| Tool | Role | Install |
|
|
41
|
+
|------|------|---------|
|
|
42
|
+
| **MinGW-w64 (GCC)** | Compile C runtime (`-m32`) | `winget install -e --id BrechtSanders.WinLibs.POSIX.UCRT` |
|
|
43
|
+
| **NASM** | Assemble bootloader | `winget install -e --id NASM.NASM` |
|
|
44
|
+
| **QEMU** | Run the OS | `winget install -e --id SoftwareFreedomConservancy.QEMU` |
|
|
45
|
+
|
|
46
|
+
Then verify:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
pyos check
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Install pyOS
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
pip install pyOS-kernel
|
|
56
|
+
# or from source:
|
|
57
|
+
pip install -e .
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Hello World
|
|
61
|
+
|
|
62
|
+
```python
|
|
63
|
+
from pyos import Kernel, Screen
|
|
64
|
+
|
|
65
|
+
kernel = Kernel(arch="x86")
|
|
66
|
+
|
|
67
|
+
@kernel.on_boot
|
|
68
|
+
def main():
|
|
69
|
+
Screen.clear()
|
|
70
|
+
Screen.set_color("green", "black")
|
|
71
|
+
Screen.print("Hello World!")
|
|
72
|
+
|
|
73
|
+
kernel.build("myos.bin")
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
pyos run myos.bin
|
|
78
|
+
pyos debug myos.bin # human-readable serial log / panics
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Keyboard (runtime)
|
|
82
|
+
|
|
83
|
+
```python
|
|
84
|
+
@kernel.on_keypress
|
|
85
|
+
def on_key(key=None):
|
|
86
|
+
pass # enables IRQ1 echo in the C runtime
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## Architecture
|
|
90
|
+
|
|
91
|
+
| Layer | What it does |
|
|
92
|
+
|-------|----------------|
|
|
93
|
+
| **Python API** | `Kernel`, `Screen`, decorators — records intent at build time |
|
|
94
|
+
| **C runtime** | VGA, keyboard, IDT/PIC, heap, syscalls, panic/serial |
|
|
95
|
+
| **ASM** | 16→32-bit bootloader only (`pyos/boot/bootloader.asm`) |
|
|
96
|
+
|
|
97
|
+
pyOS is **not** a full Python-to-machine-code compiler. Boot functions run once at build time; their `Screen.*` operations become C calls into the runtime.
|
|
98
|
+
|
|
99
|
+
## Human debug
|
|
100
|
+
|
|
101
|
+
Panics print clear messages on the serial port (and VGA):
|
|
102
|
+
|
|
103
|
+
```text
|
|
104
|
+
========== pyOS PANIC ==========
|
|
105
|
+
Where : @kernel Screen.print
|
|
106
|
+
Why : Print position is outside the VGA text screen (0..24 rows, 0..79 cols)
|
|
107
|
+
Hint : Pass a valid row/col, or omit them to use the cursor
|
|
108
|
+
Detail: EIP=0x.... (secondary technical detail)
|
|
109
|
+
================================
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
pyos debug myos.bin
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## CLI
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
pyos check
|
|
120
|
+
pyos new myos
|
|
121
|
+
pyos build main.py -o myos.bin
|
|
122
|
+
pyos run myos.bin
|
|
123
|
+
pyos debug myos.bin
|
|
124
|
+
pyos c main.py -o glue.c # inspect generated C glue
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## Examples
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
python examples/hello_world.py
|
|
131
|
+
python examples/keyboard_input.py
|
|
132
|
+
python examples/advanced_os.py
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## Tests
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
python -m pytest tests/ -q
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## License
|
|
142
|
+
|
|
143
|
+
MIT
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
# pyOS
|
|
2
|
+
|
|
3
|
+
**Build operating systems in Python.** You write a simple Python API; pyOS builds a real freestanding **C kernel** and an **ASM bootloader**, then runs it in QEMU.
|
|
4
|
+
|
|
5
|
+
```text
|
|
6
|
+
Your Python → C glue + C runtime → GCC -m32 ┐
|
|
7
|
+
├→ os.bin → QEMU
|
|
8
|
+
ASM bootloader → NASM ┘
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Requirements (Windows)
|
|
12
|
+
|
|
13
|
+
| Tool | Role | Install |
|
|
14
|
+
|------|------|---------|
|
|
15
|
+
| **MinGW-w64 (GCC)** | Compile C runtime (`-m32`) | `winget install -e --id BrechtSanders.WinLibs.POSIX.UCRT` |
|
|
16
|
+
| **NASM** | Assemble bootloader | `winget install -e --id NASM.NASM` |
|
|
17
|
+
| **QEMU** | Run the OS | `winget install -e --id SoftwareFreedomConservancy.QEMU` |
|
|
18
|
+
|
|
19
|
+
Then verify:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
pyos check
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Install pyOS
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
pip install pyOS-kernel
|
|
29
|
+
# or from source:
|
|
30
|
+
pip install -e .
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Hello World
|
|
34
|
+
|
|
35
|
+
```python
|
|
36
|
+
from pyos import Kernel, Screen
|
|
37
|
+
|
|
38
|
+
kernel = Kernel(arch="x86")
|
|
39
|
+
|
|
40
|
+
@kernel.on_boot
|
|
41
|
+
def main():
|
|
42
|
+
Screen.clear()
|
|
43
|
+
Screen.set_color("green", "black")
|
|
44
|
+
Screen.print("Hello World!")
|
|
45
|
+
|
|
46
|
+
kernel.build("myos.bin")
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
pyos run myos.bin
|
|
51
|
+
pyos debug myos.bin # human-readable serial log / panics
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Keyboard (runtime)
|
|
55
|
+
|
|
56
|
+
```python
|
|
57
|
+
@kernel.on_keypress
|
|
58
|
+
def on_key(key=None):
|
|
59
|
+
pass # enables IRQ1 echo in the C runtime
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Architecture
|
|
63
|
+
|
|
64
|
+
| Layer | What it does |
|
|
65
|
+
|-------|----------------|
|
|
66
|
+
| **Python API** | `Kernel`, `Screen`, decorators — records intent at build time |
|
|
67
|
+
| **C runtime** | VGA, keyboard, IDT/PIC, heap, syscalls, panic/serial |
|
|
68
|
+
| **ASM** | 16→32-bit bootloader only (`pyos/boot/bootloader.asm`) |
|
|
69
|
+
|
|
70
|
+
pyOS is **not** a full Python-to-machine-code compiler. Boot functions run once at build time; their `Screen.*` operations become C calls into the runtime.
|
|
71
|
+
|
|
72
|
+
## Human debug
|
|
73
|
+
|
|
74
|
+
Panics print clear messages on the serial port (and VGA):
|
|
75
|
+
|
|
76
|
+
```text
|
|
77
|
+
========== pyOS PANIC ==========
|
|
78
|
+
Where : @kernel Screen.print
|
|
79
|
+
Why : Print position is outside the VGA text screen (0..24 rows, 0..79 cols)
|
|
80
|
+
Hint : Pass a valid row/col, or omit them to use the cursor
|
|
81
|
+
Detail: EIP=0x.... (secondary technical detail)
|
|
82
|
+
================================
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
pyos debug myos.bin
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## CLI
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
pyos check
|
|
93
|
+
pyos new myos
|
|
94
|
+
pyos build main.py -o myos.bin
|
|
95
|
+
pyos run myos.bin
|
|
96
|
+
pyos debug myos.bin
|
|
97
|
+
pyos c main.py -o glue.c # inspect generated C glue
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## Examples
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
python examples/hello_world.py
|
|
104
|
+
python examples/keyboard_input.py
|
|
105
|
+
python examples/advanced_os.py
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Tests
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
python -m pytest tests/ -q
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## License
|
|
115
|
+
|
|
116
|
+
MIT
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pyOS-kernel
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Build operating systems in Python — freestanding C runtime + ASM bootloader
|
|
5
|
+
Author-email: i87kxxzz <redtgx32@gmail.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/i87kxxz/pyOS
|
|
8
|
+
Project-URL: Documentation, https://github.com/i87kxxz/pyOS#readme
|
|
9
|
+
Project-URL: Repository, https://github.com/i87kxxz/pyOS
|
|
10
|
+
Project-URL: Issues, https://github.com/i87kxxz/pyOS/issues
|
|
11
|
+
Keywords: operating-system,os,kernel,x86,bootloader,qemu,nasm,systems-programming,cybersecurity
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Topic :: System :: Operating System Kernels
|
|
22
|
+
Requires-Python: >=3.8
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
Requires-Dist: click>=8.0.0
|
|
25
|
+
Provides-Extra: dev
|
|
26
|
+
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
27
|
+
|
|
28
|
+
# pyOS
|
|
29
|
+
|
|
30
|
+
**Build operating systems in Python.** You write a simple Python API; pyOS builds a real freestanding **C kernel** and an **ASM bootloader**, then runs it in QEMU.
|
|
31
|
+
|
|
32
|
+
```text
|
|
33
|
+
Your Python → C glue + C runtime → GCC -m32 ┐
|
|
34
|
+
├→ os.bin → QEMU
|
|
35
|
+
ASM bootloader → NASM ┘
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Requirements (Windows)
|
|
39
|
+
|
|
40
|
+
| Tool | Role | Install |
|
|
41
|
+
|------|------|---------|
|
|
42
|
+
| **MinGW-w64 (GCC)** | Compile C runtime (`-m32`) | `winget install -e --id BrechtSanders.WinLibs.POSIX.UCRT` |
|
|
43
|
+
| **NASM** | Assemble bootloader | `winget install -e --id NASM.NASM` |
|
|
44
|
+
| **QEMU** | Run the OS | `winget install -e --id SoftwareFreedomConservancy.QEMU` |
|
|
45
|
+
|
|
46
|
+
Then verify:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
pyos check
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Install pyOS
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
pip install pyOS-kernel
|
|
56
|
+
# or from source:
|
|
57
|
+
pip install -e .
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Hello World
|
|
61
|
+
|
|
62
|
+
```python
|
|
63
|
+
from pyos import Kernel, Screen
|
|
64
|
+
|
|
65
|
+
kernel = Kernel(arch="x86")
|
|
66
|
+
|
|
67
|
+
@kernel.on_boot
|
|
68
|
+
def main():
|
|
69
|
+
Screen.clear()
|
|
70
|
+
Screen.set_color("green", "black")
|
|
71
|
+
Screen.print("Hello World!")
|
|
72
|
+
|
|
73
|
+
kernel.build("myos.bin")
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
pyos run myos.bin
|
|
78
|
+
pyos debug myos.bin # human-readable serial log / panics
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Keyboard (runtime)
|
|
82
|
+
|
|
83
|
+
```python
|
|
84
|
+
@kernel.on_keypress
|
|
85
|
+
def on_key(key=None):
|
|
86
|
+
pass # enables IRQ1 echo in the C runtime
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## Architecture
|
|
90
|
+
|
|
91
|
+
| Layer | What it does |
|
|
92
|
+
|-------|----------------|
|
|
93
|
+
| **Python API** | `Kernel`, `Screen`, decorators — records intent at build time |
|
|
94
|
+
| **C runtime** | VGA, keyboard, IDT/PIC, heap, syscalls, panic/serial |
|
|
95
|
+
| **ASM** | 16→32-bit bootloader only (`pyos/boot/bootloader.asm`) |
|
|
96
|
+
|
|
97
|
+
pyOS is **not** a full Python-to-machine-code compiler. Boot functions run once at build time; their `Screen.*` operations become C calls into the runtime.
|
|
98
|
+
|
|
99
|
+
## Human debug
|
|
100
|
+
|
|
101
|
+
Panics print clear messages on the serial port (and VGA):
|
|
102
|
+
|
|
103
|
+
```text
|
|
104
|
+
========== pyOS PANIC ==========
|
|
105
|
+
Where : @kernel Screen.print
|
|
106
|
+
Why : Print position is outside the VGA text screen (0..24 rows, 0..79 cols)
|
|
107
|
+
Hint : Pass a valid row/col, or omit them to use the cursor
|
|
108
|
+
Detail: EIP=0x.... (secondary technical detail)
|
|
109
|
+
================================
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
pyos debug myos.bin
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## CLI
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
pyos check
|
|
120
|
+
pyos new myos
|
|
121
|
+
pyos build main.py -o myos.bin
|
|
122
|
+
pyos run myos.bin
|
|
123
|
+
pyos debug myos.bin
|
|
124
|
+
pyos c main.py -o glue.c # inspect generated C glue
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## Examples
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
python examples/hello_world.py
|
|
131
|
+
python examples/keyboard_input.py
|
|
132
|
+
python examples/advanced_os.py
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## Tests
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
python -m pytest tests/ -q
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## License
|
|
142
|
+
|
|
143
|
+
MIT
|
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
LICENSE
|
|
2
|
-
MANIFEST.in
|
|
3
1
|
README.md
|
|
4
2
|
pyproject.toml
|
|
5
|
-
requirements.txt
|
|
6
3
|
setup.py
|
|
7
|
-
examples/advanced_os.py
|
|
8
|
-
examples/hello_world.py
|
|
9
|
-
examples/keyboard_input.py
|
|
10
4
|
pyOS_kernel.egg-info/PKG-INFO
|
|
11
5
|
pyOS_kernel.egg-info/SOURCES.txt
|
|
12
6
|
pyOS_kernel.egg-info/dependency_links.txt
|
|
@@ -16,8 +10,10 @@ pyOS_kernel.egg-info/top_level.txt
|
|
|
16
10
|
pyos/__init__.py
|
|
17
11
|
pyos/builder.py
|
|
18
12
|
pyos/cli.py
|
|
13
|
+
pyos/debug.py
|
|
19
14
|
pyos/emulator.py
|
|
20
15
|
pyos/kernel.py
|
|
16
|
+
pyos/toolchain.py
|
|
21
17
|
pyos/boot/__init__.py
|
|
22
18
|
pyos/boot/bootloader.asm
|
|
23
19
|
pyos/compiler/__init__.py
|
|
@@ -32,5 +28,29 @@ pyos/interrupts/idt.py
|
|
|
32
28
|
pyos/memory/__init__.py
|
|
33
29
|
pyos/memory/gdt.py
|
|
34
30
|
pyos/memory/manager.py
|
|
31
|
+
pyos/runtime/linker.ld
|
|
32
|
+
pyos/runtime/include/debug.h
|
|
33
|
+
pyos/runtime/include/heap.h
|
|
34
|
+
pyos/runtime/include/idt.h
|
|
35
|
+
pyos/runtime/include/io.h
|
|
36
|
+
pyos/runtime/include/kernel.h
|
|
37
|
+
pyos/runtime/include/keyboard.h
|
|
38
|
+
pyos/runtime/include/pic.h
|
|
39
|
+
pyos/runtime/include/screen.h
|
|
40
|
+
pyos/runtime/include/syscall.h
|
|
41
|
+
pyos/runtime/include/types.h
|
|
42
|
+
pyos/runtime/src/debug.c
|
|
43
|
+
pyos/runtime/src/heap.c
|
|
44
|
+
pyos/runtime/src/idt.c
|
|
45
|
+
pyos/runtime/src/isr.S
|
|
46
|
+
pyos/runtime/src/isr.asm
|
|
47
|
+
pyos/runtime/src/keyboard.c
|
|
48
|
+
pyos/runtime/src/kmain.c
|
|
49
|
+
pyos/runtime/src/pic.c
|
|
50
|
+
pyos/runtime/src/screen.c
|
|
51
|
+
pyos/runtime/src/start.S
|
|
52
|
+
pyos/runtime/src/start.asm
|
|
53
|
+
pyos/runtime/src/syscall.c
|
|
35
54
|
pyos/syscalls/__init__.py
|
|
36
|
-
pyos/syscalls/handler.py
|
|
55
|
+
pyos/syscalls/handler.py
|
|
56
|
+
tests/test_build.py
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
; pyOS Bootloader — LBA (int 13h AH=42h), QEMU-friendly
|
|
2
|
+
[BITS 16]
|
|
3
|
+
[ORG 0x7C00]
|
|
4
|
+
|
|
5
|
+
KERNEL_OFFSET equ 0x1000
|
|
6
|
+
KERNEL_SEGS equ 0x0000
|
|
7
|
+
KERNEL_SECTORS equ 64
|
|
8
|
+
|
|
9
|
+
start:
|
|
10
|
+
cli
|
|
11
|
+
xor ax, ax
|
|
12
|
+
mov ds, ax
|
|
13
|
+
mov es, ax
|
|
14
|
+
mov ss, ax
|
|
15
|
+
mov sp, 0x7C00
|
|
16
|
+
sti
|
|
17
|
+
|
|
18
|
+
mov [boot_drive], dl
|
|
19
|
+
|
|
20
|
+
mov al, 'B'
|
|
21
|
+
out 0xE9, al
|
|
22
|
+
|
|
23
|
+
; Check extensions
|
|
24
|
+
mov ah, 0x41
|
|
25
|
+
mov bx, 0x55AA
|
|
26
|
+
mov dl, [boot_drive]
|
|
27
|
+
int 0x13
|
|
28
|
+
jc .no_lba
|
|
29
|
+
cmp bx, 0xAA55
|
|
30
|
+
jne .no_lba
|
|
31
|
+
|
|
32
|
+
mov al, 'X'
|
|
33
|
+
out 0xE9, al
|
|
34
|
+
|
|
35
|
+
; LBA read: DAP
|
|
36
|
+
mov si, dap
|
|
37
|
+
mov ah, 0x42
|
|
38
|
+
mov dl, [boot_drive]
|
|
39
|
+
int 0x13
|
|
40
|
+
jc .error
|
|
41
|
+
|
|
42
|
+
mov al, 'L'
|
|
43
|
+
out 0xE9, al
|
|
44
|
+
jmp .pm
|
|
45
|
+
|
|
46
|
+
.no_lba:
|
|
47
|
+
; Fallback CHS: one track from sector 2 (17 sectors)
|
|
48
|
+
mov al, 'C'
|
|
49
|
+
out 0xE9, al
|
|
50
|
+
mov ax, KERNEL_SEGS
|
|
51
|
+
mov es, ax
|
|
52
|
+
mov bx, KERNEL_OFFSET
|
|
53
|
+
mov ah, 0x02
|
|
54
|
+
mov al, 17
|
|
55
|
+
mov ch, 0
|
|
56
|
+
mov cl, 2
|
|
57
|
+
mov dh, 0
|
|
58
|
+
mov dl, [boot_drive]
|
|
59
|
+
int 0x13
|
|
60
|
+
jc .error
|
|
61
|
+
mov al, 'L'
|
|
62
|
+
out 0xE9, al
|
|
63
|
+
|
|
64
|
+
.pm:
|
|
65
|
+
cli
|
|
66
|
+
in al, 0x92
|
|
67
|
+
or al, 2
|
|
68
|
+
out 0x92, al
|
|
69
|
+
lgdt [gdt_desc]
|
|
70
|
+
mov eax, cr0
|
|
71
|
+
or eax, 1
|
|
72
|
+
mov cr0, eax
|
|
73
|
+
jmp 0x08:pm_start
|
|
74
|
+
|
|
75
|
+
.error:
|
|
76
|
+
mov al, 'E'
|
|
77
|
+
out 0xE9, al
|
|
78
|
+
jmp $
|
|
79
|
+
|
|
80
|
+
; Disk Address Packet
|
|
81
|
+
align 4
|
|
82
|
+
dap:
|
|
83
|
+
db 16
|
|
84
|
+
db 0
|
|
85
|
+
dw KERNEL_SECTORS
|
|
86
|
+
dw KERNEL_OFFSET
|
|
87
|
+
dw KERNEL_SEGS
|
|
88
|
+
dq 1 ; LBA 1 (sector after MBR)
|
|
89
|
+
|
|
90
|
+
gdt_start:
|
|
91
|
+
dq 0
|
|
92
|
+
gdt_code:
|
|
93
|
+
dw 0xFFFF, 0x0000
|
|
94
|
+
db 0x00, 10011010b, 11001111b, 0x00
|
|
95
|
+
gdt_data:
|
|
96
|
+
dw 0xFFFF, 0x0000
|
|
97
|
+
db 0x00, 10010010b, 11001111b, 0x00
|
|
98
|
+
gdt_end:
|
|
99
|
+
gdt_desc:
|
|
100
|
+
dw gdt_end - gdt_start - 1
|
|
101
|
+
dd gdt_start
|
|
102
|
+
|
|
103
|
+
[BITS 32]
|
|
104
|
+
pm_start:
|
|
105
|
+
mov ax, 0x10
|
|
106
|
+
mov ds, ax
|
|
107
|
+
mov es, ax
|
|
108
|
+
mov fs, ax
|
|
109
|
+
mov gs, ax
|
|
110
|
+
mov ss, ax
|
|
111
|
+
mov esp, 0x90000
|
|
112
|
+
mov al, 'K'
|
|
113
|
+
out 0xE9, al
|
|
114
|
+
call KERNEL_OFFSET
|
|
115
|
+
mov al, 'H'
|
|
116
|
+
out 0xE9, al
|
|
117
|
+
cli
|
|
118
|
+
.halt:
|
|
119
|
+
hlt
|
|
120
|
+
jmp .halt
|
|
121
|
+
|
|
122
|
+
[BITS 16]
|
|
123
|
+
boot_drive: db 0
|
|
124
|
+
|
|
125
|
+
times 510 - ($ - $$) db 0
|
|
126
|
+
dw 0xAA55
|