-
Notifications
You must be signed in to change notification settings - Fork 7
/
build.sh
executable file
·43 lines (32 loc) · 947 Bytes
/
build.sh
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
#!/bin/sh
set -e
CURDIR="$PWD"
TMPDIR="$CURDIR/build"
IMAGEPATH="$CURDIR/razer_acpi_fix.img"
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root" 1>&2
exit 1
fi
mkdir -p "$TMPDIR"
# Extract DSDT.
cat "/sys/firmware/acpi/tables/DSDT" > "$TMPDIR/DSDT.dat"
# Extract SSDT Files.
SSDT_FILES=`ls /sys/firmware/acpi/tables/ | grep SSDT`
for f in $SSDT_FILES; do
cat "/sys/firmware/acpi/tables/$f" > "$TMPDIR/$f.dat"
done
# Disassemble.
iasl -e "$TMPDIR"/*.dat -d "$TMPDIR"/SSDT5.dat
# Patch.
sed -i '/^ *External/! s/OSYS/0x07D9/g' "$TMPDIR/SSDT5.dsl"
sed -i '/^ *DefinitionBlock/ s/0x00003000/0x00003001/g' "$TMPDIR/SSDT5.dsl"
# Compile.
iasl -ve -tc -p "$TMPDIR/SSDT5" "$TMPDIR/SSDT5.dsl"
# Create the image.
mkdir -p "$TMPDIR/kernel/firmware/acpi"
cp "$TMPDIR/SSDT5.aml" "$TMPDIR/kernel/firmware/acpi/ssdt5.aml"
cd "$TMPDIR"
find kernel | cpio -H newc --create > "$IMAGEPATH"
cd "$CURDIR"
# Cleanup.
rm -r "$TMPDIR"