1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
#!/bin/bash
#
# This file is part of the coreboot project.
#
# Copyright (C) 2007-2010 coresystems GmbH
#
# This program 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; version 2 of the License.
#
# This program 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 this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
MICROCODE_VERSION=20100209
MICROCODE_ARCHIVE=microcode-$MICROCODE_VERSION.tgz
MICROCODE_FILE=microcode-$MICROCODE_VERSION.dat
INTEL_MICROCODE=http://downloadmirror.intel.com/18683/eng/$MICROCODE_ARCHIVE
#
# Getting Intel(R) Microcode
#
get_microcode() {
printf "Getting microcode...\n"
wget -nv $INTEL_MICROCODE
tar xzf $MICROCODE_ARCHIVE
}
#
# Creating separate files per microcode
#
separate_microcode() {
printf "Separating microcode...\n"
csplit -s -n4 -k microcode-20100209.dat '/^\/\*.*\.inc.*\*\//' '{500}' 2> /dev/null
mv xx0000 header.inc
perl -pi -e 's,\ \ \ \ \ \ \ ,\ ,' header.inc
perl -pi -e 's,^,/,g' header.inc
perl -pi -e 's,^//\*,/\*,' header.inc
for i in xx????; do
name="`head -1 $i`"
name=${name%??}
name=${name:2}
name=$( echo $name )
name=microcode-${name%.inc}.h
cat header.inc $i > $name
done
rm -f xx???? header.inc
}
#
# Dump CPUIDs from all separated files
#
dump_cpuids() {
ls -1 microcode-*.h | while read F; do
CPUID="$( echo $( head -36 $F |tail -1|cut -d, -f4|sed s,0x,, ) | sed 's/0*//')"
echo "$CPUID:$F"
done
}
#
# Move microcode to target positions
#
move_microcode() {
printf "Moving microcode...\n"
dump_cpuids | sort | while read N; do
ID=$( echo $N | cut -d: -f1 )
F=$( echo $N | cut -d: -f2 )
if [ -d ../model_$ID ]; then
echo "Model: $ID Microcode: $F"
mv $F ../model_$ID/$F
else
ID2=${ID%?}x
if [ -d ../model_$ID2 ]; then
echo "Model: $ID($ID2) Microcode: $F (copied)"
mv $F ../model_$ID2/$F
else
ID1=${ID%??}xx
if [ -d ../model_$ID1 ]; then
echo "Model: $ID($ID1) Microcode: $F (copied)"
mv $F ../model_$ID1/$F
else
echo "Model: $ID Microcode: $F (erased)"
rm -f $F
fi
fi
fi
done
}
get_microcode
separate_microcode
move_microcode
rm -f $MICROCODE_ARCHIVE
rm -f $MICROCODE_FILE
|