3 # This file is part of the coreboot project.
5 # Copyright (C) 2007-2010 coresystems GmbH
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; version 2 of the License.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 MICROCODE_VERSION=20100209
22 MICROCODE_ARCHIVE=microcode-$MICROCODE_VERSION.tgz
23 MICROCODE_FILE=microcode-$MICROCODE_VERSION.dat
24 INTEL_MICROCODE=http://downloadmirror.intel.com/18683/eng/$MICROCODE_ARCHIVE
27 # Getting Intel(R) Microcode
31 printf "Getting microcode...\n"
32 wget -nv $INTEL_MICROCODE
33 tar xzf $MICROCODE_ARCHIVE
37 # Creating separate files per microcode
40 separate_microcode() {
41 printf "Separating microcode...\n"
42 csplit -s -n4 -k microcode-20100209.dat '/^\/\*.*\.inc.*\*\//' '{500}' 2> /dev/null
44 perl -pi -e 's,\ \ \ \ \ \ \ ,\ ,' header.inc
45 perl -pi -e 's,^,/,g' header.inc
46 perl -pi -e 's,^//\*,/\*,' header.inc
52 name=microcode-${name%.inc}.h
53 cat header.inc $i > $name
55 rm -f xx???? header.inc
59 # Dump CPUIDs from all separated files
63 ls -1 microcode-*.h | while read F; do
64 CPUID="$( echo $( head -36 $F |tail -1|cut -d, -f4|sed s,0x,, ) | sed 's/0*//')"
70 # Move microcode to target positions
74 printf "Moving microcode...\n"
75 dump_cpuids | sort | while read N; do
76 ID=$( echo $N | cut -d: -f1 )
77 F=$( echo $N | cut -d: -f2 )
79 if [ -d ../model_$ID ]; then
80 echo "Model: $ID Microcode: $F"
84 if [ -d ../model_$ID2 ]; then
85 echo "Model: $ID($ID2) Microcode: $F (copied)"
86 mv $F ../model_$ID2/$F
89 if [ -d ../model_$ID1 ]; then
90 echo "Model: $ID($ID1) Microcode: $F (copied)"
91 mv $F ../model_$ID1/$F
93 echo "Model: $ID Microcode: $F (erased)"
105 rm -f $MICROCODE_ARCHIVE
106 rm -f $MICROCODE_FILE