build/roms: general code style cleanup
parent
d521fca7ef
commit
5f44556f47
|
@ -86,14 +86,14 @@ uboot_config="undefined"
|
||||||
|
|
||||||
if [ "${grub_scan_disk}" = "undefined" ]; then
|
if [ "${grub_scan_disk}" = "undefined" ]; then
|
||||||
printf "build/roms: Target '%s' does not define grub_scan_disk. " \
|
printf "build/roms: Target '%s' does not define grub_scan_disk. " \
|
||||||
${board}
|
${board}
|
||||||
printf "Defaulting to 'both'.\n"
|
printf "Defaulting to 'both'.\n"
|
||||||
grub_scan_disk="both"
|
grub_scan_disk="both"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "${grub_scan_disk}" != "both" ] && \
|
if [ "${grub_scan_disk}" != "both" ] && \
|
||||||
[ "${grub_scan_disk}" != "ata" ] && \
|
[ "${grub_scan_disk}" != "ata" ] && \
|
||||||
[ "${grub_scan_disk}" != "ahci" ]; then
|
[ "${grub_scan_disk}" != "ahci" ]; then
|
||||||
printf "build/roms: Target '%s' defines bad grub_scan_disk option. " \
|
printf "build/roms: Target '%s' defines bad grub_scan_disk option. " \
|
||||||
${board}
|
${board}
|
||||||
printf "Defaulting to 'both'.\n"
|
printf "Defaulting to 'both'.\n"
|
||||||
|
@ -266,7 +266,6 @@ if [ "${payload_grub}" = "y" ] \
|
||||||
rm -Rf payload/grub/ # just in case
|
rm -Rf payload/grub/ # just in case
|
||||||
fi
|
fi
|
||||||
for keymapfile in ${kmapdir}/*; do
|
for keymapfile in ${kmapdir}/*; do
|
||||||
|
|
||||||
if [ ! -f "${keymapfile}" ]; then
|
if [ ! -f "${keymapfile}" ]; then
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
@ -305,19 +304,20 @@ fi
|
||||||
|
|
||||||
# it is assumed that no other work will be done on the ROM
|
# it is assumed that no other work will be done on the ROM
|
||||||
# after calling this function. therefore this function is "final"
|
# after calling this function. therefore this function is "final"
|
||||||
moverom() {
|
moverom()
|
||||||
|
{
|
||||||
rompath="$1"
|
rompath="$1"
|
||||||
newrompath="$2"
|
_newrom="$2"
|
||||||
cuttype="$3"
|
cuttype="$3"
|
||||||
|
|
||||||
printf "\nCreating new ROM image: %s\n" "${newrompath}"
|
printf "\nCreating new ROM image: %s\n" "${_newrom}"
|
||||||
|
|
||||||
if [ "${cuttype}" = "4MiB IFD BIOS region" ]; then
|
if [ "${cuttype}" = "4MiB IFD BIOS region" ]; then
|
||||||
dd if=${rompath} of=${newrompath} bs=1 \
|
dd if=${rompath} of=${_newrom} bs=1 \
|
||||||
skip=$(($(stat -c %s ${rompath}) - 0x400000)) \
|
skip=$(($(stat -c %s ${rompath}) - 0x400000)) \
|
||||||
count=4194304
|
count=4194304
|
||||||
else
|
else
|
||||||
cp ${rompath} ${newrompath}
|
cp ${rompath} ${_newrom}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for romsize in 4 8 16; do
|
for romsize in 4 8 16; do
|
||||||
|
@ -326,7 +326,7 @@ moverom() {
|
||||||
if [ ! -f "${ifdgbe}" ]; then
|
if [ ! -f "${ifdgbe}" ]; then
|
||||||
./build descriptors ich9m
|
./build descriptors ich9m
|
||||||
fi
|
fi
|
||||||
dd if=${ifdgbe} of=${newrompath} bs=1 count=12k \
|
dd if=${ifdgbe} of=${_newrom} bs=1 count=12k \
|
||||||
conv=notrunc
|
conv=notrunc
|
||||||
fi
|
fi
|
||||||
cmpstr="${romsize}MiB ICH9 IFD NOGBE NOR flash"
|
cmpstr="${romsize}MiB ICH9 IFD NOGBE NOR flash"
|
||||||
|
@ -335,24 +335,25 @@ moverom() {
|
||||||
if [ ! -f "${ifdgbe}" ]; then
|
if [ ! -f "${ifdgbe}" ]; then
|
||||||
./build descriptors ich9m
|
./build descriptors ich9m
|
||||||
fi
|
fi
|
||||||
dd if=${ifdgbe} of=${newrompath} bs=1 count=4k \
|
dd if=${ifdgbe} of=${_newrom} bs=1 count=4k \
|
||||||
conv=notrunc
|
conv=notrunc
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ "${cuttype}" = "i945 laptop" ]; then
|
if [ "${cuttype}" = "i945 laptop" ]; then
|
||||||
dd if=${newrompath} of=top64k.bin bs=1 \
|
dd if=${_newrom} of=top64k.bin bs=1 \
|
||||||
skip=$(($(stat -c %s ${newrompath}) - 0x10000)) \
|
skip=$(($(stat -c %s ${_newrom}) - 0x10000)) \
|
||||||
count=64k
|
count=64k
|
||||||
dd if=top64k.bin of=${newrompath} bs=1 \
|
dd if=top64k.bin of=${_newrom} bs=1 \
|
||||||
seek=$(($(stat -c %s ${newrompath}) - 0x20000)) \
|
seek=$(($(stat -c %s ${_newrom}) - 0x20000)) \
|
||||||
count=64k conv=notrunc
|
count=64k conv=notrunc
|
||||||
rm -f top64k.bin
|
rm -f top64k.bin
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# expected: configs must not specify a payload
|
# expected: configs must not specify a payload
|
||||||
mkCoreboot() {
|
mkCoreboot()
|
||||||
|
{
|
||||||
cbdir="${1}" # eg. coreboot/default
|
cbdir="${1}" # eg. coreboot/default
|
||||||
cbcfgpath="${2}" # eg. resources/coreboot/e6400nvidia_4mb/config/normal
|
cbcfgpath="${2}" # eg. resources/coreboot/e6400nvidia_4mb/config/normal
|
||||||
if [ ! -f "${cbcfgpath}" ]; then
|
if [ ! -f "${cbcfgpath}" ]; then
|
||||||
|
@ -385,7 +386,8 @@ mkCoreboot() {
|
||||||
}
|
}
|
||||||
|
|
||||||
# make a rom in /tmp/ and then print the path of that ROM
|
# make a rom in /tmp/ and then print the path of that ROM
|
||||||
mkSeabiosRom() {
|
mkSeabiosRom()
|
||||||
|
{
|
||||||
target_cbrom="${1}" # rom to insert seabios in. will not be touched
|
target_cbrom="${1}" # rom to insert seabios in. will not be touched
|
||||||
# (a tmpfile will be made instead)
|
# (a tmpfile will be made instead)
|
||||||
target_seabios_cbfs_path="${2}" # e.g. fallback/payload
|
target_seabios_cbfs_path="${2}" # e.g. fallback/payload
|
||||||
|
@ -401,24 +403,22 @@ mkSeabiosRom() {
|
||||||
|
|
||||||
"${cbfstool}" "${tmprom}" add-payload -f "${target_seabioself}" \
|
"${cbfstool}" "${tmprom}" add-payload -f "${target_seabioself}" \
|
||||||
-n ${target_seabios_cbfs_path} -c lzma || exit 1
|
-n ${target_seabios_cbfs_path} -c lzma || exit 1
|
||||||
|
|
||||||
"${cbfstool}" "${tmprom}" add-int -i 3000 -n etc/ps2-keyboard-spinup \
|
"${cbfstool}" "${tmprom}" add-int -i 3000 -n etc/ps2-keyboard-spinup \
|
||||||
|| exit 1
|
|| exit 1
|
||||||
|
|
||||||
if [ "${target_initmode}" = "normal" ] \
|
if [ "${target_initmode}" = "normal" ] \
|
||||||
|| [ "${target_initmode}" = "libgfxinit" ]; then
|
|| [ "${target_initmode}" = "libgfxinit" ]; then
|
||||||
"${cbfstool}" "${tmprom}" add-int -i 2 \
|
"${cbfstool}" "${tmprom}" add-int -i 2 \
|
||||||
-n etc/pci-optionrom-exec || exit 1
|
-n etc/pci-optionrom-exec || exit 1
|
||||||
elif [ "${target_initmode}" = "vgarom" ]; then # coreboot executes it
|
elif [ "${target_initmode}" = "vgarom" ]; then # coreboot executes it
|
||||||
"${cbfstool}" "${tmprom}" add-int -i 0 \
|
"${cbfstool}" "${tmprom}" add-int -i 0 \
|
||||||
-n etc/pci-optionrom-exec || exit 1
|
-n etc/pci-optionrom-exec || exit 1
|
||||||
fi # for undefined modes, don't add this integer. use SeaBIOS defaults
|
fi # for undefined modes, don't add this integer. use SeaBIOS defaults
|
||||||
|
|
||||||
"${cbfstool}" "${tmprom}" add-int -i 0 -n etc/optionroms-checksum \
|
"${cbfstool}" "${tmprom}" add-int -i 0 -n etc/optionroms-checksum \
|
||||||
|| exit 1
|
|| exit 1
|
||||||
|
|
||||||
"${cbfstool}" "${tmprom}" add-int -i ${target_opromloadonly} \
|
"${cbfstool}" "${tmprom}" add-int -i ${target_opromloadonly} \
|
||||||
-n etc/only-load-option-roms || exit 1
|
-n etc/only-load-option-roms || exit 1
|
||||||
|
|
||||||
if [ "${target_initmode}" = "libgfxinit" ]; then
|
if [ "${target_initmode}" = "libgfxinit" ]; then
|
||||||
"${cbfstool}" "${tmprom}" add -f "${target_seavgabios_rom}" \
|
"${cbfstool}" "${tmprom}" add -f "${target_seavgabios_rom}" \
|
||||||
|
@ -429,7 +429,8 @@ mkSeabiosRom() {
|
||||||
}
|
}
|
||||||
|
|
||||||
# make a rom in /tmp/ and then print the path of that ROM
|
# make a rom in /tmp/ and then print the path of that ROM
|
||||||
mkUbootRom() {
|
mkUbootRom()
|
||||||
|
{
|
||||||
target_cbrom="${1}" # rom to insert u-boot in. it won't be touched
|
target_cbrom="${1}" # rom to insert u-boot in. it won't be touched
|
||||||
# (a tmpfile will be made instead)
|
# (a tmpfile will be made instead)
|
||||||
target_uboot_cbfs_path="${2}" # e.g. fallback/payload
|
target_uboot_cbfs_path="${2}" # e.g. fallback/payload
|
||||||
|
@ -458,7 +459,8 @@ mkUbootRom() {
|
||||||
}
|
}
|
||||||
|
|
||||||
# make a rom in /tmp/ and then print the path of that ROM
|
# make a rom in /tmp/ and then print the path of that ROM
|
||||||
mkGrubRom() {
|
mkGrubRom()
|
||||||
|
{
|
||||||
target_keymap="${1}"
|
target_keymap="${1}"
|
||||||
target_cbrom="${2}"
|
target_cbrom="${2}"
|
||||||
target_grubelf_cbfs_path="${3}" # e.g. fallback/payload
|
target_grubelf_cbfs_path="${3}" # e.g. fallback/payload
|
||||||
|
@ -496,7 +498,6 @@ mkGrubRom() {
|
||||||
|
|
||||||
"${cbfstool}" "${tmprom}" add -f "${tmpgrubcfg}" -n grub.cfg -t raw \
|
"${cbfstool}" "${tmprom}" add -f "${tmpgrubcfg}" -n grub.cfg -t raw \
|
||||||
|| exit 1
|
|| exit 1
|
||||||
|
|
||||||
"${cbfstool}" "${tmprom}" add -f "${tmpgrubtestcfg}" -n grubtest.cfg \
|
"${cbfstool}" "${tmprom}" add -f "${tmpgrubtestcfg}" -n grubtest.cfg \
|
||||||
-t raw || exit 1
|
-t raw || exit 1
|
||||||
rm -f "${tmpgrubcfg}" "${tmpgrubtestcfg}"
|
rm -f "${tmpgrubcfg}" "${tmpgrubtestcfg}"
|
||||||
|
@ -514,7 +515,8 @@ mkGrubRom() {
|
||||||
}
|
}
|
||||||
|
|
||||||
# Make separate ROM images with GRUB payload, for each supported keymap
|
# Make separate ROM images with GRUB payload, for each supported keymap
|
||||||
mkRomsWithGrub() {
|
mkRomsWithGrub()
|
||||||
|
{
|
||||||
tmprompath="${1}"
|
tmprompath="${1}"
|
||||||
initmode="${2}"
|
initmode="${2}"
|
||||||
displaymode="${3}"
|
displaymode="${3}"
|
||||||
|
@ -524,19 +526,18 @@ mkRomsWithGrub() {
|
||||||
y=${seabios_opromloadonly}
|
y=${seabios_opromloadonly}
|
||||||
z=${initmode}
|
z=${initmode}
|
||||||
if [ "${payload_grub_withseabios}" = "y" ] \
|
if [ "${payload_grub_withseabios}" = "y" ] \
|
||||||
&& [ "${firstpayloadname}" = "grub" ]; then
|
&& [ "${firstpayloadname}" = "grub" ]; then
|
||||||
mv "$(mkSeabiosRom "${x}" "seabios.elf" "${y}" "${z}")" \
|
mv "$(mkSeabiosRom "${x}" "seabios.elf" "${y}" "${z}")" \
|
||||||
"${tmprompath}"
|
"${tmprompath}"
|
||||||
elif [ "${payload_seabios_withgrub}" ] \
|
elif [ "${payload_seabios_withgrub}" ] \
|
||||||
&& [ "${firstpayloadname}" != "grub" ]; then
|
&& [ "${firstpayloadname}" != "grub" ]; then
|
||||||
mv "$(mkSeabiosRom "${x}" "fallback/payload" "$y" "$z")" \
|
mv "$(mkSeabiosRom "${x}" "fallback/payload" "$y" "$z")" \
|
||||||
"${tmprompath}"
|
"${tmprompath}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
keymaps=""
|
keymaps=""
|
||||||
if [ -z ${keyboard_layouts} ]; then
|
if [ -z ${keyboard_layouts} ]; then
|
||||||
for kmapfile in "${kmapdir}"/*
|
for kmapfile in "${kmapdir}"/*; do
|
||||||
do
|
|
||||||
keymaps="${keymaps} ${kmapfile}"
|
keymaps="${keymaps} ${kmapfile}"
|
||||||
done
|
done
|
||||||
else
|
else
|
||||||
|
@ -545,8 +546,6 @@ mkRomsWithGrub() {
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
for keymapfile in ${keymaps}; do
|
for keymapfile in ${keymaps}; do
|
||||||
echo "keymaps is $keymaps, keymapfile is $keymapfile"
|
|
||||||
|
|
||||||
if [ ! -f "${keymapfile}" ]; then
|
if [ ! -f "${keymapfile}" ]; then
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
@ -563,24 +562,22 @@ mkRomsWithGrub() {
|
||||||
x=${keymap}
|
x=${keymap}
|
||||||
y=${tmprompath}
|
y=${tmprompath}
|
||||||
z=${grub_path_in_cbfs}
|
z=${grub_path_in_cbfs}
|
||||||
|
|
||||||
tmpgrubrom="$(mkGrubRom "${x}" "${y}" "${z}")"
|
tmpgrubrom="$(mkGrubRom "${x}" "${y}" "${z}")"
|
||||||
|
|
||||||
|
_newrom="${romdir}/${firstpayloadname}_${board}_${initmode}_"
|
||||||
if [ "${initmode}" = "normal" ]; then
|
if [ "${initmode}" = "normal" ]; then
|
||||||
newrompath="${romdir}/${firstpayloadname}_${board}_"
|
_newrom="${_newrom}${keymap}.rom"
|
||||||
newrompath="${newrompath}${initmode}_${keymap}.rom"
|
|
||||||
else
|
else
|
||||||
newrompath="${romdir}/${firstpayloadname}_${board}_"
|
_newrom="${_newrom}${displaymode}_${keymap}.rom"
|
||||||
newrompath="${newrompath}${initmode}_${displaymode}_"
|
|
||||||
newrompath="${newrompath}${keymap}.rom"
|
|
||||||
fi
|
fi
|
||||||
moverom "${tmpgrubrom}" "${newrompath}" "${romtype}"
|
moverom "${tmpgrubrom}" "${_newrom}" "${romtype}"
|
||||||
rm -f "${tmpgrubrom}"
|
rm -f "${tmpgrubrom}"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
# Main ROM building function. This calls all other functions
|
# Main ROM building function. This calls all other functions
|
||||||
mkRoms() {
|
mkRoms()
|
||||||
|
{
|
||||||
cbcfgpath="${1}"
|
cbcfgpath="${1}"
|
||||||
displaymode="${2}"
|
displaymode="${2}"
|
||||||
initmode="${3}"
|
initmode="${3}"
|
||||||
|
@ -607,16 +604,13 @@ mkRoms() {
|
||||||
y=${seabios_opromloadonly}
|
y=${seabios_opromloadonly}
|
||||||
z=${initmode}
|
z=${initmode}
|
||||||
t=$(mkSeabiosRom "$x" "fallback/payload" "$y" "$z")
|
t=$(mkSeabiosRom "$x" "fallback/payload" "$y" "$z")
|
||||||
if [ "${initmode}" = "normal" ]; then
|
|
||||||
newrompath="${romdir}/seabios_${board}_"
|
_newrom="${romdir}/seabios_${board}_${initmode}.rom"
|
||||||
newrompath="${newrompath}${initmode}.rom"
|
if [ "${initmode}" != "normal" ]; then
|
||||||
else
|
_newrom="${_newrom%.rom}_${displaymode}.rom"
|
||||||
newrompath="${romdir}/seabios_${board}_"
|
|
||||||
newrompath="${newrompath}${initmode}_"
|
|
||||||
newrompath="${newrompath}${displaymode}.rom"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
moverom "${t}" "${newrompath}" "${romtype}"
|
moverom "${t}" "${_newrom}" "${romtype}"
|
||||||
rm -f "${t}"
|
rm -f "${t}"
|
||||||
else
|
else
|
||||||
tmprom=$(mktemp -t coreboot_rom.XXXXXXXXXX)
|
tmprom=$(mktemp -t coreboot_rom.XXXXXXXXXX)
|
||||||
|
@ -638,13 +632,13 @@ mkRoms() {
|
||||||
z=${cbfstool}
|
z=${cbfstool}
|
||||||
tmpubootrom="$(mkUbootRom "$x" "fallback/payload" "$y" "$z")"
|
tmpubootrom="$(mkUbootRom "$x" "fallback/payload" "$y" "$z")"
|
||||||
if [ "${initmode}" = "normal" ]; then
|
if [ "${initmode}" = "normal" ]; then
|
||||||
newrompath="${romdir}/uboot_payload_${board}_"
|
_newrom="${romdir}/uboot_payload_${board}_"
|
||||||
newrompath="${newrompath}${initmode}.rom"
|
_newrom="${_newrom}${initmode}.rom"
|
||||||
else
|
else
|
||||||
newrompath="${romdir}/uboot_payload_${board}_"
|
_newrom="${romdir}/uboot_payload_${board}_"
|
||||||
newrompath="${newrompath}${initmode}_${displaymode}.rom"
|
_newrom="${_newrom}${initmode}_${displaymode}.rom"
|
||||||
fi
|
fi
|
||||||
moverom "${tmpubootrom}" "${newrompath}" "${romtype}"
|
moverom "${tmpubootrom}" "${_newrom}" "${romtype}"
|
||||||
rm -f "${tmpubootrom}"
|
rm -f "${tmpubootrom}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue