175 lines
5.3 KiB
Nix
175 lines
5.3 KiB
Nix
{ config, pkgs, lib, ... }:
|
|
|
|
with lib;
|
|
let toDhall = lib.generators.toDhall { };
|
|
in {
|
|
imports = [ ./ahci.nix ./framebuffer.nix ./nic.nix ./usb.nix ];
|
|
|
|
options.hardware.genode.platform.policies = lib.mkOption {
|
|
type = with types; listOf path;
|
|
default = [ ];
|
|
description = ''
|
|
List of policies to append to the Genode platform driver.
|
|
Type is Init.Config.Policy.Type.
|
|
'';
|
|
};
|
|
|
|
config = let
|
|
ahciEris = lib.getEris "bin" pkgs.genodePackages.ahci_drv;
|
|
partBlockEris = lib.getEris "bin" pkgs.genodePackages.part_block;
|
|
|
|
usbEris = lib.attrsets.mapAttrs (_: lib.getEris "bin") {
|
|
inherit (pkgs.genodePackages) usb_block_drv usb_drv;
|
|
};
|
|
|
|
ahciConfig = with config.hardware.genode.ahci;
|
|
lib.optionalString enable ''
|
|
, ahci_driver = Some ${
|
|
toDhall {
|
|
binary = ahciEris.cap;
|
|
atapi = atapiSupport;
|
|
}
|
|
}
|
|
'';
|
|
|
|
usbConfig = with config.hardware.genode.usb;
|
|
lib.optionalString enable ''
|
|
, usb_block = Some { binary = "${usbEris.usb_block_drv.cap}" }
|
|
, usb_driver = Some ${
|
|
toDhall {
|
|
binary = usbEris.usb_drv.cap;
|
|
bios_handoff = biosHandoff;
|
|
ehci = ehciSupport;
|
|
ohci = ohciSupport;
|
|
uhci = uhciSupport;
|
|
xhci = xhciSupport;
|
|
}
|
|
}
|
|
'';
|
|
|
|
managerConfig = pkgs.writeText "device_manager.dhall" ''
|
|
let Manager = ${pkgs.genodePackages.device_manager.dhall}/package.dhall
|
|
|
|
in Manager.toChildAttributes
|
|
Manager::{
|
|
, part_block.binary = "${partBlockEris.cap}"
|
|
${ahciConfig}
|
|
${usbConfig}
|
|
}
|
|
'';
|
|
in {
|
|
|
|
genode.core.children.acpi_drv = {
|
|
package = pkgs.genodePackages.acpi_drv;
|
|
configFile = pkgs.writeText "acpi_drv.dhall" ''
|
|
let Sigil = env:DHALL_SIGIL
|
|
|
|
let Init = Sigil.Init
|
|
|
|
let label = λ(_ : Text) → { local = _, route = _ }
|
|
|
|
in λ(binary : Text) →
|
|
Init.Child.flat
|
|
Init.Child.Attributes::{
|
|
, binary
|
|
, resources = Init.Resources::{
|
|
, caps = 400
|
|
, ram = Sigil.units.MiB 4
|
|
, constrainPhys = True
|
|
}
|
|
, romReports = [ label "acpi", label "smbios_table" ]
|
|
, routes =
|
|
[ Init.ServiceRoute.parent "IRQ"
|
|
, Init.ServiceRoute.parent "IO_MEM"
|
|
, Init.ServiceRoute.parent "IO_PORT"
|
|
]
|
|
}
|
|
'';
|
|
};
|
|
|
|
genode.core.children.platform_drv = {
|
|
package = pkgs.genodePackages.platform_drv;
|
|
configFile = let
|
|
policies =
|
|
map (policy: ", ${policy}") config.hardware.genode.platform.policies;
|
|
in pkgs.writeText "platform_drv.dhall" ''
|
|
let Sigil = env:DHALL_SIGIL
|
|
|
|
let Init = Sigil.Init
|
|
|
|
in λ(binary : Text) -> Init.Child.flat
|
|
Init.Child.Attributes::{
|
|
, binary
|
|
, resources = Init.Resources::{
|
|
, caps = 800
|
|
, ram = Sigil.units.MiB 4
|
|
, constrainPhys = True
|
|
}
|
|
, reportRoms = let label = "acpi" in [ { local = label, route = label } ]
|
|
, provides = [ "Platform" ]
|
|
, routes =
|
|
[ Init.ServiceRoute.parent "IRQ"
|
|
, Init.ServiceRoute.parent "IO_MEM"
|
|
, Init.ServiceRoute.parent "IO_PORT"
|
|
]
|
|
, config = Init.Config::{
|
|
, policies = [ ${
|
|
toString policies
|
|
} ] : List Init.Config.Policy.Type
|
|
}
|
|
}
|
|
'';
|
|
};
|
|
|
|
genode.core.children.device_manager = lib.mkIf
|
|
(config.hardware.genode.ahci.enable
|
|
|| config.hardware.genode.usb.enable) {
|
|
package = pkgs.genodePackages.device_manager;
|
|
configFile = pkgs.writeText "device_manager.dhall" ''
|
|
let Sigil = env:DHALL_SIGIL
|
|
|
|
in λ(cap : Text) →
|
|
Sigil.Init.Child.flat
|
|
( (${managerConfig}).device_manager
|
|
⫽ { binary = cap
|
|
, resources = Sigil.Init.Resources::{
|
|
, caps = 256
|
|
, ram = Sigil.units.MiB 8
|
|
}
|
|
}
|
|
)
|
|
'';
|
|
};
|
|
|
|
genode.core.children.drivers = {
|
|
package = pkgs.genodePackages.init;
|
|
extraErisInputs = [ partBlockEris ]
|
|
++ lib.optional config.hardware.genode.ahci.enable ahciEris
|
|
++ lib.optionals config.hardware.genode.usb.enable
|
|
(builtins.attrValues usbEris);
|
|
configFile = pkgs.writeText "drivers.dhall" ''
|
|
let Sigil = env:DHALL_SIGIL
|
|
|
|
let childAttrs = (${managerConfig}).drivers
|
|
|
|
in λ(cap : Text) →
|
|
Sigil.Init.Child.flat
|
|
( childAttrs
|
|
⫽ { binary = cap
|
|
, config =
|
|
childAttrs.config
|
|
with policies =
|
|
[ Sigil.Init.Config.Policy::{
|
|
, label = Sigil.Init.LabelSelector.none
|
|
, service = "Block"
|
|
}
|
|
]
|
|
}
|
|
)
|
|
'';
|
|
};
|
|
|
|
};
|
|
|
|
}
|