From 8c3e8e7de8ddb69caf049cc51ae0be1365a052c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20F=C3=B6rster?= Date: Sun, 1 Sep 2013 08:50:02 +0200 Subject: [PATCH] [sys-apps/microcode-data] bump, change homepage --- sys-apps/microcode-data/Manifest | 1 + .../files/intel-microcode2ucode.c | 163 ++++++++++++++++++ .../microcode-data-20130808.ebuild | 45 +++++ 3 files changed, 209 insertions(+) create mode 100644 sys-apps/microcode-data/Manifest create mode 100644 sys-apps/microcode-data/files/intel-microcode2ucode.c create mode 100644 sys-apps/microcode-data/microcode-data-20130808.ebuild diff --git a/sys-apps/microcode-data/Manifest b/sys-apps/microcode-data/Manifest new file mode 100644 index 0000000..05bc6a3 --- /dev/null +++ b/sys-apps/microcode-data/Manifest @@ -0,0 +1 @@ +DIST microcode-20130808.tgz 717772 SHA256 d5dd1977992308d7e0244993cf5fbed54a396df2f8f1533c3dbb37b3530160a7 SHA512 680e78ebb9832ef4273d48da49742392eda72aa41b4e2e5c3636ac08b7c515c64dc844c41713a9ac3fbfaf42b4e2b6ef15f2737ad4a336ebfc0c0a6f9570e8ca WHIRLPOOL b8501b3890867b73c84fe288d45b0cfe066dc63f5b5add6b19e15101e35c0dba42fc545f6b3e3662b04897ec38b4adf9789b34f4bfae0deee4c19d219e3cb580 diff --git a/sys-apps/microcode-data/files/intel-microcode2ucode.c b/sys-apps/microcode-data/files/intel-microcode2ucode.c new file mode 100644 index 0000000..caad032 --- /dev/null +++ b/sys-apps/microcode-data/files/intel-microcode2ucode.c @@ -0,0 +1,163 @@ +/* + * 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 + */ + + +#ifndef _GNU_SOURCE +# define _GNU_SOURCE 1 +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +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; + + asprintf(&filename, "intel-ucode/%02x-%02x-%02x", family, model, stepping); + 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-apps/microcode-data/microcode-data-20130808.ebuild b/sys-apps/microcode-data/microcode-data-20130808.ebuild new file mode 100644 index 0000000..223a20a --- /dev/null +++ b/sys-apps/microcode-data/microcode-data-20130808.ebuild @@ -0,0 +1,45 @@ +# Copyright 1999-2013 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: $Id$ + +EAPI="5" + +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="23082" +DESCRIPTION="Intel IA32 microcode update data" +HOMEPAGE="https://fedorahosted.org/microcode_ctl/ 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="" + +RDEPEND="!