windows-creator.sleela
lib/operating-system/examples/windows/windows-creator.sleela · 147 line(s) · sleela
#sleela 2.5
material;
< windows-creator.sleela -- a self-contained, COMPILABLE OS Creator example for >
< a Windows 10+ -shaped OS. Mirrors the lib/os design classes in one unit (the >
< split provider classes use native string intrinsics that do not compile >
< standalone; see "Issues/notes" at the bottom). >
< >
< It demonstrates the Windows family defaults the OS Creator applies: the NT >
< kernel (NT 10.0), BOOTMGR loader, NTFS root, the system-managed pagefile for >
< swap, the Service Control Manager as init, Explorer as the shell, and the >
< Windows base-driver series (.sys drivers). Its compat route runs a Linux >
< guest via WSL2. >
< >
< Run: ./impl/build/sleela run lib/operating-system/examples/windows/windows-creator.sleela >
struct Model {
< ---- Descriptive metadata (version 1.11 nested-friendly accessors) ---- >
<< Eleven catalogued attributes with getter/setter pairs, so a GUI, loader,
or catalog can read and (where appropriate) override this record.
Values are faithful to the subject's real origin where publicly known. >>
String metaVersion = "1.0.0";
int metaId = 10999;
String metaAuthor = "Kiro Agent";
String metaDate = "2026-10-16";
String metaCopyright = "SLeeLa project";
String metaTrademark = "none";
String metaCorporation = "none";
< metaOrigin: National | <nation> | International | Galactic >
String metaOrigin = "International";
String metaBirthDate = "2026-10-11";
< metaScienceRating: maturity/robustness on a 1..10 scale >
int metaScienceRating = 7;
< metaNationalSchedule: a real, citable instrument or "none" >
String metaNationalSchedule = "none";
String getMetaVersion() { return metaVersion; }
void setMetaVersion(String v) { metaVersion = v; }
int getMetaId() { return metaId; }
void setMetaId(int v) { metaId = v; }
String getAuthor() { return metaAuthor; }
void setAuthor(String v) { metaAuthor = v; }
String getDate() { return metaDate; }
void setDate(String v) { metaDate = v; }
String getCopyright() { return metaCopyright; }
void setCopyright(String v) { metaCopyright = v; }
String getTrademark() { return metaTrademark; }
void setTrademark(String v) { metaTrademark = v; }
String getCorporation() { return metaCorporation; }
void setCorporation(String v) { metaCorporation = v; }
String getOrigin() { return metaOrigin; }
void setOrigin(String v) { metaOrigin = v; }
String getBirthDate() { return metaBirthDate; }
void setBirthDate(String v) { metaBirthDate = v; }
int getScienceRating() { return metaScienceRating; }
void setScienceRating(int v) { metaScienceRating = v; }
String getNationalSchedule() { return metaNationalSchedule; }
void setNationalSchedule(String v) { metaNationalSchedule = v; }
String name; String version; String arch; String triple;
String loader; String kernel; String kernelVer; String cmdline;
String rootfs; String init; String desktop;
}
class WindowsCreator {
Model windows(String name, String version) {
Model m = new Model();
m.name = name; m.version = version; m.arch = "amd64";
m.triple = "x86_64-pc-windows-msvc";
< Windows 11 24H2 >
m.loader = "BOOTMGR"; m.kernel = "NT"; m.kernelVer = "10.0.26100";
m.cmdline = "ro quiet"; m.rootfs = "NTFS"; m.init = "ServiceControlManager";
m.desktop = "Explorer/DWM";
return m;
}
String identity(Model m) { return m.name + " " + m.version + " (Windows, " + m.arch + ")"; }
boolean readyToCompile(Model m) {
boolean downloads = packageRepo(m) != "" && kernelSrc(m) != "";
boolean settings = m.rootfs != "" && m.cmdline != "";
boolean bootable = m.loader != "" && m.kernel != "";
return downloads && settings && bootable;
}
String packageRepo(Model m) { return "https://pkgs.local/windows"; }
String kernelSrc(Model m) { return "https://pkgs.local/windows/nt-src"; }
String configHeader(Model m) {
String h = "/* os_config.h - generated by SLeeLa OS Creator for " + identity(m) + " */\n";
h = h + "#define OS_NAME \"" + m.name + "\"\n";
h = h + "#define OS_SHAPE \"Windows\"\n";
h = h + "#define OS_ARCH \"" + m.arch + "\"\n";
h = h + "#define OS_TRIPLE \"" + m.triple + "\"\n";
h = h + "#define OS_LOADER \"" + m.loader + "\"\n";
h = h + "#define OS_KERNEL \"" + m.kernel + "\"\n";
h = h + "#define OS_KERNEL_VER \"" + m.kernelVer + "\"\n";
h = h + "#define OS_ROOTFS \"" + m.rootfs + "\"\n";
h = h + "#define OS_INIT \"" + m.init + "\"\n";
h = h + "#define OS_DESKTOP \"" + m.desktop + "\"\n";
return h;
}
String baseDrivers(Model m) {
String s = "bus pci.sys/acpi.sys boot\nstorage storahci.sys/stornvme.sys boot\n";
s = s + "display BasicDisplay.sys boot\nkeyboard i8042prt/kbdhid.sys boot\n";
s = s + "mouse mouhid.sys early\nusb usbxhci.sys early\naudio HDAudio.sys early";
return s;
}
String downloads(Model m) {
String s = "package-repo compile " + packageRepo(m) + "\n";
s = s + "kernel-src compile " + kernelSrc(m) + "\n";
s = s + "firmware-src iso https://uefi.org/firmware";
return s;
}
String settings(Model m) {
String s = "swap: pagefile.sys (system-managed)\n";
s = s + "filesystem: root=" + m.rootfs + " esp=fat32\n";
s = s + "cmdline: " + m.cmdline;
return s;
}
< Windows has no FS-level interpreter; it runs a Linux guest via WSL2. >
String compat(Model m) { return "Windows runs Linux via wsl2 + linux-userland"; }
void banner(String t) {
print("================================================================");
print(" " + t);
print("================================================================");
}
void main() {
Model os = windows("Resolute", "1.0");
banner("OS Creator example: " + identity(os));
print("readyToCompile = " + readyToCompile(os));
if (!readyToCompile(os)) { print("REFUSED: not emitting."); return; }
print("");
banner("os/os_config.h"); print(configHeader(os));
banner("kernel/base-drivers (series)"); print(baseDrivers(os));
banner("config/downloads.conf"); print(downloads(os));
banner("config settings"); print(settings(os));
banner("userspace/compat-loader"); print(compat(os));
banner("done");
print("Next: the OS Creator writes these under /os-development, then: build.ps1");
}
}