Skip to content

Commit

Permalink
nix: Add Xilinx QEMU
Browse files Browse the repository at this point in the history
Signed-off-by: Nick Spinale <[email protected]>
  • Loading branch information
nspin committed Jun 10, 2024
1 parent 1efeda6 commit 2d44e56
Show file tree
Hide file tree
Showing 4 changed files with 119 additions and 14 deletions.
12 changes: 2 additions & 10 deletions hacking/nix/scope/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -261,15 +261,7 @@ superCallPackage ../rust-utils {} self //

opensbi = callPackage ./opensbi.nix {};

qemuForSeL4 = callPackage ./qemu {
hostCpuTargets = [
"arm-softmmu"
"aarch64-softmmu"
"riscv32-softmmu"
"riscv64-softmmu"
"i386-softmmu"
"x86_64-softmmu"
];
};
qemuForSeL4 = callPackage ./qemu {};
qemuForSeL4Xilinx = callPackage ./qemu/xilinx.nix {};

})
16 changes: 12 additions & 4 deletions hacking/nix/scope/qemu/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

{ lib, stdenv
, buildPackages
, fetchurl, fetchpatch
, fetchurl, fetchpatch, fetchFromGitHub, fetchFromGitLab
, python3Packages
, pkg-config, ninja, meson, perl
, zlib, lzo, glib
Expand All @@ -15,10 +15,18 @@
, texinfo
, snappy, libaio, libtasn1, gnutls, nettle, curl
, attr, libcap, libcap_ng, libslirp
, hostCpuTargets ? []

, hostCpuTargets ? [
"arm-softmmu"
"aarch64-softmmu"
"riscv32-softmmu"
"riscv64-softmmu"
"i386-softmmu"
"x86_64-softmmu"
]
}:

stdenv.mkDerivation rec {
stdenv.mkDerivation (finalAttrs: with finalAttrs; {
pname = "qemu";
version = "9.0.0";

Expand Down Expand Up @@ -94,4 +102,4 @@ stdenv.mkDerivation rec {
preBuild = ''
cd build
'';
}
})
89 changes: 89 additions & 0 deletions hacking/nix/scope/qemu/xilinx.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
#
# Copyright 2024, Colias Group, LLC
#
# SPDX-License-Identifier: BSD-2-Clause
#

{ lib, stdenv
, fetchFromGitHub, fetchFromGitLab
, python3, dtc
, qemuForSeL4
}:

let
version = "xilinx_v2024.1";

src = fetchFromGitHub {
owner = "Xilinx";
repo = "qemu";
rev = version;
hash = "sha256-FKaoTRTftaIId+VkjMqKzcdO48ngQirymH4XLzMm+t8=";
};

keycodemapdb = fetchFromGitLab {
owner = "qemu-project";
repo = "keycodemapdb";
rev = "f5772a62ec52591ff6870b7e8ef32482371f22c6";
hash = "sha256-GbZ5mrUYLXMi0IX4IZzles0Oyc095ij2xAsiLNJwfKQ=";
};

berkeley-softfloat-3 = fetchFromGitLab {
owner = "qemu-project";
repo = "berkeley-softfloat-3";
rev = "b64af41c3276f97f0e181920400ee056b9c88037";
hash = "sha256-Yflpx+mjU8mD5biClNpdmon24EHg4aWBZszbOur5VEA=";
};

berkeley-testfloat-3 = fetchFromGitLab {
owner = "qemu-project";
repo = "berkeley-testfloat-3";
rev = "40619cbb3bf32872df8c53cc457039229428a263";
hash = "sha256-EBz1uYnjehCtJqrSFzERH23N5ELZU3gGM26JnsGFcWg=";
};

devicetrees = stdenv.mkDerivation {
name = "devicetrees";
src = fetchFromGitHub {
owner = "Xilinx";
repo = "qemu-devicetrees";
rev = version;
hash = "sha256-FYNo/2XVq/viWIB+yFDwzY5eaosC5omQZ3LyypMu2bM=";
};
nativeBuildInputs = [
python3
dtc
];
dontConfigure = true;
dontFixup = true;
installPhase = ''
mv LATEST $out
'';
};

in

(qemuForSeL4.override {
hostCpuTargets = [
"aarch64-softmmu"
];
}).overrideAttrs (finalAttrs: previousAttrs: {
inherit version src;

postPatch = (previousAttrs.postPatch or "") + ''
pushd subprojects
ln -sf ${keycodemapdb} keycodemapdb
d=berkeley-softfloat-3
cp -r --no-preserve=owner,mode ${berkeley-softfloat-3} $d
cp -r packagefiles/$d/* $d
d=berkeley-testfloat-3
cp -r --no-preserve=owner,mode ${berkeley-testfloat-3} $d
cp -r packagefiles/$d/* $d
popd
'';

passthru = (previousAttrs.passthru or {}) // {
inherit devicetrees;
};
})
16 changes: 16 additions & 0 deletions hacking/nix/scope/worlds.nix
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,22 @@ in rec {
board = "zcu102";
config = "debug";
};
canSimulate = true;
mkInstanceForPlatform = platUtils.qemu.mkMkInstanceForPlatform {
mkQemuCmd = loader: [
"${pkgsBuildBuild.this.qemuForSeL4Xilinx}/bin/qemu-system-aarch64"
# "${pkgsBuildBuild.this.qemuForSeL4}/bin/qemu-system-aarch64"
"-machine" "xlnx-zcu102"
# "-machine" "arm-generic-fdt"
# "-hw-dtb" "${pkgsBuildBuild.this.qemuForSeL4Xilinx.devicetrees}/SINGLE_ARCH//zcu102-arm.dtb"
"-m" "size=4G"
"-nographic"
"-serial" "mon:stdio"
"-device" "loader,file=${loader},addr=0x40000000,cpu-num=0"
"-device" "loader,addr=0xfd1a0104,data=0x0000000e,data-len=4"
];
};

};
};

Expand Down

0 comments on commit 2d44e56

Please sign in to comment.