Home /Modules/operating-system/SLUEFIFirmware.sleela

SLUEFIFirmware.sleela

lib/operating-system/uefi/SLUEFIFirmware.sleela · 118 line(s) · sleela

<< lib/operating-system/uefi/SLUEFIFirmware.sleela
   SLeeLa Standard Library Definition.
   Definition: Defines SLUEFIFirmware — a named UEFI platform firmware. It
     extends SLHardwareComponent and models the finite set of UEFI
     implementations and their relevant attributes: the firmware vendor
     (AMI Aptio, Insyde InsydeH2O, Phoenix SecureCore, the open-source
     TianoCore/EDK II, and coreboot+Tianocore payloads), the UEFI specification
     revision it implements, Secure Boot capability, the Compatibility Support
     Module (legacy BIOS) option, the boot-services/runtime-services split, and
     the EFI System Partition it reads. A machine description selects a firmware
     and composes it as the part that hands control to a bootloader.
   
   This is the hardware/firmware counterpart to the OS-side SLBootloaderSpec: the
   firmware is what runs first and loads the loader named there.
   
   Family: operating-system. Extends SLHardwareComponent. >>
#sleela 2.5
material;
class SLUEFIFirmware extends SLHardwareComponent {
  < ---- 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 = 10943;
  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; }
  < UEFI spec revision, e.g. "2.10" >
  String specRevision;
  < 1 if Secure Boot is supported >
  int secureBoot;
  < 1 if a Compatibility Support Module (legacy BIOS) exists >
  int csm;
  < 1 if boot services present (always, modeled) >
  int bootServices;
  < 1 if runtime services present >
  int runtimeServices;
  < EFI System Partition label it reads >
  String espLabel;
  int configured2;

  void configure(String vendor, String product, String revision) {
    configureComponent(vendor, product, CLASS_UEFI);
    specRevision = revision; secureBoot = 1; csm = 0;
    bootServices = 1; runtimeServices = 1; espLabel = "EFI System Partition";
    configured2 = 1;
  }

  < Named presets for the common firmware vendors. >
  void ami()        { configure("AMI", "Aptio V", "2.10"); }
  void insyde()     { configure("Insyde", "InsydeH2O", "2.9"); }
  void phoenix()    { configure("Phoenix", "SecureCore", "2.8"); }
  void tianocore()  { configure("TianoCore", "EDK II (OVMF)", "2.10"); }
  void coreboot()   { configure("coreboot", "coreboot + Tianocore payload", "2.10"); }

  < Choose by vendor name; defaults to TianoCore (the reference/open firmware). >
  void configureByVendor(String vendor) {
    if (vendor == "AMI")      { ami();      return; }
    if (vendor == "Insyde")   { insyde();   return; }
    if (vendor == "Phoenix")  { phoenix();  return; }
    if (vendor == "coreboot") { coreboot(); return; }
    tianocore();
  }

  void enableSecureBoot(boolean on) { if (on) { secureBoot = 1; } else { secureBoot = 0; } }
  void enableCsm(boolean on) { if (on) { csm = 1; } else { csm = 0; } }

  String uefiRevision()     { return specRevision; }
  boolean supportsSecureBoot() { return secureBoot == 1; }
  boolean hasCsm()          { return csm == 1; }
  boolean hasRuntimeServices() { return runtimeServices == 1; }
  String esp()              { return espLabel; }

  < True if this firmware can hand off to the given OS-side bootloader name. >
  < Modeled: UEFI firmware can launch any EFI loader; a legacy loader needs CSM. >
  boolean canLaunch(String loaderName) {
    if (loaderName == "GRUB" || loaderName == "BOOTMGR"
        || loaderName == "boot.efi" || loaderName == "systemd-boot") {
      return true;
    }
    < non-EFI loaders require the Compatibility Support Module >
    return csm == 1;
  }
}