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 {
|
|
inputs = [ pkgs.genodePackages.ahci_drv ];
|
|
configFile = pkgs.writeText "ahci_drv.dhall" ''
|
|
let Genode = env:DHALL_GENODE
|
|
|
|
let Init = Genode.Init
|
|
|
|
in Init.Child.flat
|
|
Init.Child.Attributes::{
|
|
, binary = "ahci_drv"
|
|
, 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" }
|
|
}
|
|
]
|
|
}
|
|
}
|
|
'';
|
|
};
|
|
|
|
};
|
|
|
|
}
|