Merge pull request #739 from lrusak/x86-firmware

linux-firmware build system rework
This commit is contained in:
MilhouseVH 2016-09-19 20:07:36 +01:00 committed by GitHub
commit 8ae2726f1d
361 changed files with 278 additions and 188 deletions

View File

@ -29,6 +29,7 @@ ROOT=`pwd`
DISTRO_DIR="$ROOT/distributions"
PROJECT_DIR="$ROOT/projects"
LINUX_DEPENDS="$PROJECT_DIR/$PROJECT/linux/linux.$TARGET_ARCH.conf $ROOT/packages/linux/package.mk"
[ "$TARGET_ARCH" = "x86_64" ] && LINUX_DEPENDS+=" $ROOT/packages/linux-firmware/intel-ucode/package.mk $ROOT/packages/linux-firmware/x86-firmware/package.mk"
# include versioning
. config/version

View File

@ -1,55 +0,0 @@
################################################################################
# This file is part of OpenELEC - http://www.openelec.tv
# Copyright (C) 2009-2016 Stephan Raue (stephan@openelec.tv)
#
# OpenELEC is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# OpenELEC is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OpenELEC. If not, see <http://www.gnu.org/licenses/>.
################################################################################
PKG_NAME="cpu-firmware"
PKG_VERSION="ad1238f"
PKG_REV="1"
PKG_ARCH="i386 x86_64"
PKG_LICENSE="other"
PKG_SITE="https://git.fedorahosted.org/cgit/microcode_ctl.git"
PKG_URL="https://git.fedorahosted.org/cgit/microcode_ctl.git/snapshot/$PKG_VERSION.tar.xz"
PKG_SOURCE_DIR="$PKG_VERSION"
PKG_DEPENDS_INIT="toolchain"
PKG_DEPENDS_TARGET="toolchain"
PKG_PRIORITY="optional"
PKG_SECTION="linux-firmware"
PKG_SHORTDESC="cpu-microcode: Intel and AMD CPU microcodes"
PKG_LONGDESC="cpu-microcode: Intel and AMD CPU microcodes"
PKG_IS_ADDON="no"
PKG_AUTORECONF="no"
make_init() {
PREFIX=/
MICDIR=/lib/firmware
make
}
makeinstall_init() {
DESTDIR=$INSTALL make install
}
make_target() {
PREFIX=/
MICDIR=/lib/firmware
make
}
makeinstall_target() {
DESTDIR=$INSTALL make install
}

View File

@ -1,66 +0,0 @@
diff -Naur a/Makefile b/Makefile
--- a/Makefile 2016-01-12 07:14:57.000000000 -0800
+++ b/Makefile 2016-03-19 13:59:39.937499052 -0700
@@ -14,34 +14,25 @@
MICROCODE_AMD = amd-ucode-2012-09-10.tar
INS = install
-CC = gcc
-KERNELHEADER = /usr/src/linux/include
+CC ?= gcc
+KERNELHEADER ?= /usr/src/linux/include
CFLAGS = -g -Wall -O2 -I $(KERNELHEADER)
-DESTDIR =
-PREFIX = /usr/local
+DESTDIR ?=
+PREFIX ?= /usr/local
INSDIR = $(PREFIX)/sbin
MANDIR = $(PREFIX)/share/man/man8
DOCDIR = $(PREFIX)/share/doc/microcode_ctl
-MICDIR = /lib/firmware
+MICDIR ?= /lib/firmware
MICDIRAMD = $(MICDIR)/amd-ucode
-RCFILE = microcode_ctl.start
-RCFILEFINAL = microcode_ctl
-# this is a bit nasty...
-RCDIR = $(shell if [ -d /etc/init.d ]; then echo "/etc"; else echo "/etc/rc.d"; fi)
-RCHOMEDIR = init.d
-RCFILETO = $(RCDIR)/$(RCHOMEDIR)
-
all: microcode_ctl
-microcode_ctl: microcode_ctl.c
- $(CC) $(CFLAGS) -o $(PROGRAM) microcode_ctl.c
- mkdir intel-ucode amd-ucode
+microcode_ctl:
+ mkdir -p intel-ucode amd-ucode
tar xfz $(MICROCODE_INTEL) -C intel-ucode
tar --strip-components 1 -xf $(MICROCODE_AMD) -C amd-ucode
- echo "$(RCDIR)/$(RCHOMEDIR)/microcode_ctl" > microcode-filelist
clean:
rm -rf $(PROGRAM) intel-ucode amd-ucode
@@ -50,20 +41,9 @@
$(INS) -d $(DESTDIR)$(INSDIR) $(DESTDIR)$(MICDIRAMD) \
$(DESTDIR)$(MANDIR) $(DESTDIR)$(RCFILETO) \
$(DESTDIR)$(RCLINKTO) $(DESTDIR)$(DOCDIR)
- $(INS) -m 755 $(PROGRAM) $(DESTDIR)$(INSDIR)
- $(INS) -m 644 $(MANPAGE) $(DESTDIR)$(MANDIR)
- gzip -9f $(DESTDIR)$(MANDIR)/$(MANPAGE)
- $(INS) -m 755 $(RCFILE) $(DESTDIR)$(RCFILETO)/$(RCFILEFINAL)
$(INS) -m 644 intel-ucode/microcode.dat $(DESTDIR)$(MICDIR)
$(INS) -m 644 amd-ucode/microcode_amd.bin $(DESTDIR)$(MICDIR)/amd-ucode/
$(INS) -m 644 amd-ucode/microcode_amd_fam15h.bin $(DESTDIR)$(MICDIR)/amd-ucode/
- $(INS) -m 644 amd-ucode/microcode_amd.bin.README \
- $(DESTDIR)$(DOCDIR)/README.microcode_amd.bin
- $(INS) -m 644 amd-ucode/microcode_amd_fam15h.bin.README \
- $(DESTDIR)$(DOCDIR)/README.microcode_amd_fam15h.bin
- $(INS) -m 644 amd-ucode/LICENSE $(DESTDIR)$(DOCDIR)/LICENSE.microcode_amd
- $(INS) -m 644 amd-ucode/README $(DESTDIR)$(DOCDIR)/README.microcode_amd
- $(INS) -m 644 amd-ucode/INSTALL $(DESTDIR)$(DOCDIR)/INSTALL.microcode_amd
ifndef DESTDIR
chkconfig --add $(RCFILEFINAL)

View File

@ -0,0 +1,54 @@
################################################################################
# This file is part of LibreELEC - https://libreelec.tv
# Copyright (C) 2016 Team LibreELEC
#
# LibreELEC is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# LibreELEC is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with LibreELEC. If not, see <http://www.gnu.org/licenses/>.
################################################################################
PKG_NAME="intel-ucode"
PKG_VERSION="20160714"
PKG_REV="1"
PKG_ARCH="x86_64"
PKG_LICENSE="other"
PKG_SITE="https://downloadcenter.intel.com/search?keyword=linux+microcode"
PKG_URL="https://downloadmirror.intel.com/26156/eng/microcode-${PKG_VERSION}.tgz"
PKG_DEPENDS_TARGET="toolchain intel-ucode:host"
PKG_PRIORITY="optional"
PKG_SECTION="linux-firmware"
PKG_SHORTDESC="intel-ucode: Intel CPU microcodes"
PKG_LONGDESC="intel-ucode: Intel CPU microcodes"
PKG_IS_ADDON="no"
PKG_AUTORECONF="no"
unpack() {
mkdir -p $ROOT/$PKG_BUILD
tar xf $SOURCES/$PKG_NAME/$PKG_NAME-$PKG_VERSION.tgz -C $ROOT/$PKG_BUILD
}
make_host() {
$CC $CFLAGS -o intel-microcode2ucode intel-microcode2ucode.c
}
makeinstall_host() {
cp intel-microcode2ucode $ROOT/$TOOLCHAIN/bin/
}
make_target() {
intel-microcode2ucode ./microcode.dat
}
makeinstall_target() {
:
}

View File

@ -0,0 +1,154 @@
/*
* Convert Intel microcode.dat into a single binary microcode.bin file
*
* Based on code by Kay Sievers <kay.sievers@vrfy.org>
* Changed to create a single file by Thomas Bächler <thomas@archlinux.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[])
{
const 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;
f = fopen("microcode.bin", "we");
if (f == NULL) {
printf("open microcode.bin: %m\n");
rc = EXIT_FAILURE;
goto out;
}
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;
printf("\n");
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);
if (fwrite(mc, size, 1, f) != 1) {
printf("write microcode.bin: %m\n");
rc = EXIT_FAILURE;
goto out;
}
start += size;
if (start >= bufsize)
break;
}
fclose(f);
printf("\n");
out:
return rc;
}

View File

@ -0,0 +1,46 @@
################################################################################
# This file is part of LibreELEC - https://libreelec.tv
# Copyright (C) 2016 Team LibreELEC
#
# LibreELEC is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# LibreELEC is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with LibreELEC. If not, see <http://www.gnu.org/licenses/>.
################################################################################
PKG_NAME="x86-firmware"
PKG_VERSION="c4c07a8"
PKG_REV="1"
PKG_ARCH="x86_64"
PKG_LICENSE="other"
PKG_SITE="http://git.kernel.org/cgit/linux/kernel/git/firmware/linux-firmware.git/"
PKG_URL="http://git.kernel.org/cgit/linux/kernel/git/firmware/linux-firmware.git/snapshot/$PKG_VERSION.tar.xz"
PKG_SOURCE_DIR="$PKG_VERSION"
PKG_DEPENDS_TARGET="toolchain"
PKG_PRIORITY="optional"
PKG_SECTION="linux-firmware"
PKG_SHORTDESC="x86-firmware: x86 related firmware"
PKG_LONGDESC="x86-firmware: x86 related firmware"
PKG_IS_ADDON="no"
PKG_AUTORECONF="no"
configure_target() {
:
}
make_target() {
:
}
makeinstall_target() {
:
}

View File

@ -1 +0,0 @@
bxt_dmc_ver1_06.bin

View File

@ -1 +0,0 @@
skl_dmc_ver1_26.bin

View File

@ -1 +0,0 @@
skl_guc_ver1_1059.bin

View File

@ -1 +0,0 @@
skl_guc_ver4_3.bin

View File

@ -1 +0,0 @@
skl_guc_ver6_1.bin

Some files were not shown because too many files have changed in this diff Show More