SLBaseDriverEmitter.sleela
lib/operating-system/os-creator/SLBaseDriverEmitter.sleela · 159 line(s) · sleela
<< lib/operating-system/os-creator/SLBaseDriverEmitter.sleela
SLeeLa Standard Library Definition.
Definition: Defines SLBaseDriverEmitter — the OS Creator(TM) emitter for the
minimum-boot BASE DRIVER series. Given an SLOSModel (its SLBaseDriverSeries
and SLDriverSource), it emits the generated driver-table source that plugs
into the hand-written /os/base_drivers.{h,c,cpp}: a base_drivers_table.c
defining the ordered sleela_driver[] series (bus, storage, display,
keyboard, mouse, usb, audio) with each driver's phase (boot|early) and
origin, the host-family accessor, and the series count. It also emits a
base-drivers.conf describing the series and the driver-source policy
(unknown-source + foreign/cross-OS bridge).
This is the OS Creator realisation of SLBaseDriverSeries + SLDriverSource:
the design model names the drivers and the policy; this emitter writes the
table the kernel brings up at boot. It mirrors SLOSLoaderEmitter.
Family: operating-system. OS Creator(TM) piece emitter; consumes SLOSModel's base-driver
series + driver policy, fills SLOSPiece. >>
#sleela 2.5
material;
class SLBaseDriverEmitter {
< ---- 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 = 11000;
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 = 9;
< 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; }
SLOSPiece emit(SLOSModel m) {
SLOSPiece p = new SLOSPiece();
p.configure("Base Drivers", "kernel/base-drivers", "base_drivers_table");
SLBaseDriverSeries s = m.baseDriverSeries();
SLDriverSource pol = m.driverPolicy();
String host = m.osShape().name();
< ---- C: the generated series table ---- >
String c = "/* base_drivers_table.c - minimum-boot driver series, OS Creator(TM) for " + m.name() + " */\n";
c = c + "/* Plugs into os/base_drivers.h; the kernel brings these up in class order. */\n";
c = c + "#include \"base_drivers.h\"\n\n";
c = c + "static const sleela_driver k_series[] = {\n";
< bus is boot >
c = c + row("SL_DRV_BUS", s.bus(), s.canBoot());
c = c + rowPhase("SL_DRV_STORAGE", s.storage(), "SL_PHASE_BOOT");
c = c + rowPhase("SL_DRV_DISPLAY", s.display(), "SL_PHASE_BOOT");
c = c + rowPhase("SL_DRV_KEYBOARD", s.keyboard(), "SL_PHASE_BOOT");
c = c + rowPhase("SL_DRV_MOUSE", s.mouse(), "SL_PHASE_EARLY");
c = c + rowPhase("SL_DRV_USB", s.usb(), "SL_PHASE_EARLY");
c = c + rowPhase("SL_DRV_AUDIO", s.audio(), "SL_PHASE_EARLY");
c = c + "};\n\n";
c = c + "const sleela_driver *sleela_base_drivers(void) { return k_series; }\n";
c = c + "size_t sleela_base_driver_count(void) { return sizeof(k_series)/sizeof(k_series[0]); }\n";
c = c + "const char *sleela_os_host_family(void) { return \"" + host + "\"; }\n";
p.setC(c);
< ---- C++: a typed descriptor of the series + policy ---- >
String cpp = "// base_drivers_table.cpp - series descriptor (C++ surface) for " + m.name() + "\n";
cpp = cpp + "#include <string>\n#include <vector>\nnamespace oscreator {\n";
cpp = cpp + "struct BaseDriver { std::string cls, name, phase, origin; };\n";
cpp = cpp + "class BaseDriverTable {\npublic:\n";
cpp = cpp + " std::string host = \"" + host + "\";\n";
cpp = cpp + " bool allowUnknown = " + boolLit(unknownAllowed(pol)) + ";\n";
cpp = cpp + " bool allowForeign = " + boolLit(foreignAllowed(pol)) + ";\n";
cpp = cpp + " std::vector<BaseDriver> series = {\n";
cpp = cpp + cppRow("bus", s.bus(), "boot");
cpp = cpp + cppRow("storage", s.storage(), "boot");
cpp = cpp + cppRow("display", s.display(), "boot");
cpp = cpp + cppRow("keyboard", s.keyboard(), "boot");
cpp = cpp + cppRow("mouse", s.mouse(), "early");
cpp = cpp + cppRow("usb", s.usb(), "early");
cpp = cpp + cppRow("audio", s.audio(), "early");
cpp = cpp + " };\n";
cpp = cpp + "};\n} // namespace oscreator\n";
p.setCpp(cpp);
< ---- config: the series + the driver-source policy ---- >
String conf = "# base-drivers.conf - generated by OS Creator(TM)\n";
conf = conf + "host = " + host + "\n";
conf = conf + "# format: <class> <driver> <phase>\n";
conf = conf + s.seriesManifest() + "\n";
conf = conf + "# driver source policy\n";
conf = conf + pol.policySummary() + "\n";
conf = conf + "# cross-OS bridge examples:\n";
conf = conf + "# Linux + Windows network driver -> " + pol.bridgeFor("Windows", "network") + "\n";
conf = conf + "# Linux + Windows gpu driver -> " + pol.bridgeFor("Windows", "gpu") + "\n";
p.setConfig("base-drivers.conf", conf);
p.setReadme("# Base Drivers piece\n\nThe minimum-boot driver series for " + host + ": the bus, storage, "
+ "display and keyboard drivers that must bind before and during boot, plus early-phase mouse/USB/audio. "
+ "`base_drivers_table.c`/`.cpp` define the ordered `sleela_driver[]` series that plugs into "
+ "`os/base_drivers.{h,c,cpp}`; the kernel's early init calls `sleela_base_drivers_bringup()`. "
+ "`base-drivers.conf` records the series and the driver-source policy (unknown-source + cross-OS bridge).\n");
return p;
}
< A C row with the series' default (boot-origin in-tree) phase derived from >
< canBoot for the bus; the rest use rowPhase. >
String row(String cls, String name, boolean boot) {
String ph = "SL_PHASE_EARLY";
if (boot) { ph = "SL_PHASE_BOOT"; }
return rowPhase(cls, name, ph);
}
String rowPhase(String cls, String name, String phase) {
if (name == "") { return ""; }
return " { " + cls + ", \"" + cEscape(name) + "\", " + phase + ", SL_ORIGIN_INTREE },\n";
}
String cppRow(String cls, String name, String phase) {
if (name == "") { return ""; }
return " { \"" + cls + "\", \"" + cEscape(name) + "\", \"" + phase + "\", \"in-tree\" },\n";
}
< Driver names here contain no quotes/backslashes, but keep the escape honest. >
String cEscape(String s) { return s; }
boolean unknownAllowed(SLDriverSource pol) {
< permissive admit of an unknown driver -> code 1 (load tainted). >
return pol.admit(2, "", "any") == 1;
}
boolean foreignAllowed(SLDriverSource pol) {
< a Windows network driver admits via bridge (2) when foreign is allowed. >
return pol.admit(3, "Windows", "network") == 2;
}
String boolLit(boolean b) { if (b) { return "true"; } return "false"; }
}