Skip to content

Commit

Permalink
Refactor boot0 platform specific definition
Browse files Browse the repository at this point in the history
Make it easier to manage new sku
  • Loading branch information
Staphylo committed Dec 31, 2019
1 parent 5a28f6a commit a157fda
Showing 1 changed file with 29 additions and 11 deletions.
40 changes: 29 additions & 11 deletions files/Aboot/boot0.j2
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,28 @@ EOF
chmod a+r "${target_path}/machine.conf"
}

in_array() {
local value="$1"
shift

for other in $@; do
if [ "$value" = "$other" ]; then
return 0
fi
done

return 1
}

read_system_eeprom() {
if [ -x /bin/readprefdl ]; then
readprefdl -f /tmp/.system-prefdl -d > $target_path/.system-prefdl
elif [ -f /etc/prefdl ]; then
cp /etc/prefdl $target_path/.system-prefdl
chmod a+r $target_path/.system-prefdl
fi
}

platform_specific() {
local platform="$(sed -nr 's/.*platform=([^ ]+).*/\1/p' "$cmdline_base")"
local sid="$(sed -nr 's/.*sid=([^ ]+).*/\1/p' "$cmdline_base" | sed 's/Ssd$//')"
Expand All @@ -227,20 +249,21 @@ platform_specific() {
local flash_size=$(($(df | grep -E "$flash_re" | tr -s ' ' | cut -f2 -d' ') / 1000))

if [ "$platform" = "raven" ]; then
# Assuming sid=Cloverdale
aboot_machine=arista_7050_qx32
flash_size=2000
docker_inram=on
echo "modprobe.blacklist=radeon,sp5100_tco acpi=off docker_inram=on" >>/tmp/append
fi
if [ "$platform" = "crow" ]; then
# Assuming sid=Clearlake
aboot_machine=arista_7050_qx32s
flash_size=3700
echo "modprobe.blacklist=radeon,sp5100_tco" >>/tmp/append
fi
if [ "$sid" = "Upperlake" ] || [ "$sid" = "UpperlakeES" ]; then
aboot_machine=arista_7060_cx32s
flash_size=3700
echo "amd_iommu=off" >> /tmp/append
fi
if [ "$sid" = "Gardena" ] || [ "$sid" = "GardenaE" ]; then
aboot_machine=arista_7260cx3_64
Expand Down Expand Up @@ -271,23 +294,18 @@ platform_specific() {
aboot_machine=arista_7280cr3_32d4
flash_size=7382
fi
if [ "$platform" = "rook" ] || [ "$platform" = "magpie" ] ||
[ "$platform" = "woodpecker" ]; then
if in_array "$platform" "rook" "magpie" "woodpecker"; then
echo "tsc=reliable pcie_ports=native" >>/tmp/append
echo "rhash_entries=1 usb-storage.delay_use=0" >>/tmp/append
if [ -x /bin/readprefdl ]; then
readprefdl -f /tmp/.system-prefdl -d > /mnt/flash/.system-prefdl
elif [ -f /etc/prefdl ]; then
cp /etc/prefdl /mnt/flash/.system-prefdl
chmod a+r /mnt/flash/.system-prefdl
fi
echo "reassign_prefmem" >> /tmp/append
fi
if [ "$platform" = "rook" ] || [ "$platform" = "magpie" ]; then
if in_array "$platform" "rook"; then
echo "iommu=on intel_iommu=on" >>/tmp/append
read_system_eeprom
fi
if [ "$platform" = "woodpecker" ]; then
if in_array "$platform" "crow" "woodpecker" "magpie"; then
echo "amd_iommu=off modprobe.blacklist=snd_hda_intel,hdaudio" >> /tmp/append
read_system_eeprom
fi

if [ $flash_size -ge 28000 ]; then
Expand Down

0 comments on commit a157fda

Please sign in to comment.