Index: head/sysutils/devcpu-data/Makefile =================================================================== --- head/sysutils/devcpu-data/Makefile +++ head/sysutils/devcpu-data/Makefile @@ -2,13 +2,13 @@ # $FreeBSD$ PORTNAME= data -PORTVERSION= 1.14 -PORTREVISION= 3 +PORTVERSION= 1.15 CATEGORIES= sysutils MASTER_SITES= https://downloadmirror.intel.com/27337/eng/:intel \ LOCAL/sbruno:amd PKGNAMEPREFIX= devcpu- -DISTFILES= microcode-20171117.tgz:intel amd64-microcode_3.20171205.1.tar.xz:amd +DISTFILES= microcode-20171117.tgz:intel \ + amd64-microcode_3.20171205.1.tar.xz:amd MAINTAINER= clarkjc@runbox.com COMMENT= Intel and AMD CPUs microcode updates @@ -20,17 +20,19 @@ ONLY_FOR_ARCHS= amd64 i386 NO_ARCH= yes +NO_BUILD= yes NO_WRKSUBDIR= yes DATADIR= ${PREFIX}/share/cpucontrol USE_RC_SUBR= microcode_update -post-extract: - ${CP} -p ${FILESDIR}/Makefile ${FILESDIR}/ucode-tool.c ${WRKSRC} - do-install: ${MKDIR} ${STAGEDIR}${DATADIR}/ - ${INSTALL_DATA} ${WRKSRC}/mcodes/* ${STAGEDIR}${DATADIR}/ + ${INSTALL_DATA} ${WRKSRC}/intel-ucode/* ${STAGEDIR}${DATADIR}/ + ${INSTALL_DATA} ${WRKSRC}/amd64-microcode-3.20171205.1/microcode_amd.bin ${STAGEDIR}${DATADIR}/ + ${INSTALL_DATA} ${WRKSRC}/amd64-microcode-3.20171205.1/microcode_amd_fam15h.bin ${STAGEDIR}${DATADIR}/ + ${INSTALL_DATA} ${WRKSRC}/amd64-microcode-3.20171205.1/microcode_amd_fam16h.bin ${STAGEDIR}${DATADIR}/ + ${INSTALL_DATA} ${WRKSRC}/amd64-microcode-3.20171205.1/microcode_amd_fam17h.bin ${STAGEDIR}${DATADIR}/ .include Index: head/sysutils/devcpu-data/files/Makefile =================================================================== --- head/sysutils/devcpu-data/files/Makefile +++ head/sysutils/devcpu-data/files/Makefile @@ -1,19 +0,0 @@ -AMD_UCODE_DIR= amd64-microcode-3.20171205.1 -AMD_UCODE= $(AMD_UCODE_DIR)/microcode_amd.bin \ - $(AMD_UCODE_DIR)/microcode_amd_fam15h.bin \ - $(AMD_UCODE_DIR)/microcode_amd_fam16h.bin \ - $(AMD_UCODE_DIR)/microcode_amd_fam17h.bin -INTEL_UCODE= microcode.dat -OUTPUT_DIR= mcodes -all: ucode -ucode: ucode-tool - mkdir -p $(OUTPUT_DIR) - ./ucode-tool -o $(OUTPUT_DIR) -i $(INTEL_UCODE) - mv ${AMD_UCODE} $(OUTPUT_DIR) - -# Use the host cc to compile ucode-tool in case of cross-compile -ucode-tool: ucode-tool.c - cc ucode-tool.c -o $@ - -clean: - rm -rf $(OUTPUT_DIR) ucode-tool Index: head/sysutils/devcpu-data/files/ucode-tool.c =================================================================== --- head/sysutils/devcpu-data/files/ucode-tool.c +++ head/sysutils/devcpu-data/files/ucode-tool.c @@ -1,228 +0,0 @@ -/*- - * Copyright (c) 2013 John Clark - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include -#include -#include - -#define BUFFER_SIZE 4096 - -static void error(const char *fmt, ...); -static void process_amd(const char *container, const char *outdir); -static void process_intel(const char *filename, const char *outdir); - -/* - * This tool extracts microcode from container files provided by - * Intel and AMD for their families of popular microprocessors. - */ -int -main(int argc, char *argv[]) -{ - int ch, i, mode = -1; - char *outdir = "."; - - /* Parse the command line arguments. */ - while ((ch = getopt(argc, argv, "aio:")) != -1) { - switch (ch) { - case 'a': /* Mode select */ - case 'i': - mode = ch; - break; - case 'o': /* Output directory */ - outdir = optarg; - break; - default: /* Unknown */ - error("Error: Invalid argument\n"); - } - } - - if (mode == 'i') { - /* Process Intel microcode container files */ - for (i = optind; i < argc; i++) { - process_intel(argv[i], outdir); - } - } else if (mode == 'a') { - /* Process AMD microcode container files */ - for (i = optind; i < argc; i++) { - process_amd(argv[i], outdir); - } - } else { - error("Error: Invalid mode\n"); - } - - return 0; -} - -/* Display an error message and exit with a status code of 1. */ -static void -error(const char *fmt, ...) -{ - va_list args; - - if (fmt == NULL) { - perror("Error"); - } else { - va_start(args, fmt); - vfprintf(stderr, fmt, args); - va_end(args); - } - exit(1); -} - -/* Process an AMD supplied microcode container file. */ -#define AMD_HEADER_LEN 12 -#define AMD_SKIP_OFFSET 8 -#define AMD_UCODE_HEADER_LEN 8 -#define AMD_UCODE_HEADER_TYPE 0x00000001 -#define AMD_UCODE_ID_OFFSET 4 -#define AMD_UCODE_SIG_OFFSET 24 -static void -process_amd(const char *container, const char *outdir) -{ - char outname[FILENAME_MAX]; - const uint8_t magic[] = { - 0x44, 0x4d, 0x41, 0x00, 0x00, 0x00, 0x00, 0x00 - }; - FILE *fin, *fout; - uint8_t *buf; - uint32_t id, len, sig; - int num; - - if ((buf = malloc(BUFFER_SIZE)) == NULL) - error(NULL); - - /* Open the container file and read the header. */ - if ((fin = fopen(container, "rb")) == NULL) - error(NULL); - if (fread(buf, AMD_HEADER_LEN, 1, fin) != 1) { - error("Error: Truncated file: %s\n", container); - } - - /* Check the magic numbers. */ - if (memcmp(magic, buf, sizeof(magic)) != 0) { - error("Error: Invalid file: %s\n", container); - } - - /* Seek to the first microcode image. */ - if (fseek(fin, le32dec(buf + AMD_SKIP_OFFSET), SEEK_CUR) != 0) - error(NULL); - - /* Read all microcode images. */ - while ((num = fread(buf, 1, AMD_UCODE_HEADER_LEN, fin)) != 0) { - /* Read and validate the image. */ - if (num != AMD_UCODE_HEADER_LEN) { - error("Error: Truncated file: %s\n", container); - } - if (le32dec(buf) != AMD_UCODE_HEADER_TYPE) { - error("Error: Invalid type: %s\n", container); - } - len = le32dec(buf + sizeof(uint32_t)); - if (len > BUFFER_SIZE) { - if ((buf = realloc(buf, len)) == NULL) - error(NULL); - } - if (fread(buf, len, 1, fin) != 1) { - error("Error: Truncated file: %s\n", container); - } - - /* Write the image to an output file. */ - sig = le32dec(buf + AMD_UCODE_SIG_OFFSET); - id = le32dec(buf + AMD_UCODE_ID_OFFSET); - snprintf(outname, sizeof(outname), "%s/AMD-%08x-%08x.fw", - outdir, sig, id); - if ((fout = fopen(outname, "wb")) == NULL) - error(NULL); - if (fwrite(buf, len, 1, fout) != 1) - error(NULL); - if (fclose(fout) != 0) - error(NULL); - } - - if (fclose(fin) != 0) - error(NULL); - free(buf); -} - -/* Process an Intel supplied microcode container file. */ -static void -process_intel(const char *container, const char *outdir) -{ - char outname[FILENAME_MAX]; - FILE *fin, *fout = NULL; - char *buf, *token; - const char * const sep = ",. \t\n"; - uint32_t val; - - if ((buf = malloc(BUFFER_SIZE)) == NULL) - error(NULL); - if ((fin = fopen(container, "r")) == NULL) - error(NULL); - - /* Process the container file line by line. */ - while (fgets(buf, BUFFER_SIZE, fin) != NULL) { - if ((token = strtok(buf, sep)) == NULL) - continue; - - if (*token == '/') { - /* Process a comment line. */ - if (fout != NULL) { - /* Close previous output file. */ - if (fclose(fout) != 0) - error(NULL); - fout = NULL; - } - if ((token = strtok(NULL, sep)) != NULL) { - /* Construct next file name. */ - snprintf(outname, sizeof(outname), "%s/%s.fw", - outdir, token); - } - } else { - /* Process a data line. */ - if ((fout == NULL) && (token != NULL)) { - if ((fout = fopen(outname, "wb")) == NULL) - error(NULL); - } - while (token != NULL) { - val = htole32(strtoul(token, NULL, 0)); - if (fwrite(&val, sizeof(val), 1, fout) != 1) - error(NULL); - token = strtok(NULL, sep); - } - } - } - - if (fout != NULL) { - if (fclose(fout) != 0) - error(NULL); - } - if (fclose(fin) != 0) - error(NULL); - free(buf); -} Index: head/sysutils/devcpu-data/pkg-plist =================================================================== --- head/sysutils/devcpu-data/pkg-plist +++ head/sysutils/devcpu-data/pkg-plist @@ -1,168 +1,98 @@ -%%DATADIR%%/2f0708.fw -%%DATADIR%%/M01106C2217.fw -%%DATADIR%%/M01106CA107.fw -%%DATADIR%%/M0120661104.fw -%%DATADIR%%/M0220661105_CV.fw -%%DATADIR%%/M04106C2218.fw -%%DATADIR%%/M04106CA107.fw -%%DATADIR%%/M08106C2219.fw -%%DATADIR%%/M08106CA107.fw -%%DATADIR%%/M10106CA107.fw -%%DATADIR%%/MU163202.fw -%%DATADIR%%/MU165040.fw -%%DATADIR%%/MU165041.fw -%%DATADIR%%/MU165045.fw -%%DATADIR%%/MU165140.fw -%%DATADIR%%/MU16522a.fw -%%DATADIR%%/MU16522c.fw -%%DATADIR%%/MU16530c.fw -%%DATADIR%%/MU16530d.fw -%%DATADIR%%/MU165310.fw -%%DATADIR%%/MU16600a.fw -%%DATADIR%%/MU166503.fw -%%DATADIR%%/MU166a0b.fw -%%DATADIR%%/MU166a0c.fw -%%DATADIR%%/MU166a0d.fw -%%DATADIR%%/MU166d05.fw -%%DATADIR%%/MU166d06.fw -%%DATADIR%%/MU166d07.fw -%%DATADIR%%/MU16810d.fw -%%DATADIR%%/MU16810e.fw -%%DATADIR%%/MU16810f.fw -%%DATADIR%%/MU168111.fw -%%DATADIR%%/MU168307.fw -%%DATADIR%%/MU168308.fw -%%DATADIR%%/MU168607.fw -%%DATADIR%%/MU168608.fw -%%DATADIR%%/MU16860a.fw -%%DATADIR%%/MU16860c.fw -%%DATADIR%%/MU168a01.fw -%%DATADIR%%/MU168a04.fw -%%DATADIR%%/MU168a05.fw -%%DATADIR%%/MU16b11c.fw -%%DATADIR%%/MU16b11d.fw -%%DATADIR%%/MU16b401.fw -%%DATADIR%%/MU16b402.fw -%%DATADIR%%/MU26522b.fw -%%DATADIR%%/MU26530b.fw -%%DATADIR%%/MU268110.fw -%%DATADIR%%/MU268602.fw -%%DATADIR%%/m011066143.fw -%%DATADIR%%/m011067660F.fw -%%DATADIR%%/m016fbBA.fw -%%DATADIR%%/m01f0712.fw -%%DATADIR%%/m01f0a13.fw -%%DATADIR%%/m01f2529.fw -%%DATADIR%%/m01f480c.fw -%%DATADIR%%/m01f6402.fw -%%DATADIR%%/m01f6508.fw -%%DATADIR%%/m021066142.fw -%%DATADIR%%/m02906eb_00000071_00000072.fw -%%DATADIR%%/m02f0a15.fw -%%DATADIR%%/m02f241f.fw -%%DATADIR%%/m02f252a.fw -%%DATADIR%%/m02f2610.fw -%%DATADIR%%/m02f2738.fw -%%DATADIR%%/m02f292d.fw -%%DATADIR%%/m02f4116.fw -%%DATADIR%%/m02f480e.fw -%%DATADIR%%/m03106a4_00000012.fw -%%DATADIR%%/m03106a5_00000019.fw -%%DATADIR%%/m041067660F.fw -%%DATADIR%%/m046fbBC.fw -%%DATADIR%%/m04f0a14.fw -%%DATADIR%%/m04f122e.fw -%%DATADIR%%/m04f241e.fw -%%DATADIR%%/m04f252b.fw -%%DATADIR%%/m04f2737.fw -%%DATADIR%%/m04f292e.fw -%%DATADIR%%/m04f620f.fw -%%DATADIR%%/m05206f2_00000037.fw -%%DATADIR%%/m08106d129.fw -%%DATADIR%%/m086fbBB.fw -%%DATADIR%%/m08f2739.fw -%%DATADIR%%/m08f292f.fw -%%DATADIR%%/m0df320a.fw -%%DATADIR%%/m0df330c.fw -%%DATADIR%%/m101067660F.fw -%%DATADIR%%/m101067770A.fw -%%DATADIR%%/m1050662_0000000f.fw -%%DATADIR%%/m1050663_0700000d.fw -%%DATADIR%%/m1050664_0f00000a.fw -%%DATADIR%%/m1069507.fw -%%DATADIR%%/m106f76a.fw -%%DATADIR%%/m106fbBA.fw -%%DATADIR%%/m10f2421.fw -%%DATADIR%%/m10f252c.fw -%%DATADIR%%/m111067AA0B.fw -%%DATADIR%%/m1220652_0000000e.fw -%%DATADIR%%/m12206a7_00000029.fw -%%DATADIR%%/m12306a9_0000001c.fw -%%DATADIR%%/m13106e5_00000007.fw -%%DATADIR%%/m16f25d.fw -%%DATADIR%%/m16f6d0.fw -%%DATADIR%%/m16fda4.fw -%%DATADIR%%/m1df3417.fw -%%DATADIR%%/m2069507.fw -%%DATADIR%%/m206d618.fw -%%DATADIR%%/m206e839.fw -%%DATADIR%%/m206ec54.fw -%%DATADIR%%/m206f25c.fw -%%DATADIR%%/m206f6d1.fw -%%DATADIR%%/m206fbBA.fw -%%DATADIR%%/m206fda4.fw -%%DATADIR%%/m2240671_00000017.fw -%%DATADIR%%/m22906ea_0000006f_00000070.fw -%%DATADIR%%/m22f6809.fw -%%DATADIR%%/m2a906e9_0000005d_0000005e.fw -%%DATADIR%%/m32306c3_00000022.fw -%%DATADIR%%/m3240661_00000017.fw -%%DATADIR%%/m34f6404.fw -%%DATADIR%%/m36506e3_000000b9_000000ba.fw -%%DATADIR%%/m401067660F.fw -%%DATADIR%%/m406f76b.fw -%%DATADIR%%/m406fbBC.fw -%%DATADIR%%/m441067AA0B.fw -%%DATADIR%%/m46f6d2.fw -%%DATADIR%%/m5cf4a04.fw -%%DATADIR%%/m5df4a02.fw -%%DATADIR%%/m5ff4807.fw -%%DATADIR%%/m6d206d6_00000619.fw -%%DATADIR%%/m6d206d7_00000710.fw -%%DATADIR%%/m6f306f2_0000003a.fw -%%DATADIR%%/m7240651_00000020.fw -%%DATADIR%%/m801066144.fw -%%DATADIR%%/m801067660F.fw -%%DATADIR%%/m80306f4_0000000f.fw -%%DATADIR%%/m8069547.fw -%%DATADIR%%/m806ec59.fw -%%DATADIR%%/m806fa95.fw -%%DATADIR%%/m806fbBA.fw -%%DATADIR%%/m806fda4.fw -%%DATADIR%%/m9220655_00000004.fw -%%DATADIR%%/m9df4305.fw -%%DATADIR%%/m9df4406.fw -%%DATADIR%%/m9df4703.fw -%%DATADIR%%/mA01067AA0B.fw -%%DATADIR%%/m_01_706a1_0000001e.fw -%%DATADIR%%/m_03_506c9_0000002c.fw -%%DATADIR%%/mb750654_02000035.fw -%%DATADIR%%/mbdf4117.fw -%%DATADIR%%/mbdf4903.fw -%%DATADIR%%/mc0306d4_00000025.fw -%%DATADIR%%/mc0406e3_000000b9_000000ba.fw -%%DATADIR%%/mc0806e9_00000061_00000062.fw -%%DATADIR%%/mc0806ea_0000006f_00000070.fw -%%DATADIR%%/med306e4_00000428.fw -%%DATADIR%%/med306e6_00000600.fw -%%DATADIR%%/med306e7_0000070d.fw -%%DATADIR%%/mef406f1_0b000021.fw +%%DATADIR%%/06-03-02 +%%DATADIR%%/06-05-00 +%%DATADIR%%/06-05-01 +%%DATADIR%%/06-05-02 +%%DATADIR%%/06-05-03 +%%DATADIR%%/06-06-00 +%%DATADIR%%/06-06-05 +%%DATADIR%%/06-06-0a +%%DATADIR%%/06-06-0d +%%DATADIR%%/06-07-01 +%%DATADIR%%/06-07-02 +%%DATADIR%%/06-07-03 +%%DATADIR%%/06-08-01 +%%DATADIR%%/06-08-03 +%%DATADIR%%/06-08-06 +%%DATADIR%%/06-08-0a +%%DATADIR%%/06-09-05 +%%DATADIR%%/06-0a-00 +%%DATADIR%%/06-0a-01 +%%DATADIR%%/06-0b-01 +%%DATADIR%%/06-0b-04 +%%DATADIR%%/06-0d-06 +%%DATADIR%%/06-0e-08 +%%DATADIR%%/06-0e-0c +%%DATADIR%%/06-0f-02 +%%DATADIR%%/06-0f-06 +%%DATADIR%%/06-0f-07 +%%DATADIR%%/06-0f-0a +%%DATADIR%%/06-0f-0b +%%DATADIR%%/06-0f-0d +%%DATADIR%%/06-16-01 +%%DATADIR%%/06-17-06 +%%DATADIR%%/06-17-07 +%%DATADIR%%/06-17-0a +%%DATADIR%%/06-1a-04 +%%DATADIR%%/06-1a-05 +%%DATADIR%%/06-1c-02 +%%DATADIR%%/06-1c-0a +%%DATADIR%%/06-1d-01 +%%DATADIR%%/06-1e-05 +%%DATADIR%%/06-25-02 +%%DATADIR%%/06-25-05 +%%DATADIR%%/06-26-01 +%%DATADIR%%/06-2a-07 +%%DATADIR%%/06-2d-06 +%%DATADIR%%/06-2d-07 +%%DATADIR%%/06-2f-02 +%%DATADIR%%/06-3a-09 +%%DATADIR%%/06-3c-03 +%%DATADIR%%/06-3d-04 +%%DATADIR%%/06-3e-04 +%%DATADIR%%/06-3e-06 +%%DATADIR%%/06-3e-07 +%%DATADIR%%/06-3f-02 +%%DATADIR%%/06-3f-04 +%%DATADIR%%/06-45-01 +%%DATADIR%%/06-46-01 +%%DATADIR%%/06-47-01 +%%DATADIR%%/06-4e-03 +%%DATADIR%%/06-4f-01 +%%DATADIR%%/06-55-04 +%%DATADIR%%/06-56-02 +%%DATADIR%%/06-56-03 +%%DATADIR%%/06-56-04 +%%DATADIR%%/06-5c-09 +%%DATADIR%%/06-5e-03 +%%DATADIR%%/06-7a-01 +%%DATADIR%%/06-8e-09 +%%DATADIR%%/06-8e-0a +%%DATADIR%%/06-9e-09 +%%DATADIR%%/06-9e-0a +%%DATADIR%%/06-9e-0b +%%DATADIR%%/0f-00-07 +%%DATADIR%%/0f-00-0a +%%DATADIR%%/0f-01-02 +%%DATADIR%%/0f-02-04 +%%DATADIR%%/0f-02-05 +%%DATADIR%%/0f-02-06 +%%DATADIR%%/0f-02-07 +%%DATADIR%%/0f-02-09 +%%DATADIR%%/0f-03-02 +%%DATADIR%%/0f-03-03 +%%DATADIR%%/0f-03-04 +%%DATADIR%%/0f-04-01 +%%DATADIR%%/0f-04-03 +%%DATADIR%%/0f-04-04 +%%DATADIR%%/0f-04-07 +%%DATADIR%%/0f-04-08 +%%DATADIR%%/0f-04-09 +%%DATADIR%%/0f-04-0a +%%DATADIR%%/0f-06-02 +%%DATADIR%%/0f-06-04 +%%DATADIR%%/0f-06-05 +%%DATADIR%%/0f-06-08 %%DATADIR%%/microcode_amd.bin %%DATADIR%%/microcode_amd_fam15h.bin %%DATADIR%%/microcode_amd_fam16h.bin %%DATADIR%%/microcode_amd_fam17h.bin -%%DATADIR%%/mu267114.fw -%%DATADIR%%/mu267238.fw -%%DATADIR%%/mu26732e.fw -%%DATADIR%%/mu26a003.fw -%%DATADIR%%/mu26a101.fw