parent
a1f9effb3c
commit
a2a152b68a
@ -0,0 +1,170 @@
|
||||
let Genode = env:DHALL_GENODE
|
||||
|
||||
let Prelude = Genode.Prelude
|
||||
|
||||
let XML = Prelude.XML
|
||||
|
||||
let VFS = Genode.VFS
|
||||
|
||||
let Init = Genode.Init
|
||||
|
||||
let Child = Init.Child
|
||||
|
||||
in λ(params : { bash : Text, coreutils : Text }) →
|
||||
let init =
|
||||
Init::{
|
||||
, verbose = True
|
||||
, routes =
|
||||
[ Init.ServiceRoute.parent "Timer"
|
||||
, Init.ServiceRoute.parent "Rtc"
|
||||
]
|
||||
, children = toMap
|
||||
{ vfs =
|
||||
Child.flat
|
||||
Child.Attributes::{
|
||||
, binary = "vfs"
|
||||
, provides = [ "File_system" ]
|
||||
, resources = Genode.Init.Resources::{
|
||||
, caps = 256
|
||||
, ram = Genode.units.MiB 8
|
||||
}
|
||||
, routes =
|
||||
Prelude.List.map
|
||||
Text
|
||||
Init.ServiceRoute.Type
|
||||
Init.ServiceRoute.parent
|
||||
[ "File_system", "Rtc" ]
|
||||
, config = Init.Config::{
|
||||
, content =
|
||||
[ VFS.vfs
|
||||
[ VFS.dir
|
||||
"dev"
|
||||
[ VFS.dir "pipes" [ VFS.leaf "pipe" ]
|
||||
, VFS.leaf "log"
|
||||
, VFS.leaf "null"
|
||||
, VFS.leaf "rtc"
|
||||
, VFS.leaf "zero"
|
||||
]
|
||||
, VFS.dir
|
||||
"usr"
|
||||
[ VFS.dir
|
||||
"bin"
|
||||
[ VFS.symlink
|
||||
"env"
|
||||
"${params.coreutils}/bin/env"
|
||||
]
|
||||
]
|
||||
, VFS.dir "ram" [ VFS.leaf "ram" ]
|
||||
, VFS.dir
|
||||
"nix"
|
||||
[ VFS.dir
|
||||
"store"
|
||||
[ VFS.fs VFS.FS::{ label = "nix-store" } ]
|
||||
]
|
||||
, VFS.inline
|
||||
"script.sh"
|
||||
''
|
||||
bash --version
|
||||
bash -c "bash --version"
|
||||
''
|
||||
]
|
||||
]
|
||||
, policies =
|
||||
[ Init.Config.Policy::{
|
||||
, service = "File_system"
|
||||
, label = Init.LabelSelector.prefix "shell"
|
||||
, attributes = toMap
|
||||
{ root = "/", writeable = "yes" }
|
||||
}
|
||||
, Init.Config.Policy::{
|
||||
, service = "File_system"
|
||||
, label = Init.LabelSelector.prefix "vfs_rom"
|
||||
, attributes = toMap { root = "/" }
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
, vfs_rom =
|
||||
Child.flat
|
||||
Child.Attributes::{
|
||||
, binary = "cached_fs_rom"
|
||||
, provides = [ "ROM" ]
|
||||
, resources = Init.Resources::{
|
||||
, caps = 256
|
||||
, ram = Genode.units.MiB 32
|
||||
}
|
||||
, config = Init.Config::{
|
||||
, policies =
|
||||
[ Init.Config.Policy::{
|
||||
, service = "ROM"
|
||||
, label = Init.LabelSelector.prefix "shell"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
, shell =
|
||||
Child.flat
|
||||
Child.Attributes::{
|
||||
, binary = "${params.bash}/bin/bash"
|
||||
, exitPropagate = True
|
||||
, resources = Genode.Init.Resources::{
|
||||
, caps = 256
|
||||
, ram = Genode.units.MiB 8
|
||||
}
|
||||
, routes =
|
||||
Prelude.List.map
|
||||
Text
|
||||
Init.ServiceRoute.Type
|
||||
( λ(label : Text) →
|
||||
Init.ServiceRoute.parentLabel
|
||||
"ROM"
|
||||
(Some label)
|
||||
(Some label)
|
||||
)
|
||||
[ "libc.lib.so"
|
||||
, "libm.lib.so"
|
||||
, "posix.lib.so"
|
||||
, "vfs.lib.so"
|
||||
]
|
||||
, config = Genode.Init.Config::{
|
||||
, attributes = toMap { ld_verbose = "true" }
|
||||
, content =
|
||||
let env =
|
||||
λ(key : Text) →
|
||||
λ(value : Text) →
|
||||
XML.leaf
|
||||
{ name = "env"
|
||||
, attributes = toMap { key, value }
|
||||
}
|
||||
|
||||
let arg =
|
||||
λ(value : Text) →
|
||||
XML.leaf
|
||||
{ name = "arg"
|
||||
, attributes = toMap { value }
|
||||
}
|
||||
|
||||
in [ XML.leaf
|
||||
{ name = "libc"
|
||||
, attributes = toMap
|
||||
{ stdin = "/dev/null"
|
||||
, stdout = "/dev/log"
|
||||
, stderr = "/dev/log"
|
||||
, pipe = "/dev/pipe"
|
||||
, rtc = "/dev/rtc"
|
||||
}
|
||||
}
|
||||
, VFS.vfs [ VFS.fs VFS.FS::{ label = "root" } ]
|
||||
, env "TERM" "screen"
|
||||
, env
|
||||
"PATH"
|
||||
"${params.coreutils}/bin:${params.bash}/bin"
|
||||
, arg "bash"
|
||||
, arg "/script.sh"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
in Init.toChild init Init.Attributes::{=}
|
@ -0,0 +1,24 @@
|
||||
{
|
||||
name = "bash";
|
||||
machine = { pkgs, ... }: {
|
||||
genode.init.children.bash = {
|
||||
configFile = pkgs.writeText "bash.child.dhall" ''
|
||||
${
|
||||
./bash.dhall
|
||||
} { bash = "${pkgs.genodePackages.bash}", coreutils = "${pkgs.coreutils}" }
|
||||
'';
|
||||
inputs = with pkgs.genodePackages; [
|
||||
bash
|
||||
cached_fs_rom
|
||||
libc
|
||||
posix
|
||||
vfs
|
||||
vfs_pipe
|
||||
];
|
||||
};
|
||||
};
|
||||
testScript = ''
|
||||
start_all()
|
||||
machine.wait_until_serial_output('child "bash" exited with exit value 0')
|
||||
'';
|
||||
}
|
Loading…
Reference in new issue