Skip to content

Commit 5c0d097

Browse files
committed
update
1 parent 0baf988 commit 5c0d097

32 files changed

Lines changed: 755 additions & 183 deletions

‎.github/workflows/ci.yml‎

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout repository
15+
uses: actions/checkout@v4
16+
# Repo must contain both xdv-os and dust (e.g. dustlang monorepo)
17+
18+
- name: Install NASM
19+
run: sudo apt-get update && sudo apt-get install -y nasm
20+
21+
- name: Install Rust
22+
uses: dtolnay/rust-toolchain@stable
23+
24+
- name: Build dust compiler
25+
run: |
26+
if [ -d dust ]; then
27+
cd dust && cargo build --release 2>/dev/null || cargo build
28+
else
29+
echo "No dust/ in repo; assuming dust is on PATH or will be built by build.sh"
30+
fi
31+
32+
- name: Build xdv-os (dust + NASM)
33+
run: |
34+
chmod +x xdv-os/src/build.sh
35+
./xdv-os/src/build.sh
36+
37+
- name: Verify disk image
38+
run: |
39+
[ -f xdv-os/src/xdv-os.img ] || exit 1
40+
ls -la xdv-os/src/xdv-os.img
41+
xxd -s 510 xdv-os/src/xdv-os.img -l 2
42+
43+
- name: Verify components
44+
run: |
45+
[ -d xdv-os/xdv-boot ] && [ -d xdv-os/xdv-kernel ] && [ -d xdv-os/xdv-runtime ] && \
46+
[ -d xdv-os/xdv-shell ] && [ -d xdv-os/xdv-xdvfs ] || exit 1
47+
echo "All components present"
48+
49+
- name: Upload xdv-os.img
50+
uses: actions/upload-artifact@v4
51+
with:
52+
name: xdv-os-img
53+
path: xdv-os/src/xdv-os.img

‎README.md‎

Lines changed: 18 additions & 140 deletions
Original file line numberDiff line numberDiff line change
@@ -1,156 +1,34 @@
11
# xdv-os
22

3-
Complete XDV Operating System - Bootable for VirtualBox
3+
XDV Operating System integration workspace.
44

5-
xdv-os is an operating system built with the **Dust Programming Language (DPL)** toolchain. The kernel is **compiled from DPL** using the **dust** compiler; the build loads and validates **xdv-kernel**, **xdv-runtime**, **xdv-shell**, **xdv-boot**, **xdv-xdvfs**, **dustlib**, **dustlib_k**, and **dust_runtime**. The bootable image is produced by: `dust obj kernel_entry.ds --bare-metal` (kernel) plus a minimal MBR in assembly (required by the BIOS).
5+
## Build
66

7-
## Overview
7+
Windows:
88

9-
xdv-os combines all XDV components into a fully functional operating system that boots in VirtualBox:
10-
11-
- **xdv-boot** - Bootloader (MBR, GDT, IDT, Paging, Disk I/O, XDVFS mount, Kernel load)
12-
- **xdv-kernel** - 13-sector kernel
13-
- **xdv-xdvfs** - Native file system
14-
- **xdv-runtime** - User space runtime
15-
- **xdv-shell** - Command line shell
16-
17-
## Quick Start
18-
19-
### Build on Linux/Mac
20-
```bash
21-
cd src
22-
chmod +x build.sh
23-
./build.sh
24-
```
25-
26-
### Build on Windows
279
```cmd
28-
cd src
10+
cd xdv-os\src
2911
build.bat
3012
```
3113

32-
### Run in VirtualBox
33-
1. Download `xdv-os.img` from CI artifacts
34-
2. Open VirtualBox
35-
3. Create new VM: Type=Other, Version=64-bit
36-
4. Set RAM to 64MB
37-
5. Add xdv-os.img as hard disk (or use vmkfdimg for live CD)
38-
6. Start VM
39-
40-
## Boot Process
41-
42-
```
43-
BIOS -> MBR (0x7C00) -> Load kernel to 0x10000 -> Protected mode -> DPL kernel (VGA output, then halt)
44-
```
45-
46-
1. **BIOS** loads MBR at 0x7C00
47-
2. **Boot sector** (assembly) loads the DPL-built kernel from sector 2 to 0x10000, enables protected mode, jumps to kernel
48-
3. **Kernel** (from `dust obj kernel_entry.ds --bare-metal`) runs at 0x10000: prints boot messages to VGA, then halts
49-
50-
## Expected Boot Output (VirtualBox)
51-
52-
When the OS boots in VirtualBox you should see (then the system halts):
53-
54-
```
55-
XDV Kernel starting...
56-
Initializing XDV Kernel v0.2.0
57-
Build date: 2026-02-12
58-
Booting on K-Domain (x64/Intel/AMD)
59-
K-Domain (x64): ONLINE
60-
XDV: Probing for Q-Domain hardware...
61-
XDV: Q-Domain hardware not detected - disabled
62-
XDV: Probing for Phi-Domain hardware...
63-
XDV: Phi-Domain hardware not detected - disabled
64-
XDV Kernel: Initializing process management
65-
Entering kernel main loop
66-
```
67-
68-
## Memory Layout
14+
Linux/macOS:
6915

16+
```bash
17+
cd xdv-os/src
18+
./build.sh
7019
```
71-
0x00000 - 0x9FFFF : Real mode memory
72-
0x07C00 : Boot sector load address
73-
0x10000 (64KB) : Kernel load address (0x1000:0)
74-
0xB8000 : VGA text memory
75-
0x90000 : Stack
76-
```
77-
78-
## Components
79-
80-
### xdv-boot
81-
- MBR boot sector
82-
- Stage 1 loader
83-
- GDT, IDT
84-
- Paging setup
85-
- Disk I/O
86-
- Kernel loading
87-
88-
### xdv-kernel (13 sectors)
89-
1. xdv_boot - Boot integration
90-
2. xdv_memory - Memory management
91-
3. xdv_cpu - CPU control
92-
4. xdv_drivers - Hardware drivers
93-
5. xdv_kernel - Core kernel
94-
6. xdv_dal - Device Abstraction Layer
95-
7. xdv_qdomain - Q-Domain support (stubbed)
96-
8. xdv_phidomain - Φ-Domain support (stubbed)
97-
9. xdv_cds - Core Data Structures
98-
10. xdv_umf - User Mode Facilities
99-
11. xdv_hypervisor - Hypervisor support
100-
12. xdv_sdbm - Simple Database Manager
101-
13. xdv_odt - Object Dispatch Table
102-
103-
### xdv-xdvfs
104-
- Superblock, Inodes, Block allocation
105-
- Directory operations
106-
- File operations (K-domain only)
107-
108-
### xdv-runtime
109-
- I/O, Memory, String, Process
110-
- Scheduler, FS interface, Console, Init
111-
112-
### xdv-shell
113-
- Lexer, Parser, Executor
114-
- Builtins: cd, ls, cat, mkdir, rm, echo, ps, help, exit
115-
- Tab completion
116-
117-
## Architecture
118-
119-
K-Domain only (classical x86-64 hardware). Q/Φ domains stubbed.
120-
121-
## Directory Structure
122-
123-
```
124-
xdv-os/
125-
├── State.toml
126-
├── src/
127-
│ ├── boot_sector.asm # MBR (loads kernel, switches to protected mode)
128-
│ ├── kernel_entry.ds # DPL kernel entry (dust obj --bare-metal -> kernel.bin)
129-
│ ├── build.sh # Linux/Mac build (dust + NASM -> xdv-os.img)
130-
│ └── build.bat # Windows build
131-
├── xdv-boot/
132-
├── xdv-kernel/
133-
├── xdv-xdvfs/
134-
├── xdv-runtime/
135-
├── xdv-shell/
136-
└── .github/workflows/
137-
└── ci.yml # Builds xdv-os.img with dust
138-
```
139-
140-
## Build (dust + NASM)
141-
142-
The build uses the **dust** compiler and validates all DPL components:
14320

144-
1. **dust** compiler: built from repo root `dust/` if not in PATH
145-
2. **dust check** on: dustlib, dustlib_k, dust_runtime, xdv-boot, xdv-kernel, xdv-runtime, xdv-shell, xdv-xdvfs
146-
3. **dust obj** `kernel_entry.ds` **--bare-metal** → `kernel.bin` (32-bit code, VGA output)
147-
4. **NASM** assembles `boot_sector.asm` → MBR
148-
5. Image: 1 MB disk with MBR + kernel at sector 2
21+
## Artifacts
14922

150-
## CI Build
23+
The build now emits partitioned 64MB disk images:
15124

152-
GitHub Actions: build dust, run full build (dust obj + NASM), produce `xdv-os.img` artifact.
25+
- `xdv-os/src/xdv-os-mbr-64m.img` - BIOS/MBR boot image.
26+
- `xdv-os/src/xdv-os-uefi-64m.img` - GPT image with ESP and xdvfs partition.
27+
- `xdv-os/src/xdv-os.img` - compatibility alias to the MBR image.
15328

154-
## Version
29+
## Image Contents
15530

156-
0.2.0
31+
- `xdv-boot` boot path metadata and BIOS stage machine code.
32+
- `xdv-kernel` + `xdv-runtime` combined bare-metal kernel binary.
33+
- `xdvfs` superblock and layout markers.
34+
- preload payload with `xdv-core`, `xdv-edx`, and `xdv-shell`.

‎src/boot_sector.asm‎

Lines changed: 58 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
1-
; XDV OS boot sector (MBR style).
2-
; Loads kernel from sector 2, enters protected mode, jumps to 0x10000.
1+
; XDV OS boot sector (MBR style, partition-aware).
2+
; Loads the kernel from the active partition:
3+
; absolute_lba = partition_start_lba + KERNEL_REL_LBA
4+
; Then enters protected mode and jumps to 0x10000.
35

46
[ORG 0x7C00]
57
[BITS 16]
68

9+
KERNEL_REL_LBA equ 32
10+
KERNEL_SECTORS equ 128
11+
KERNEL_LOAD_SEG equ 0x1000
12+
KERNEL_LOAD_OFF equ 0x0000
13+
714
jmp short start
815
nop
916

@@ -16,23 +23,41 @@ start:
1623
mov sp, 0x7C00
1724
mov [boot_drive], dl
1825

19-
; Reset disk.
20-
xor ah, ah
26+
; Require INT13 extensions for LBA reads.
27+
mov ah, 0x41
28+
mov bx, 0x55AA
29+
mov dl, [boot_drive]
2130
int 0x13
2231
jc disk_error
32+
cmp bx, 0xAA55
33+
jne disk_error
34+
test cx, 0x0001
35+
jz disk_error
2336

24-
; Read kernel from CHS 0/0/3 into 0x1000:0000 (physical 0x10000).
25-
; build.{bat,sh} writes kernel.bin at LBA 2 (offset 1024), which is sector 3 in CHS.
26-
; 8 sectors is enough for current kernel.bin and stays in track.
27-
mov ax, 0x1000
28-
mov es, ax
29-
xor bx, bx
30-
mov ah, 0x02
31-
mov al, 0x08
32-
mov ch, 0x00
33-
mov cl, 0x03
34-
mov dh, 0x00
37+
; Prefer active partition; fallback to partition entry 0.
38+
mov si, partition_table
39+
mov cx, 4
40+
.find_active:
41+
cmp byte [si], 0x80
42+
je .active_found
43+
add si, 16
44+
loop .find_active
45+
mov si, partition_table
46+
47+
.active_found:
48+
; Partition start LBA is +8 in a 16-byte MBR partition entry.
49+
mov eax, [si + 8]
50+
add eax, KERNEL_REL_LBA
51+
mov [dap_lba_low], eax
52+
mov dword [dap_lba_high], 0
53+
54+
mov word [dap_count], KERNEL_SECTORS
55+
mov word [dap_offset], KERNEL_LOAD_OFF
56+
mov word [dap_segment], KERNEL_LOAD_SEG
57+
58+
mov si, disk_address_packet
3559
mov dl, [boot_drive]
60+
mov ah, 0x42
3661
int 0x13
3762
jc disk_error
3863

@@ -67,7 +92,23 @@ print16:
6792
ret
6893

6994
boot_drive db 0x80
70-
err_msg db 'BOOTERR', 0
95+
96+
; INT13 extended read packet (16 bytes).
97+
disk_address_packet:
98+
db 0x10
99+
db 0x00
100+
dap_count:
101+
dw 0
102+
dap_offset:
103+
dw 0
104+
dap_segment:
105+
dw 0
106+
dap_lba_low:
107+
dd 0
108+
dap_lba_high:
109+
dd 0
110+
111+
err_msg db 'XDVBOOT ERR', 0
71112

72113
; Protected mode descriptors.
73114
gdt:
@@ -95,5 +136,6 @@ protected_mode_entry:
95136
[BITS 16]
96137
; MBR sector layout: boot code (0..445), partition table (446..509), signature.
97138
times 446 - ($ - $$) db 0
139+
partition_table:
98140
times 64 db 0
99141
dw 0xAA55

‎src/boot_sector.bin‎

0 Bytes
Binary file not shown.

‎src/build.bat‎

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@ REM xdv-os build pipeline:
33
REM - validates one compileable integration entry per required subsystem
44
REM - builds a bare-metal kernel binary from a composed source bundle:
55
REM xdv-runtime/src/runtime_bridge.ds + xdv-kernel/sector/xdv_kernel/src/kernel.ds
6-
REM - assembles MBR boot sector and packs xdv-os.img
6+
REM - assembles MBR boot sector
7+
REM - generates partitioned 64MB images:
8+
REM xdv-os-mbr-64m.img (MBR)
9+
REM xdv-os-uefi-64m.img (GPT/ESP + xdvfs)
10+
REM and xdv-os.img as alias to the MBR artifact
711

812
goto :main
913

@@ -68,6 +72,8 @@ if not defined DUST_CMD (
6872
)
6973

7074
echo [1/4] Validating required subsystem entrypoints...
75+
call :check_file "%REPO_ROOT%\xdv-boot\src\boot_mbr.ds" || exit /b 1
76+
call :check_file "%REPO_ROOT%\xdv-boot\src\boot_uefi.ds" || exit /b 1
7177
call :check_file "%REPO_ROOT%\xdv-boot\src\boot_stage1.ds" || exit /b 1
7278
call :check_file "%KERNEL_SRC%" || exit /b 1
7379
call :check_file "%REPO_ROOT%\xdv-xdvfs\src\xdvfs_mount.ds" || exit /b 1
@@ -131,28 +137,24 @@ if %ERRORLEVEL% neq 0 (
131137
exit /b 1
132138
)
133139

134-
echo [4/4] Creating disk image...
135-
powershell -NoProfile -Command ^
136-
"$img = New-Object byte[] 1048576; " ^
137-
"$boot = [System.IO.File]::ReadAllBytes('boot_sector.bin'); " ^
138-
"$kern = [System.IO.File]::ReadAllBytes('kernel.bin'); " ^
139-
"[Array]::Copy($boot, 0, $img, 0, $boot.Length); " ^
140-
"[Array]::Copy($kern, 0, $img, 1024, $kern.Length); " ^
141-
"[System.IO.File]::WriteAllBytes('xdv-os.img', $img)"
140+
echo [4/4] Creating 64MB partitioned images...
141+
powershell -NoProfile -ExecutionPolicy Bypass -File build_images.ps1 ^
142+
-BootSectorPath "boot_sector.bin" ^
143+
-KernelPath "kernel.bin" ^
144+
-RepoRoot "%REPO_ROOT%" ^
145+
-OutputDir "%~dp0." ^
146+
-ImageSizeMB 64
142147
if %ERRORLEVEL% neq 0 (
143-
echo ERROR: Failed to create image
148+
echo ERROR: Failed to create partitioned images
144149
exit /b 1
145150
)
146151

147-
REM Set boot flag and partition type
148-
powershell -NoProfile -Command ^
149-
"$f = [System.IO.File]::Open('xdv-os.img', [System.IO.FileMode]::Open, [System.IO.FileAccess]::ReadWrite, [System.IO.FileShare]::None); " ^
150-
"$f.Seek(446, [System.IO.SeekOrigin]::Begin); $f.WriteByte(0x80); " ^
151-
"$f.Seek(450, [System.IO.SeekOrigin]::Begin); $f.WriteByte(0x83); $f.Close()"
152-
153152
echo.
154153
echo === Build complete ===
155-
echo Output: %~dp0xdv-os.img
156-
echo Run in VirtualBox: Other/64-bit, 64MB RAM, attach xdv-os.img as disk.
154+
echo Output (MBR): %~dp0xdv-os-mbr-64m.img
155+
echo Output (UEFI): %~dp0xdv-os-uefi-64m.img
156+
echo Alias: %~dp0xdv-os.img
157+
echo VirtualBox BIOS: attach xdv-os-mbr-64m.img (or xdv-os.img)
158+
echo VirtualBox UEFI: enable EFI and attach xdv-os-uefi-64m.img
157159
echo.
158160
exit /b 0

0 commit comments

Comments
 (0)