SLGuestDevice.sleela
lib/cpu/SLGuestDevice.sleela · 88 line(s) · sleela
<< lib/cpu/SLGuestDevice.sleela
SLeeLa Standard Library Definition.
Definition: Defines SLGuestDevice — the base class for virtual devices the
hypervisor exposes to a guest VM. A guest kernel talks to these through
memory-mapped registers (guest MMIO addresses); a register access that
falls in a device's window is a VM-exit the hypervisor routes to the device
model. This is step 3 of the OS-VM roadmap: the minimum device surface a
guest OS expects (timer, interrupt controller, console, block device).
Each device owns an MMIO base/size and read()/write() register handlers plus
an optional interrupt line it can raise into the guest.
Family: cpu. Base of the guest device hierarchy. >>
#sleela 2.5
material;
class SLGuestDevice {
< ---- 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 = 10227;
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-06";
< 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; }
String name;
int mmioBase;
int mmioSize;
< guest IRQ this device raises, or -1 >
int irqLine;
int irqPending;
int accesses;
void configure(String deviceName, int base, int size, int irq) {
name = deviceName; mmioBase = base; mmioSize = size; irqLine = irq;
irqPending = 0; accesses = 0;
}
boolean owns(int addr) { return addr >= mmioBase && addr < mmioBase + mmioSize; }
int registerOf(int addr) { return addr - mmioBase; }
< Default MMIO handlers; concrete devices override. >
int read(int addr) { accesses = accesses + 1; return 0; }
void write(int addr, int value) { accesses = accesses + 1; }
< Interrupt protocol: a device raises its line; the guest's interrupt >
< controller later acknowledges it. >
void raiseIRQ() { if (irqLine >= 0) { irqPending = 1; } }
boolean irqRaised() { return irqPending == 1; }
void clearIRQ() { irqPending = 0; }
int irq() { return irqLine; }
String deviceName() { return name; }
int accessCount() { return accesses; }
}