Home /Modules/operating-system/SLKernelSpec.sleela

SLKernelSpec.sleela

lib/operating-system/SLKernelSpec.sleela · 136 line(s) · sleela

<< lib/operating-system/SLKernelSpec.sleela
   SLeeLa Standard Library Definition.
   Definition: Defines SLKernelSpec — the kernel layer of an OS being
     constructed. It names the kernel the target OS boots (an NT-style, a
     Linux-style, or an XNU/Darwin-style kernel), its version, the subsystems
     it must provide (process management, memory management, scheduling,
     networking, filesystems, drivers, security primitives), and the kernel
     command line handed to it at boot.
   
   In the firmware -> boot -> kernel -> userspace -> desktop model, this is the
   kernel node. The C/C++ emitters turn a configured SLKernelSpec into the
   kernel-config and command-line artifacts the ISO build consumes; where a
   real upstream kernel is used (the common case) the spec records which kernel
   and configuration to assemble rather than re-implementing one.
   
   SCOPE NOTE: this models the kernel's COMPOSITION contract, not a from-scratch
   kernel implementation. Compare lib/cpu/SLGuestKernelBuilder, which compiles a
   small custom teaching kernel on a simulated CPU.
   
   Family: operating-system. Pure design model; no native bridge calls. >>
#sleela 2.5
material;
class SLKernelSpec {
  < ---- 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 = 10902;
  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-10";
  < 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; }
  < "NT", "Linux", "XNU" >
  String kernelName;
  < e.g. "6.18.27" >
  String version;
  < kernel boot parameters >
  String cmdline;
  < Subsystem toggles (1 = required, 0 = omitted). >
  int processMgmt;
  int memoryMgmt;
  int scheduler;
  int networking;
  int filesystems;
  int drivers;
  int security;
  < preemptible kernel >
  int preemptible;
  int configured;

  < Baseline: a full-featured, preemptible kernel with every core subsystem. >
  void configure(String name, String ver) {
    kernelName = name; version = ver; cmdline = "ro quiet";
    processMgmt = 1; memoryMgmt = 1; scheduler = 1; networking = 1;
    filesystems = 1; drivers = 1; security = 1; preemptible = 1;
    configured = 1;
  }

  < Pick the kernel family that matches a shape, with a sensible version. >
  void forShape(SLOSShape shape) {
    if (shape.isWindows()) { configure("NT", "10.0"); return; }
    if (shape.isMac())     { configure("XNU", "24.0"); return; }
    configure("Linux", "6.18.27");
  }

  < Request a SPECIFIC kernel version via SLKernelCatalog. `family` is >
  < "Linux"/"Windows"/"macOS" and `selection` is a named series/edition >
  < ("6.6 LTS", "11", "Sonoma", "latest", "default") or an explicit version. >
  < Returns true when the selection is supported for the family; on success the >
  < kernel name and resolved version are applied, otherwise the spec is left >
  < unchanged. Windows requests below Windows 10 are unsupported (return false). >
  boolean selectVersion(SLKernelCatalog catalog, String family, String selection) {
    String resolved = catalog.resolve(family, selection);
    if (resolved == "") { return false; }
    configure(catalog.kernelName(family), resolved);
    return true;
  }

  void setCmdline(String line) { cmdline = line; }
  void appendCmdline(String arg) { cmdline = cmdline + " " + arg; }
  void requireSecurity(boolean on) { if (on) { security = 1; } else { security = 0; } }

  String name()        { return kernelName; }
  String kernelVersion() { return version; }
  String commandLine() { return cmdline; }

  < Count of enabled core subsystems (used by the model's validity check). >
  int subsystemCount() {
    int n = 0;
    if (processMgmt == 1) { n = n + 1; }
    if (memoryMgmt == 1)  { n = n + 1; }
    if (scheduler == 1)   { n = n + 1; }
    if (networking == 1)  { n = n + 1; }
    if (filesystems == 1) { n = n + 1; }
    if (drivers == 1)     { n = n + 1; }
    if (security == 1)    { n = n + 1; }
    return n;
  }
  < A kernel is bootable only if it provides the three irreducible subsystems. >
  boolean isBootable() {
    return processMgmt == 1 && memoryMgmt == 1 && scheduler == 1;
  }
}