Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
6523c4a
Add USB support with mass storage and HID drivers
y4my4my4m Jul 23, 2026
ace4434
Refactor USB endpoint handling to use auto_kind instead of auto_cb
y4my4my4m Jul 23, 2026
96b4084
Refactor CUsbEP to use pointer for CXhciRing
y4my4my4m Jul 23, 2026
bc2b7ba
Refactor USB endpoint management to use ep_list instead of eps
y4my4my4m Jul 23, 2026
2f69b00
Fix Mounting USB Drives
y4my4my4m Jul 23, 2026
a73013f
Add USB support for booting and mass storage integration
y4my4my4m Jul 23, 2026
e838db5
Enhance block device management with runtime-dispatched raw read/writ…
y4my4my4m Jul 23, 2026
8bacee9
Refactor raw block read/write functions for runtime dispatching
y4my4my4m Jul 23, 2026
0039a23
Add USB boot guide documentation
y4my4my4m Jul 23, 2026
9a38908
Add RAM-distro ISO guide and enhance boot progress markers
y4my4my4m Jul 24, 2026
1ad5f87
Update RAM-distro build process and documentation
y4my4my4m Jul 24, 2026
8ba2171
Update ventoy-ram-iso-guide.md and DiskAddDev.ZC for improved clarity…
y4my4my4m Jul 24, 2026
5f2dd62
fix
y4my4my4m Jul 24, 2026
16721a1
Update MakeRAMDistro function to increase default image size and add …
y4my4my4m Jul 24, 2026
df2c780
Enhance BlkPool memory management for RAM-distro image handling
y4my4my4m Jul 24, 2026
844e032
Implement LAPIC timer initialization and diagnostics
y4my4my4m Jul 24, 2026
0cdb747
Add scripts for building RAM-distro ISO and extracting kernel image
y4my4my4m Jul 24, 2026
24f280f
Refactor LAPIC timer initialization for improved calibration and fall…
y4my4my4m Jul 24, 2026
0e29eb3
Refactor xHCI controller initialization to support multiple controllers
y4my4my4m Jul 24, 2026
7b18ec9
Enhance xHCI controller initialization and memory mapping
y4my4my4m Jul 24, 2026
8aeffe7
Update build markers and enhance xHCI controller initialization logging
y4my4my4m Jul 24, 2026
c97b993
Add xHCI controller switching and enhance initialization logging
y4my4my4m Jul 24, 2026
9e1ddbd
Enhance xHCI controller initialization and logging
y4my4my4m Jul 24, 2026
9b10a8d
Add CDC-ECM and USB Hub support to USB subsystem
y4my4my4m Jul 24, 2026
81e04cb
update
y4my4my4m Jul 29, 2026
3c63f9c
Refactor USB subsystem to support multiple xHCI controllers
y4my4my4m Jul 29, 2026
6e5b081
Refactor USB CDC-ECM driver and related components for clarity and ef…
y4my4my4m Jul 29, 2026
86d712b
Enhance USB CDC-ECM driver with transmit queue management
y4my4my4m Jul 29, 2026
fda0ff9
Implement target selection for installation process
y4my4my4m Jul 31, 2026
3256f5f
Enhance RAM distribution and installation process
y4my4my4m Jul 31, 2026
90250ab
Update FAT32 format handling to support USB drives
y4my4my4m Jul 31, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions build/build-ram-iso.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#!/usr/bin/env bash
# Package the self-contained RAM-distro ISO: the normal Kernel.ZXE plus the OS
# image (RAMDistro.BIN, made in-OS by src/Misc/DoDistroRAM.ZC) as a second
# Limine module. ZealBooter hands the image address to the kernel, which mounts
# it as RAM drive B: and boots -- works from CD, dd'd USB, Ventoy, PXE.
#
# Usage: ./build-ram-iso.sh <RAMDistro.BIN> [Kernel.ZXE]
# RAMDistro.BIN : OS image from the VM (see sync.sh for mounting the vdisk)
# Kernel.ZXE : normal kernel; defaults to the one build-iso.sh produced
# (build/limine ISO), else supply a path.
set -e
cd "$(dirname "$0")"

IMG="${1:-RAMDistro.BIN}"
KZXE="${2:-Kernel.ZXE}"

if [ ! -f "$IMG" ]; then
echo "ERROR: OS image not found: $IMG"
echo "Run src/Misc/DoDistroRAM.ZC inside ZealOS, then copy Tmp/RAMDistro.BIN here."
exit 1
fi
if [ ! -f "$KZXE" ]; then
echo "ERROR: kernel not found: $KZXE"
echo "Copy a normal Kernel.ZXE here (e.g. from build-iso.sh output or the vdisk)."
exit 1
fi

LIMINE_BINARY_BRANCH="v10.x-binary"
[ -d limine ] || git clone https://github.com/limine-bootloader/limine.git --branch=$LIMINE_BINARY_BRANCH --depth=1
make -C limine
[ -f ../zealbooter/bin/kernel ] || make -C ../zealbooter distclean all

TMPISODIR=$(mktemp -d)
trap 'rm -rf "$TMPISODIR"' EXIT
mkdir -p "$TMPISODIR/Boot" "$TMPISODIR/EFI/BOOT"

cp limine/BOOTX64.EFI "$TMPISODIR/EFI/BOOT/BOOTX64.EFI"
cp limine/limine-uefi-cd.bin "$TMPISODIR/Boot/Limine-UEFI-CD.BIN"
cp limine/limine-bios-cd.bin "$TMPISODIR/Boot/Limine-BIOS-CD.BIN"
cp limine/limine-bios.sys "$TMPISODIR/Boot/Limine-BIOS.SYS"
cp ../zealbooter/bin/kernel "$TMPISODIR/Boot/ZealBooter.ELF"
cp "$KZXE" "$TMPISODIR/Boot/Kernel.ZXE"
cp "$IMG" "$TMPISODIR/Boot/RAMDistro.BIN"

# limine.conf: kernel = module 0, OS image = module 1
cat > "$TMPISODIR/Boot/Limine.CONF" <<'EOF'
timeout: 1
interface_resolution: 1024x768

/ZealOS (RAM)
protocol: limine
resolution: 1024x768
path: boot():/Boot/ZealBooter.ELF
module_path: boot():/Boot/Kernel.ZXE
module_path: boot():/Boot/RAMDistro.BIN
EOF

truncate -s 32K bios_boot.img
xorriso -as mkisofs -R -r -J -b Boot/Limine-BIOS-CD.BIN \
-no-emul-boot -boot-load-size 4 -boot-info-table \
--efi-boot Boot/Limine-UEFI-CD.BIN \
-efi-boot-part --efi-boot-image --protective-msdos-label \
-append_partition 4 21686148-6449-6E6F-744E-656564454649 bios_boot.img \
-appended_part_as_gpt \
"$TMPISODIR" -o ZealOS-RAM.iso
rm -f bios_boot.img

./limine/limine bios-install ZealOS-RAM.iso --no-gpt-to-mbr-isohybrid-conversion

echo
echo "Built: build/ZealOS-RAM.iso (self-contained; CD / dd-to-USB / Ventoy / PXE)"
38 changes: 38 additions & 0 deletions build/extract-kernel.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/sh
# Robust extract of Kernel.ZXE (and optionally RAMDistro.BIN) from ZealOS.qcow2.
# Run from build/ with the VM SHUT DOWN.
set -e
DISK=ZealOS.qcow2
MNT=/tmp/zealtmp

[ -f "$DISK" ] || { echo "No $DISK in $(pwd)"; exit 1; }

# Fail if QEMU still has the disk open (would give a stale read).
if command -v fuser >/dev/null 2>&1 && sudo fuser "$DISK" >/dev/null 2>&1; then
echo "ERROR: $DISK is in use (VM still running?). Shut down the VM first."
exit 1
fi

sudo modprobe nbd
# Tear down any stale connection/mount from a previous run.
sudo umount "$MNT" 2>/dev/null || true
sudo qemu-nbd -d /dev/nbd0 2>/dev/null || true
sleep 1

sudo qemu-nbd -c /dev/nbd0 "$DISK"
sudo partprobe /dev/nbd0
sleep 1
sudo mkdir -p "$MNT"
sudo mount /dev/nbd0p1 "$MNT"

echo -n "Kernel.ZXE: "; sudo stat -c '%y (%s bytes)' "$MNT/Boot/Kernel.ZXE"

sudo cp "$MNT/Boot/Kernel.ZXE" ./Kernel.ZXE
[ "$1" = "--image" ] && sudo cp "$MNT/Tmp/RAMDistro.BIN" ./RAMDistro.BIN
sudo chown "$(id -u):$(id -g)" ./Kernel.ZXE
[ -f ./RAMDistro.BIN ] && sudo chown "$(id -u):$(id -g)" ./RAMDistro.BIN || true

sync
sudo umount "$MNT"
sudo qemu-nbd -d /dev/nbd0
echo "Extracted Kernel.ZXE: $(stat -c '%y (%s bytes)' ./Kernel.ZXE)"
27 changes: 27 additions & 0 deletions build/usb-boot-guide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
dd if=/dev/zero of=usbdisk.img bs=1M count=512
echo 'start=2048, type=c' | sfdisk usbdisk.img
LOOP=$(sudo losetup -f --show -P usbdisk.img)
sudo mkfs.vfat -F 32 ${LOOP}p1
sudo losetup -d $LOOP


qemu-system-x86_64 -machine q35,accel=kvm -m 2G \
-boot d \
-cdrom ZealOS-PublicDomain-BIOS-2026-07-24-03_43_40.iso \
-device qemu-xhci,id=xhci \
-drive if=none,id=ub,format=raw,file=usbdisk.img \
-device usb-storage,bus=xhci.0,drive=ub


CopyTree("::/", "V:/"); # copies the whole CD to the stick
Dir("V:/"); # should now list Boot, Kernel, System, Compiler, Home, etc.
BootHDIns('V'); # recompiles kernel on V: (few min), writes FAT32 boot record
BootMHDIns('V'); # MBR chain-loader

# At the BootHDIns config prompt, enter V for boot drive, ENTER through the rest.

qemu-system-x86_64 -machine q35,accel=kvm -m 2G \
-device qemu-xhci,id=xhci \
-drive if=none,id=ub,format=raw,file=usbdisk.img \
-device usb-storage,bus=xhci.0,drive=ub \
-device usb-kbd,bus=xhci.0 -device usb-mouse,bus=xhci.0
138 changes: 138 additions & 0 deletions build/ventoy-ram-iso-guide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
# ZealOS RAM-distro ISO (Ventoy / limine / PXE)

Builds a self-contained `ZealOS-RAM.iso`. The kernel embeds the whole OS as a
RedSea RAM disk, so it boots with no post-load disk access from any loader that
places a kernel in memory. Same repo/branch also supports native USB-drive
install (see `usb-boot-guide.md`); the two are independent.

Branch: `usb-boot-ventoy`.

## Status / prerequisite

The RAM ISO is loaded by ZealBooter → limine. The limine boot path must reach
the desktop for this ISO to boot. If a plain limine ISO black-screens in your
setup, fix that first (kernel boot markers are emitted to QEMU debug port 0xE9;
boot with `-debugcon stdio`). Native CD boot and native USB install do not use
this path and work independently.

## Host packages

```
git qemu-system-x86 xorriso gcc make sudo
# nbd kernel module (for qemu-nbd mounting)
```

## 1. Clone + branch

```
git clone git@github.com:Zeal-Operating-System/ZealOS.git
cd ZealOS
git checkout usb-boot-ventoy
```

## 2. Build the base ISOs

```
cd build
./build-iso.sh
```

Produces `ZealOS-PublicDomain-BIOS-*.iso` (native) and `ZealOS-BSD2-UEFI-*.iso`
(limine). Bootstrap uses the tracked `build/AUTO.ISO`; needs `sudo` for
`qemu-nbd`.

## 3. Create a working ZealOS VM

```
qemu-img create -f qcow2 ZealOS.qcow2 2G
qemu-system-x86_64 -machine q35,accel=kvm -m 2G -boot d \
-cdrom ZealOS-PublicDomain-BIOS-*.iso \
-drive file=ZealOS.qcow2,format=qcow2,if=ide
```

The CD and the disk must be on the same AHCI controller or ZealOS won't see the
CD (do NOT put them on separate `-device ich9-ahci` controllers). At the ZealOS
prompt `Install onto hard drive (y or n)?` answer `y` and follow the installer
(target drive `C`). Shut down when done.

## 4. Sync branch source into the VM

`sync.sh` uses `ZEALDISK=ZealOS.qcow2` by default (edit if elsewhere). VM must be
shut down.

```
./sync.sh vm
```

## 5. Recompile kernel in the VM

```
qemu-system-x86_64 -machine q35,accel=kvm -m 2G \
-drive file=ZealOS.qcow2,format=qcow2,if=ide
```

In ZealOS:

```
BootHDIns('C');
```

Enter `C` at the boot-drive prompt, ENTER through the rest. Reboot the VM after.

## 6. Build the OS image in the VM

In ZealOS:

```
#include "::/Misc/DoDistroRAM";
```

Copies the OS into a RAM drive and snapshots it. Output: `::/Tmp/RAMDistro.BIN`
(~48MB). Shut down.

## 7. Extract image + kernel to the host

`RAMDistro.BIN` is the OS image; `/Boot/Kernel.ZXE` is the normal kernel that
step 5 recompiled (it carries the RAM-distro mount code).
(or use the kernel extraction script `./extract-kernel.sh`)

```
sudo modprobe nbd
sudo qemu-nbd -c /dev/nbd0 ZealOS.qcow2
sudo partprobe /dev/nbd0
sudo mkdir -p /tmp/zealtmp
sudo mount /dev/nbd0p1 /tmp/zealtmp
sudo cp /tmp/zealtmp/Tmp/RAMDistro.BIN ./RAMDistro.BIN
sudo cp /tmp/zealtmp/Boot/Kernel.ZXE ./Kernel.ZXE
sudo umount /tmp/zealtmp
sudo qemu-nbd -d /dev/nbd0
```

## 8. Package the RAM ISO

```
./build-ram-iso.sh RAMDistro.BIN Kernel.ZXE
```

Output: `build/ZealOS-RAM.iso`. The kernel is Limine module 0, the OS image is
module 1; ZealBooter passes the image address to the kernel, which mounts it as
RAM drive B: and boots.

## 9. Test in QEMU

```
qemu-system-x86_64 -machine q35,accel=kvm -m 2G -cdrom ZealOS-RAM.iso
```

## 10. Ventoy

Copy `ZealOS-RAM.iso` to the Ventoy partition of the USB stick. Boot the stick,
select it from the Ventoy menu.

## Notes

- Bump `RAMDISTRO_OFFSET` in `src/Misc/DoDistroRAM.ZC` if the kernel ever grows
past 1MB (`Kernel compile` will assert on a negative BINLOAD pad).
- Non-RAM ISOs on Ventoy do not work: ZealOS cannot read Ventoy's exFAT data
partition to find the ISO. The RAM ISO avoids all post-load disk access.
- PXE: chainload limine over the network with `Boot/Kernel.ZXE` = the RAM kernel.
7 changes: 7 additions & 0 deletions src/Home/Net/Drivers/Run.ZC
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@ U0 NetDriverInit()
net_driver = net_driver->next;
}

//No PCI NIC: fall back to a bound USB CDC-ECM adapter.
if (!found && UsbEcmPresent)
{
found = TRUE;
NetDriverInclude("UsbEcm");
}

if (!found)
{
ClassRep(net_pci);
Expand Down
Loading
Loading