Emery Hemingway
2afd2d08cc
Require that all init children declared by Nix be declared with an absolute path to the program binary.
66 lines
1.9 KiB
Nix
66 lines
1.9 KiB
Nix
{ config, pkgs, lib, ... }:
|
|
|
|
with lib;
|
|
|
|
{
|
|
options.hardware.genode.ahci = {
|
|
enable = lib.mkEnableOption "AHCI (SATA) block driver";
|
|
};
|
|
|
|
config = let cfg = config.hardware.genode.ahci;
|
|
in {
|
|
|
|
hardware.genode.platform.policies = lib.optional cfg.enable
|
|
(builtins.toFile ("ahci.platform-policy.dhall") ''
|
|
let Genode = env:DHALL_GENODE
|
|
|
|
in Genode.Init.Config.Policy::{
|
|
, service = "Platform"
|
|
, label = Genode.Init.LabelSelector.prefix "ahci_drv"
|
|
, content =
|
|
[ Genode.Prelude.XML.leaf
|
|
{ name = "pci", attributes = toMap { class = "AHCI" } }
|
|
]
|
|
}
|
|
'');
|
|
|
|
genode.core.children.ahci_drv = lib.mkIf cfg.enable {
|
|
binary = "${pkgs.genodePackages.ahci_drv}/bin/ahci_drv";
|
|
configFile = pkgs.writeText "ahci_drv.dhall" ''
|
|
let Genode = env:DHALL_GENODE
|
|
|
|
let Init = Genode.Init
|
|
|
|
in λ(binary : Text) -> Init.Child.flat
|
|
Init.Child.Attributes::{
|
|
, binary
|
|
, resources = Init.Resources::{
|
|
, caps = 400
|
|
, ram = Genode.units.MiB 10
|
|
, constrainPhys = True
|
|
}
|
|
, romReports = [ { local = "ports", route = "ahci_ports" } ]
|
|
, routes =
|
|
[ Init.ServiceRoute.parent "IRQ"
|
|
, Init.ServiceRoute.parent "IO_MEM"
|
|
, Init.ServiceRoute.parent "IO_PORT"
|
|
]
|
|
, config = Init.Config::{
|
|
, policies =
|
|
[ Init.Config.Policy::{
|
|
, service = "Block"
|
|
, label = Init.LabelSelector.prefix "part_block"
|
|
, attributes = toMap { device = "${
|
|
toString config.fileSystems."/".block.device
|
|
}", writeable = "yes" }
|
|
}
|
|
]
|
|
}
|
|
}
|
|
'';
|
|
};
|
|
|
|
};
|
|
|
|
}
|