Skip to content

Commit

Permalink
Merge pull request #1 from juliuskoskela/ghaf_integration
Browse files Browse the repository at this point in the history
Implement building with Nix flake
  • Loading branch information
juliuskoskela authored Jul 26, 2023
2 parents b1ae15c + eeab31d commit 1bfc052
Show file tree
Hide file tree
Showing 9 changed files with 1,227 additions and 40 deletions.
1,050 changes: 1,050 additions & 0 deletions 0001-Virtual-BPMP-drivers.patch

Large diffs are not rendered by default.

28 changes: 0 additions & 28 deletions bpmp-virt-kernel.nix

This file was deleted.

61 changes: 61 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 32 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Copyright 2023 TII (SSRC) and the Ghaf contributors
# SPDX-License-Identifier: Apache-2.0
{
description = "bpmp-virt";

inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-22.11";
flake-utils.url = "github:numtide/flake-utils";
};

outputs = {
self,
nixpkgs,
flake-utils,
}: let
systems = with flake-utils.lib.system; [
x86_64-linux
aarch64-linux
];
in
# Combine list of attribute sets together
nixpkgs.lib.foldr nixpkgs.lib.recursiveUpdate {} [
(flake-utils.lib.eachSystem systems (system: {
formatter = nixpkgs.legacyPackages.${system}.alejandra;
}))

{
nixosModules.bpmp-virt-host = ./nixosModules/bpmp-virt-host.nix;
nixosModules.bpmp-virt-guest = ./nixosModules/bpmp-virt-guest.nix;
}
];
}
18 changes: 18 additions & 0 deletions generate_kernel_patch_for_drivers.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash

set -euo pipefail

[[ ! -d linux-tegra-5.10 ]] && git clone https://github.com/OE4T/linux-tegra-5.10 --branch oe4t-patches-l4t-r35.3.ga --single-branch linux-tegra-5.10

pushd linux-tegra-5.10
git reset --hard
git clean -xdf

cp -Rv ../drivers/bpmp-{guest,host}-proxy ./drivers/
cat ../drivers/Kconfig >> drivers/Kconfig
cat ../drivers/Makefile >> drivers/Makefile

git add .
git commit -m "Virtual BPMP drivers"
git format-patch -k -1 -o ..
popd
34 changes: 34 additions & 0 deletions nixosModules/bpmp-virt-common.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Copyright 2023 TII (SSRC) and the Ghaf contributors
# SPDX-License-Identifier: Apache-2.0
{lib, ...}: {
boot.kernelPatches = [
{
name = "BPMP Driver patch";
patch = ../0001-Virtual-BPMP-drivers.patch;
}
{
name = "VFIO reset patch";
patch = ../0002-vfio_platform-reset-required-false.patch;
}
{
name = "BPMP support patch";
patch = ../0003-bpmp-support-bpmp-virt.patch;
}
{
name = "BPMP kernel configuration";
patch = null;
extraStructuredConfig = with lib.kernel; {
CONFIG_HOTPLUG_PCI = yes;
CONFIG_PCI_DEBUG = yes;
CONFIG_PCI_HOST_GENERIC = yes;
CONFIG_PCI_STUB = yes;
CONFIG_VFIO = yes;
CONFIG_VFIO_IOMMU_TYPE1 = yes;
CONFIG_VIRTIO_MMIO = yes;
CONFIG_VIRTIO_PCI = yes;
CONFIG_HOTPLUG_PCI_ACPI = yes;
CONFIG_PCI_HOST_COMMON = yes;
};
}
];
}
16 changes: 16 additions & 0 deletions nixosModules/bpmp-virt-guest.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2023 TII (SSRC) and the Ghaf contributors
# SPDX-License-Identifier: Apache-2.0
{lib, ...}: {
imports = [
./bpmp-virt-common.nix
];
boot.kernelPatches = [
{
name = "BPMP virt enable guest";
patch = null;
extraStructuredConfig = with lib.kernel; {
TEGRA_BPMP_GUEST_PROXY = yes;
};
}
];
}
16 changes: 16 additions & 0 deletions nixosModules/bpmp-virt-host.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2023 TII (SSRC) and the Ghaf contributors
# SPDX-License-Identifier: Apache-2.0
{lib, ...}: {
imports = [
./bpmp-virt-common.nix
];
boot.kernelPatches = [
{
name = "BPMP virt enable host";
patch = null;
extraStructuredConfig = with lib.kernel; {
TEGRA_BPMP_HOST_PROXY = yes;
};
}
];
}
12 changes: 0 additions & 12 deletions overlay-config.nix

This file was deleted.

0 comments on commit 1bfc052

Please sign in to comment.