summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'sys-firmware')
-rw-r--r--sys-firmware/intel-microcode/Manifest1
-rw-r--r--sys-firmware/intel-microcode/files/intel-microcode2ucode.c-r1166
-rw-r--r--sys-firmware/intel-microcode/intel-microcode-20170707.ebuild48
3 files changed, 215 insertions, 0 deletions
diff --git a/sys-firmware/intel-microcode/Manifest b/sys-firmware/intel-microcode/Manifest
index 4ce2cad68976..197db19058f0 100644
--- a/sys-firmware/intel-microcode/Manifest
+++ b/sys-firmware/intel-microcode/Manifest
@@ -7,3 +7,4 @@ DIST microcode-20160607.tgz 1236385 SHA256 db821eb47af2caa39613caee0eb89a9584b2e
DIST microcode-20160714.tgz 1239344 SHA256 f3a9c6fc93275bf1febc26f7c397ac93ed5f109e47fb52932f6dbd5cfdbc840e SHA512 f9e09b6669a86aafcc77642d6e33acf9326109c3a2bc3e0d62b45a062b9ecbde6605b5a0ae31d4a3ad2b0ed3c6d3aadbd18088431fb72216bfc31fc452b0e342 WHIRLPOOL d62bbce555adc1973465d81463d9ef51cc64f5f0937b555a0b616458afc47823b2512a60eb498d4658e96244430e47bde5f36b2e49d202d41e61914bee6a3a9c
DIST microcode-20161104.tgz 1290125 SHA256 70154ca62ff9b3da6291dfdecc90daaeb399d7290c0d308d719df16dff5ee3d1 SHA512 73a7310c1da5bec7ce82bce5cf7c2aafa3d0189e7524bdebd20e1ea3568cf8242be39d9041fa055fe06e759f98703c5d0a631e57ff185aae3ba3c91dbe83cf7a WHIRLPOOL e811315facf6b7dc80c4a99555d909e1c26aa7904d1f2608de633f7e49f691f5bf6c47973381cd72e4cb8c3b4355651a4c64564c79539ddfa41a007b8f05b5ca
DIST microcode-20170511.tgz 2143617 SHA256 2f77fd2d87403b754d01a66c78a36a8b8ffc16dc3c50fb7aa2c4cd4da7f681a3 SHA512 4e2066096d56430c2df73631f15cf16f2317c1d8ff745d7b7cdd784ebccc2b797565eb52703cce9b4238774dbfdcaecacd892d729b7869fdfd7644008ce74a60 WHIRLPOOL 492e5e5962696636bfb2e181964893ba59798873b71cb9f5d11b1dcb9a1b32acb9e11634b71d880e05f9b71eb4f45dbc72e7a48e1ac4f38dfec816dbecf79b0d
+DIST microcode-20170707.tgz 2908882 SHA256 4fd44769bf52a7ac11e90651a307aa6e56ca6e1a814e50d750ba8207973bee93 SHA512 2f0643c332318e9c818b9a23a996b59086e86e80e649589e43dbab19f13083d6d9505b8557f67b45ce56de0da043c753a14bb146e597b6669f24fe543656c65f WHIRLPOOL bafae318d350bae1ebb6aeb5611e9ffab7d52d2ca836c7b65cb6b86bae9da7ee2c41945e0252cbe1797de4737507948b5260bbe3996d1d7e3fd2489e32452456
diff --git a/sys-firmware/intel-microcode/files/intel-microcode2ucode.c-r1 b/sys-firmware/intel-microcode/files/intel-microcode2ucode.c-r1
new file mode 100644
index 000000000000..4b3ba4b48ed4
--- /dev/null
+++ b/sys-firmware/intel-microcode/files/intel-microcode2ucode.c-r1
@@ -0,0 +1,166 @@
+/*
+ * Convert Intel microcode.dat into individual ucode files
+ * named: intel-ucode/$family-$model-$stepping
+ *
+ * The subdir intel-ucode/ is created in the current working
+ * directory. We get multiple ucodes in the same file, so they
+ * are appended to an existing file. Make sure the directory
+ * is empty before every run of the converter.
+ *
+ * Kay Sievers <kay.sievers@vrfy.org>
+ */
+
+
+#ifndef _GNU_SOURCE
+# define _GNU_SOURCE 1
+#endif
+
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <limits.h>
+#include <stdbool.h>
+#include <inttypes.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <sys/stat.h>
+
+struct microcode_header_intel {
+ unsigned int hdrver;
+ unsigned int rev;
+ unsigned int date;
+ unsigned int sig;
+ unsigned int cksum;
+ unsigned int ldrver;
+ unsigned int pf;
+ unsigned int datasize;
+ unsigned int totalsize;
+ unsigned int reserved[3];
+};
+
+union mcbuf {
+ struct microcode_header_intel hdr;
+ unsigned int i[0];
+ char c[0];
+};
+
+int main(int argc, char *argv[])
+{
+ char *filename = "/lib/firmware/microcode.dat";
+ FILE *f;
+ char line[LINE_MAX];
+ char buf[4000000];
+ union mcbuf *mc;
+ size_t bufsize, count, start;
+ int rc = EXIT_SUCCESS;
+
+ if (argv[1] != NULL)
+ filename = argv[1];
+
+ count = 0;
+ mc = (union mcbuf *) buf;
+ f = fopen(filename, "re");
+ if (f == NULL) {
+ printf("open %s: %m\n", filename);
+ rc = EXIT_FAILURE;
+ goto out;
+ }
+
+ while (fgets(line, sizeof(line), f) != NULL) {
+ if (sscanf(line, "%x, %x, %x, %x",
+ &mc->i[count],
+ &mc->i[count + 1],
+ &mc->i[count + 2],
+ &mc->i[count + 3]) != 4)
+ continue;
+ count += 4;
+ }
+ fclose(f);
+
+ bufsize = count * sizeof(int);
+ printf("%s: %lu(%luk) bytes, %zu integers\n",
+ filename,
+ bufsize,
+ bufsize / 1024,
+ count);
+
+ if (bufsize < sizeof(struct microcode_header_intel))
+ goto out;
+
+ mkdir("intel-ucode", 0750);
+
+ start = 0;
+ for (;;) {
+ size_t size;
+ unsigned int family, model, stepping;
+ unsigned int year, month, day;
+
+ mc = (union mcbuf *) &buf[start];
+
+ if (mc->hdr.totalsize)
+ size = mc->hdr.totalsize;
+ else
+ size = 2000 + sizeof(struct microcode_header_intel);
+
+ if (mc->hdr.ldrver != 1 || mc->hdr.hdrver != 1) {
+ printf("unknown version/format:\n");
+ rc = EXIT_FAILURE;
+ break;
+ }
+
+ /*
+ * 0- 3 stepping
+ * 4- 7 model
+ * 8-11 family
+ * 12-13 type
+ * 16-19 extended model
+ * 20-27 extended family
+ */
+ family = (mc->hdr.sig >> 8) & 0xf;
+ if (family == 0xf)
+ family += (mc->hdr.sig >> 20) & 0xff;
+ model = (mc->hdr.sig >> 4) & 0x0f;
+ if (family == 0x06)
+ model += ((mc->hdr.sig >> 16) & 0x0f) << 4;
+ stepping = mc->hdr.sig & 0x0f;
+
+ year = mc->hdr.date & 0xffff;
+ month = mc->hdr.date >> 24;
+ day = (mc->hdr.date >> 16) & 0xff;
+
+ if (asprintf(&filename, "intel-ucode/%02x-%02x-%02x", family, model, stepping) < 0) {
+ rc = EXIT_FAILURE;
+ goto out;
+ }
+ printf("\n");
+ printf("%s\n", filename);
+ printf("signature: 0x%02x\n", mc->hdr.sig);
+ printf("flags: 0x%02x\n", mc->hdr.pf);
+ printf("revision: 0x%02x\n", mc->hdr.rev);
+ printf("date: %04x-%02x-%02x\n", year, month, day);
+ printf("size: %zu\n", size);
+
+ f = fopen(filename, "ae");
+ if (f == NULL) {
+ printf("open %s: %m\n", filename);
+ rc = EXIT_FAILURE;
+ goto out;
+ }
+ if (fwrite(mc, size, 1, f) != 1) {
+ printf("write %s: %m\n", filename);
+ rc = EXIT_FAILURE;
+ goto out;
+ }
+ fclose(f);
+ free(filename);
+
+ start += size;
+ if (start >= bufsize)
+ break;
+ }
+ printf("\n");
+out:
+ return rc;
+}
diff --git a/sys-firmware/intel-microcode/intel-microcode-20170707.ebuild b/sys-firmware/intel-microcode/intel-microcode-20170707.ebuild
new file mode 100644
index 000000000000..acab7d674757
--- /dev/null
+++ b/sys-firmware/intel-microcode/intel-microcode-20170707.ebuild
@@ -0,0 +1,48 @@
+# Copyright 1999-2017 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI="6"
+
+inherit toolchain-funcs
+
+# Find updates by searching and clicking the first link (hopefully it's the one):
+# http://www.intel.com/content/www/us/en/search.html?keyword=Processor+Microcode+Data+File
+
+NUM="26925"
+DESCRIPTION="Intel IA32/IA64 microcode update data"
+HOMEPAGE="http://inertiawar.com/microcode/ https://downloadcenter.intel.com/Detail_Desc.aspx?DwnldID=${NUM}"
+SRC_URI="http://downloadmirror.intel.com/${NUM}/eng/microcode-${PV}.tgz"
+
+LICENSE="intel-ucode"
+SLOT="0"
+KEYWORDS="-* ~amd64 ~x86"
+IUSE="initramfs monolithic +split-ucode"
+REQUIRED_USE="|| ( initramfs monolithic split-ucode )"
+
+DEPEND="initramfs? ( sys-apps/iucode_tool )"
+RDEPEND="!<sys-apps/microcode-ctl-1.17-r2" #268586
+
+S=${WORKDIR}
+
+src_unpack() {
+ default
+ cp "${FILESDIR}"/intel-microcode2ucode.c-r1 ./intel-microcode2ucode.c || die
+}
+
+src_compile() {
+ if use initramfs ; then
+ iucode_tool --write-earlyfw=microcode.cpio microcode.dat || die
+ fi
+
+ if use split-ucode ; then
+ tc-env_build emake intel-microcode2ucode
+ ./intel-microcode2ucode microcode.dat || die
+ fi
+}
+
+src_install() {
+ insinto /lib/firmware
+ use initramfs && doins microcode.cpio
+ use monolithic && doins microcode.dat
+ use split-ucode && doins -r intel-ucode
+}