Merge pull request #331119 from d-brasher/init-amd-ucodegen

amd-ucodegen: init at 0-unstable-2017-06-07
This commit is contained in:
Masum Reza 2024-08-19 18:03:43 +05:30 committed by GitHub
commit c0cdeaff88
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 100 additions and 0 deletions

View file

@ -0,0 +1,60 @@
{
lib,
stdenv,
fetchFromGitHub,
fetchpatch,
nix-update-script,
callPackage,
}:
stdenv.mkDerivation (finalAttrs: {
pname = "amd-ucodegen";
version = "0-unstable-2017-06-07";
src = fetchFromGitHub {
owner = "AndyLavr";
repo = "amd-ucodegen";
rev = "0d34b54e396ef300d0364817e763d2c7d1ffff02";
hash = "sha256-pgmxzd8tLqdQ8Kmmhl05C5tMlCByosSrwx2QpBu3UB0=";
};
strictDeps = true;
patches = [
# Extract get_family function and validate processor family
# instead of processor ID
(fetchpatch {
name = "validate-family-not-id.patch";
url = "https://github.com/AndyLavr/amd-ucodegen/compare/0d34b54e396ef300d0364817e763d2c7d1ffff02...dobo90:amd-ucodegen:7a3c51e821df96910ecb05b22f3e4866b4fb85b2.patch";
hash = "sha256-jvsvu9QgXikwsxjPiTaRff+cOg/YQmKg1MYKyBoMRQI=";
})
];
installPhase = ''
runHook preInstall
install -Dm755 amd-ucodegen $out/bin/amd-ucodegen
runHook postInstall
'';
passthru = {
updateScript = nix-update-script { extraArgs = [ "--version=branch" ]; };
tests.platomav = callPackage ./test-platomav.nix { amd-ucodegen = finalAttrs.finalPackage; };
};
meta = {
description = "Tool to generate AMD microcode files";
longDescription = ''
This tool can be used to generate AMD microcode containers as used by the
Linux kernel. It accepts raw AMD microcode files such as those generated
by [MCExtractor](https://github.com/platomav/MCExtractor.git) as input.
The generated output file can be installed in /lib/firmware/amd-ucode.
'';
homepage = "https://github.com/AndyLavr/amd-ucodegen";
license = lib.licenses.gpl2Only;
platforms = lib.platforms.unix;
mainProgram = "amd-ucodegen";
maintainers = with lib.maintainers; [ d-brasher ];
};
})

View file

@ -0,0 +1,40 @@
{
stdenvNoCC,
fetchFromGitHub,
amd-ucodegen,
}:
stdenvNoCC.mkDerivation {
name = "amd-ucodegen-test-platomav";
meta.timeout = 60;
# Repository of dumped CPU microcodes
src = fetchFromGitHub {
owner = "platomav";
repo = "CPUMicrocodes";
rev = "dfc37d654cbe294acb0ec0274763321507dd7838";
hash = "sha256-Va+ErKID5iyKEee61tlrZwSpujxwMYPC+MAgZKUkrrM=";
};
nativeBuildInputs = [ amd-ucodegen ];
buildPhase = ''
runHook preBuild
echo -n "Test normal behavior with single input... "
[ "$(amd-ucodegen AMD/cpu00B40F40_ver0B40401A_2024-06-14_544DFCB8.bin)" \
== "CPU type 0xb40f40 [0xb440], file AMD/cpu00B40F40_ver0B40401A_2024-06-14_544DFCB8.bin" ]
echo "OK"
echo -n "Check output hash... "
[ "$(sha256sum microcode_amd_fam1ah.bin)" \
== "17f25ec78fa677803684e77ce01a21344b4b33463a964f61bae51b173543b190 microcode_amd_fam1ah.bin" ]
echo "OK"
echo -n "Ensure fail when bad processor ID... "
[ "$(amd-ucodegen AMD/cpu00000F00_ver02000008_2007-06-14_C3A923BB.bin 2>&1)" \
== "Bad processor ID 0x0n" ]
echo "OK"
touch $out
runHook postBuild
'';
}