Genode Packages collection https://git.sr.ht/~ehmry/genodepkgs/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

163 lines
6.4 KiB

-- SPDX-License-Identifier: CC0-1.0
let Genode = env:DHALL_GENODE
let Prelude = Genode.Prelude
let XML = Prelude.XML
let Init = Genode.Init
let Child = Init.Child
let Resources = Init.Resources
let ServiceRoute = Init.ServiceRoute
let Vfs/inline =
λ(name : Text)
→ λ(body : Text)
→ XML.element
{ name = "inline"
, attributes = toMap { name = name }
, content = [ XML.text body ]
}
let toVbox =
λ ( params
: { vdiFilename : Text
, vdiPkg : Text
, vdiUuid : Text
, memorySize : Natural
, vmName : Text
}
)
→ let vboxConfig =
''
<VirtualBox xmlns="http://www.virtualbox.org/" version="1.14-freebsd">
<Machine uuid="{37ab43a5-38d8-4491-93f5-5b0b077f5c32}" name="ubuntu_16_04_64" OSType="Ubuntu_64" snapshotFolder="Snapshots" lastStateChange="2018-01-23T18:40:00Z">
<MediaRegistry>
<HardDisks>
<HardDisk uuid="{${params.vdiUuid}}" location="${params.vdiFilename}" format="VDI" type="Normal"/>
</HardDisks>
<DVDImages/>
</MediaRegistry>
<Hardware>
<CPU count="2">
<PAE enabled="true"/>
<LongMode enabled="true"/>
<HardwareVirtExLargePages enabled="false"/>
</CPU>
<Memory RAMSize="${Prelude.Natural.show
params.memorySize}"/>
<HID Pointing="USBTablet"/>
<Display VRAMSize="20"/>
<RemoteDisplay enabled="false"/>
<BIOS>
<IOAPIC enabled="true"/>
</BIOS>
<USB>
<Controllers/>
</USB>
<Network>
<Adapter slot="0" enabled="true" MACAddress="0800271D7901" cable="true" type="82540EM">
<BridgedInterface/>
</Adapter>
</Network>
<UART>
<Port slot="0" enabled="false" IOBase="0x3f8" IRQ="4" hostMode="Disconnected"/>
<Port slot="1" enabled="false" IOBase="0x2f8" IRQ="3" hostMode="Disconnected"/>
</UART>
<LPT>
<Port slot="0" enabled="false" IOBase="0x378" IRQ="7"/>
<Port slot="1" enabled="false" IOBase="0x378" IRQ="7"/>
</LPT>
<AudioAdapter controller="HDA" driver="OSS" enabled="false"/>
<RTC localOrUTC="UTC"/>
<SharedFolders/>
</Hardware>
<StorageControllers>
<StorageController name="SATA" type="AHCI" PortCount="4" useHostIOCache="true" Bootable="true" IDE0MasterEmulationPort="0" IDE0SlaveEmulationPort="1" IDE1MasterEmulationPort="2" IDE1SlaveEmulationPort="3">
<AttachedDevice type="HardDisk" port="0" device="0">
<Image uuid="{${params.vdiUuid}}"/>
</AttachedDevice>
</StorageController>
</StorageControllers>
</Machine>
</VirtualBox>
''
in Child.flat
Child.Attributes::{
, binary = "virtualbox5"
, config = Init.Config::{
, attributes = toMap
{ vbox_file = "machine.vbox", vm_name = params.vmName }
, content =
[ XML.leaf
{ name = "libc"
, attributes = toMap
{ stdout = "/dev/log"
, stderr = "/dev/log"
, rtc = "/dev/rtc"
}
}
, XML.element
{ name = "vfs"
, attributes = XML.emptyAttributes
, content =
let tag =
λ(name : Text)
→ XML.leaf
{ name = name
, attributes = XML.emptyAttributes
}
in [ Vfs/inline "machine.vbox" vboxConfig
, XML.element
{ name = "dir"
, attributes = toMap { name = "dev" }
, content = [ tag "log", tag "rtc" ]
}
, XML.leaf
{ name = "fs"
, attributes = toMap { writeable = "yes" }
}
, XML.element
{ name = "import"
, attributes = toMap { overwrite = "no" }
, content =
[ XML.leaf
{ name = "fs"
, attributes = toMap
{ label = "nix/store"
, root = "${params.vdiPkg}"
}
}
]
}
]
}
]
}
, resources = Resources::{
, caps = 1024
, ram =
Genode.units.MiB 128 + Genode.units.MiB params.memorySize
}
, routes =
[ ServiceRoute.parent "File_system"
, ServiceRoute.parent "Nic"
, ServiceRoute.parent "Nitpicker"
, ServiceRoute.parent "Rtc"
, ServiceRoute.parent "Timer"
, ServiceRoute.parent "VM"
, ServiceRoute.parent "Report"
, ServiceRoute.parentLabel
"ROM"
(Some "platform_info")
(Some "platform_info")
]
}
in toVbox