SLHardDrive.sleela
lib/cpu/SLHardDrive.sleela · 102 line(s) · sleela
<< lib/cpu/SLHardDrive.sleela
SLeeLa Standard Library Definition.
Definition: Defines SLHardDrive — persistent block storage (an HDD or SSD).
It is the slowest, largest tier of the storage hierarchy and the device the
OS boots from and loads programs out of. It presents a block interface
(read/write by block number) and crosses the explicit VM/OS bridge to the
native file-backed store.
Models capacity in blocks, block size, media kind (spinning vs. solid-state),
and I/O counters.
Family: cpu. Native file-backed store via bridge. >>
#sleela 2.5
material;
class SLHardDrive {
< ---- 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 = 10245;
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; }
< rotational >
static final int MEDIA_HDD = 0;
< solid-state >
static final int MEDIA_SSD = 1;
String name;
int blockCount;
int blockBytes;
int media;
int handle;
int reads;
int writes;
void configure(String driveName, int blocks, int bsize, int mediaKind) {
name = driveName; blockCount = blocks; blockBytes = bsize; media = mediaKind;
handle = 0; reads = 0; writes = 0;
}
< Mount the native file-backed store, creating it if absent. >
int mount(String path) {
handle = native sleela_blockdev_open(path, blockCount, blockBytes);
return handle;
}
boolean inRange(int block) { return block >= 0 && block < blockCount; }
int readBlock(int block) {
if (!inRange(block) || handle == 0) { return -1; }
reads = reads + 1;
return native sleela_blockdev_read(handle, block);
}
int writeBlock(int block, int payloadHandle) {
if (!inRange(block) || handle == 0) { return -1; }
writes = writes + 1;
return native sleela_blockdev_write(handle, block, payloadHandle);
}
void unmount() { if (handle != 0) { native sleela_blockdev_close(handle); handle = 0; } }
int capacityBlocks() { return blockCount; }
int capacityBytes() { return blockCount * blockBytes; }
boolean solidState() { return media == MEDIA_SSD; }
String driveName() { return name; }
}