h
Size: a a a
h
ᅠᅠ
AD
ᅠᅠ
AD
2
AD
AD
ᅠᅠ
@name E2NIX Kernel
@inputs EGP_S:array USB:array MainKeyboard:string
@outputs
@persist Procs:table Procs_counter:number Config:table
@persist NULL:number
@trigger
# consts
NULL = 0
True = 1
False = 1
# user config
TTY_FONTSIZE = 15
# General configuration
if (first() | duped()) {
Config = table(
"init_list" = array(
"writer_start",
"tty_start"
#"keyboard_listener"
)
)
}
#
# Common proccess entry:
# pid: 1-65565
# in: String
# out: String
# children: Array<PID>
# parent: PID OR 0
# data: Table # for local proccess data
#
# Awake: called when somebody wrote something into input
#
function table proc_create(Parent:number) {
Procs_counter += 1
local Obj = table(
"pid" = Procs_counter,
"in" = "",
"out" = "",
"children" = array(),
"parent" = Parent
)
Procs[Procs_counter, table] = Obj
return Obj
}
function proc_in_write(ProcPtr:table, Data:string) {
ProcPtr["in", string] = ProcPtr["in", string] + Data
local Awake = ProcPtr["awake", string]
if (Awake != "") {
Awake(ProcPtr)
}
}
function string proc_in_flush(ProcPtr:table) {
local Buffer = ProcPtr["in", string]
ProcPtr["in", string] = ""
return Buffer
}
## $USRSPC USERSPACE BEGINS HERE
function tty_start(Parent:number) {
local Obj = proc_create(Parent)
# Only 1 screen now
Obj["data", table] = table("egpid" = 1, "egp" = EGP_S[1, wirelink], "lines" = array())
# listen to stdin
Obj["awake", string] = "tty_write"
}
function tty_write(ProcPtr:table) {
local Input = proc_in_flush(ProcPtr)
print(Input)
}
function tty_clear(ProcPtr:table) {
ProcPtr["data", table]["lines", array] = array()
ProcPtr["egp", wirelink]:egpClear()
}
## init
function number writer_start(Parent:number) {
local Proc = proc_create(Parent)
#Init_P = Procs[1, table]
#proc_in_write(Init_P, "Hello world!")
return True
}
## USERSPACE ENDS HERE !!!
## INITSPACE BEGINS HERE
function e2rc_awake(ProcPtr:table) {
# flush input
local Input = proc_in_flush(ProcPtr)
}
function e2rc_start() {
local Proc = proc_create(0)
Proc["awake", string] = "e2rc_awake"
ToInit = Config["init_list", array]
# initialize
foreach (K,V:string=ToInit) {
V(Proc["pid", number])
}
}
## INITSPACE ENDS HERE !!!
## INIT CONFIGURATION SPACE BEGINS HERE
CONFIG_INIT_RC_START = "e2rc_start"
## INIT CONFIGURATION SPACEENDS HERE !!!
function os_start() {
EgpControllers = table()
Procs_counter = 0
Procs = table()
CONFIG_INIT_RC_START()
}
function bios_start() {
os_start()
}
if (first() || duped()) {
bios_start()
}
ᅠᅠ
AD
ᅠᅠ
ᅠᅠ
AD
AD
h
ᅠᅠ
AD