sort models and modify the display of disks

This commit is contained in:
Ing 2023-08-19 21:12:39 +08:00
parent 254be512cb
commit 80362e483e
9 changed files with 1163 additions and 1184 deletions

View File

@ -8,9 +8,9 @@
NUM='\([0-9a-fA-F]*[ \t]*\)' NUM='\([0-9a-fA-F]*[ \t]*\)'
OUT=$(sed -n 's/^[ \t0-9]*.b[sr][sk][ \t]*'"${NUM}${NUM}${NUM}${NUM}"'.*/\1\4/p') OUT=$(sed -n 's/^[ \t0-9]*.b[sr][sk][ \t]*'"${NUM}${NUM}${NUM}${NUM}"'.*/\1\4/p')
if [ -z "$OUT" ] ; then if [ -z "$OUT" ]; then
echo "Never found .bss or .brk file offset" >&2 echo "Never found .bss or .brk file offset" >&2
exit 1 exit 1
fi fi
OUT=$(echo ${OUT# }) OUT=$(echo ${OUT# })
@ -22,20 +22,20 @@ sizeB=$(printf "%d" 0x${OUT%% *})
OUT=${OUT#* } OUT=${OUT#* }
offsetB=$(printf "%d" 0x${OUT%% *}) offsetB=$(printf "%d" 0x${OUT%% *})
run_size=$(( ${offsetA} + ${sizeA} + ${sizeB} )) run_size=$((${offsetA} + ${sizeA} + ${sizeB}))
# BFD linker shows the same file offset in ELF. # BFD linker shows the same file offset in ELF.
if [ "${offsetA}" -ne "${offsetB}" ] ; then if [ "${offsetA}" -ne "${offsetB}" ]; then
# Gold linker shows them as consecutive. # Gold linker shows them as consecutive.
endB=$(( ${offsetB} + ${sizeB} )) endB=$((${offsetB} + ${sizeB}))
if [ "$endB" != "$run_size" ] ; then if [ "$endB" != "$run_size" ]; then
printf "sizeA: 0x%x\n" ${sizeA} >&2 printf "sizeA: 0x%x\n" ${sizeA} >&2
printf "offsetA: 0x%x\n" ${offsetA} >&2 printf "offsetA: 0x%x\n" ${offsetA} >&2
printf "sizeB: 0x%x\n" ${sizeB} >&2 printf "sizeB: 0x%x\n" ${sizeB} >&2
printf "offsetB: 0x%x\n" ${offsetB} >&2 printf "offsetB: 0x%x\n" ${offsetB} >&2
echo ".bss and .brk are non-contiguous" >&2 echo ".bss and .brk are non-contiguous" >&2
exit 1 exit 1
fi fi
fi fi
printf "%d\n" ${run_size} printf "%d\n" ${run_size}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -83,12 +83,17 @@ function modelMenu() {
FLGBETA=0 FLGBETA=0
dialog --backtitle "$(backtitle)" --colors --title "$(TEXT "Model")" \ dialog --backtitle "$(backtitle)" --colors --title "$(TEXT "Model")" \
--infobox "$(TEXT "Reading models")" 0 0 --infobox "$(TEXT "Reading models")" 0 0
echo -n "" >"${TMP_PATH}/modellist"
while read M; do
Y=$(echo ${M} | tr -cd "[0-9]")
Y=${Y:0-2}
echo "${M} ${Y}" >>"${TMP_PATH}/modellist"
done < <(find "${MODEL_CONFIG_PATH}" -maxdepth 1 -name \*.yml | sed 's/.*\///; s/\.yml//')
while true; do while true; do
echo "" >"${TMP_PATH}/menu" echo -n "" >"${TMP_PATH}/menu"
FLGNEX=0 FLGNEX=0
while read M; do while read M Y; do
M="$(basename ${M})"
M="${M::-4}"
PLATFORM=$(readModelKey "${M}" "platform") PLATFORM=$(readModelKey "${M}" "platform")
DT="$(readModelKey "${M}" "dt")" DT="$(readModelKey "${M}" "dt")"
BETA="$(readModelKey "${M}" "beta")" BETA="$(readModelKey "${M}" "beta")"
@ -106,7 +111,7 @@ function modelMenu() {
fi fi
[ "${DT}" = "true" ] && DT="DT" || DT="" [ "${DT}" = "true" ] && DT="DT" || DT=""
[ ${COMPATIBLE} -eq 1 ] && echo "${M} \"$(printf "\Zb%-12s\Zn \Z4%-2s\Zn" "${PLATFORM}" "${DT}")\" " >>"${TMP_PATH}/menu" [ ${COMPATIBLE} -eq 1 ] && echo "${M} \"$(printf "\Zb%-12s\Zn \Z4%-2s\Zn" "${PLATFORM}" "${DT}")\" " >>"${TMP_PATH}/menu"
done < <(find "${MODEL_CONFIG_PATH}" -maxdepth 1 -name \*.yml | sort) done < <(cat "${TMP_PATH}/modellist" | sort -r -n -k 2)
[ ${FLGNEX} -eq 1 ] && echo "f \"\Z1$(TEXT "Disable flags restriction")\Zn\"" >>"${TMP_PATH}/menu" [ ${FLGNEX} -eq 1 ] && echo "f \"\Z1$(TEXT "Disable flags restriction")\Zn\"" >>"${TMP_PATH}/menu"
[ ${FLGBETA} -eq 0 ] && echo "b \"\Z1$(TEXT "Show beta models")\Zn\"" >>"${TMP_PATH}/menu" [ ${FLGBETA} -eq 0 ] && echo "b \"\Z1$(TEXT "Show beta models")\Zn\"" >>"${TMP_PATH}/menu"
dialog --backtitle "$(backtitle)" --colors \ dialog --backtitle "$(backtitle)" --colors \
@ -1061,43 +1066,54 @@ function advancedMenu() {
s) s)
MSG="" MSG=""
NUMPORTS=0 NUMPORTS=0
ATTACHTNUM=0 [ $(lspci -d ::106 | wc -l) -gt 0 ] && MSG+="\nATA:\n"
DiskIdxMap="" for PCI in $(lspci -d ::106 | awk '{print $1}'); do
for PCI in $(echo -e "$(lspci -d ::106)\n$(lspci -d ::107)" | awk '{print $1}'); do
NAME=$(lspci -s "${PCI}" | sed "s/\ .*://") NAME=$(lspci -s "${PCI}" | sed "s/\ .*://")
MSG+="\Zb${NAME}\Zn\nPorts: " MSG+="\Zb${NAME}\Zn\nPorts: "
unset HOSTPORTS PORTS=$(ls -l /sys/class/scsi_host | grep "${PCI}" | awk -F'/' '{print $NF}' | sed 's/host//' | sort -n)
declare -A HOSTPORTS for P in ${PORTS}; do
ATTACHTIDX=0 if lsscsi -b | grep -v - | grep -q "\[${P}:"; then
while read LINE; do DUMMY="$([ "$(cat /sys/class/scsi_host/host${P}/ahci_port_cmd)" = "0" ] && echo 1 || echo 2)"
ATAPORT="$(echo ${LINE} | grep -o 'ata[0-9]*')" if [ "$(cat /sys/class/scsi_host/host${P}/ahci_port_cmd)" = "0" ]; then
PORT="" MSG+="\Z1$(printf "%02d" ${P})\Zn "
if [ -n "${ATAPORT}" ]; then else
PORT=$(echo ${ATAPORT} | sed 's/ata//') MSG+="\Z2$(printf "%02d" ${P})\Zn "
fi
else else
SASPORT="$(echo ${LINE} | grep -o "${PCI}/host[0-9]*")" MSG+="$(printf "%02d" ${P}) "
PORT=$(echo ${SASPORT} | sed "s/${PCI}\/host//")
fi fi
HOSTPORTS[${PORT}]=$(echo ${LINE} | grep -o 'host[0-9]*$')
done < <(ls -l /sys/class/scsi_host | fgrep "${PCI}")
while read PORT; do
ls -l /sys/block | fgrep -q "${PCI}/ata${PORT}" && ATTACH=1 ||
ls -l /sys/block | fgrep -q "${PCI}/host${PORT}" && ATTACH=1 || ATTACH=0
PCMD=$(cat /sys/class/scsi_host/${HOSTPORTS[${PORT}]}/ahci_port_cmd)
[ "${PCMD}" = "0" ] && DUMMY=1 || DUMMY=0
[ ${ATTACH} -eq 1 ] && MSG+="\Z2\Zb" && ATTACHTIDX=$((${ATTACHTIDX} + 1))
[ ${DUMMY} -eq 1 ] && MSG+="\Z1"
MSG+="${PORT}\Zn "
NUMPORTS=$((${NUMPORTS} + 1)) NUMPORTS=$((${NUMPORTS} + 1))
done < <(echo ${!HOSTPORTS[@]} | tr ' ' '\n' | sort -n) done
MSG+="\n" MSG+="\n"
[ ${ATTACHTIDX} -gt 0 ] && DiskIdxMap+=$(printf '%02x' ${ATTACHTNUM}) || DiskIdxMap+="ff"
ATTACHTNUM=$((${ATTACHTNUM} + ${ATTACHTIDX}))
done done
[ $(lspci -d ::107 | wc -l) -gt 0 ] && MSG+="\nLSI:\n"
for PCI in $(lspci -d ::107 | awk '{print $1}'); do
NAME=$(lspci -s "${PCI}" | sed "s/\ .*://")
PORT=$(ls -l /sys/class/scsi_host | grep "${PCI}" | awk -F'/' '{print $NF}' | sed 's/host//' | sort -n)
PORTNUM=$(lsscsi -b | grep -v - | grep "\[${PORT}:" | wc -l)
MSG+="\Zb${NAME}\Zn\nNumber: ${PORTNUM}\n"
NUMPORTS=$((${NUMPORTS} + ${PORTNUM}))
done
[ $(ls -l /sys/class/scsi_host | grep usb | wc -l) -gt 0 ] && MSG+="\nUSB:\n"
for PCI in $(lspci -d ::c03 | awk '{print $1}'); do
NAME=$(lspci -s "${PCI}" | sed "s/\ .*://")
PORT=$(ls -l /sys/class/scsi_host | grep "${PCI}" | awk -F'/' '{print $NF}' | sed 's/host//' | sort -n)
PORTNUM=$(lsscsi -b | grep -v - | grep "\[${PORT}:" | wc -l)
[ ${PORTNUM} -eq 0 ] && continue
MSG+="\Zb${NAME}\Zn\nNumber: ${PORTNUM}\n"
NUMPORTS=$((${NUMPORTS} + ${PORTNUM}))
done
[ $(lspci -d ::108 | wc -l) -gt 0 ] && MSG+="\nNVME:\n"
for PCI in $(lspci -d ::108 | awk '{print $1}'); do
NAME=$(lspci -s "${PCI}" | sed "s/\ .*://")
PORT=$(ls -l /sys/class/nvme | grep "${PCI}" | awk -F'/' '{print $NF}' | sed 's/nvme//' | sort -n)
PORTNUM=$(lsscsi -b | grep -v - | grep "\[N:${PORT}:" | wc -l)
MSG+="\Zb${NAME}\Zn\nNumber: ${PORTNUM}\n"
NUMPORTS=$((${NUMPORTS} + ${PORTNUM}))
done
MSG+="\n"
MSG+="$(printf "$(TEXT "\nTotal of ports: %s\n")" "${NUMPORTS}")" MSG+="$(printf "$(TEXT "\nTotal of ports: %s\n")" "${NUMPORTS}")"
MSG+="$(TEXT "\nPorts with color \Z1red\Zn as DUMMY, color \Z2\Zbgreen\Zn has drive connected.")" MSG+="$(TEXT "\nPorts with color \Z1red\Zn as DUMMY, color \Z2\Zbgreen\Zn has drive connected.")"
MSG+="$(TEXT "\nRecommended value:")"
MSG+="$(TEXT "\nDiskIdxMap:") ${DiskIdxMap}"
dialog --backtitle "$(backtitle)" --colors --title "$(TEXT "Advanced")" \ dialog --backtitle "$(backtitle)" --colors --title "$(TEXT "Advanced")" \
--msgbox "${MSG}" 0 0 --msgbox "${MSG}" 0 0
;; ;;
@ -1149,11 +1165,6 @@ function advancedMenu() {
echo "${POSITION}" | grep -q "${LOADER_DEVICE_NAME}" && continue echo "${POSITION}" | grep -q "${LOADER_DEVICE_NAME}" && continue
echo "\"${POSITION}\" \"${NAME}\" \"off\"" >>"${TMP_PATH}/opts" echo "\"${POSITION}\" \"${NAME}\" \"off\"" >>"${TMP_PATH}/opts"
done < <(ls -l /dev/disk/by-id/ | sed 's|../..|/dev|g' | grep -E "/dev/sd|/dev/nvme" | awk -F' ' '{print $NF" "$(NF-2)}' | sort -uk 1,1) done < <(ls -l /dev/disk/by-id/ | sed 's|../..|/dev|g' | grep -E "/dev/sd|/dev/nvme" | awk -F' ' '{print $NF" "$(NF-2)}' | sort -uk 1,1)
while read POSITION NAME; do
[ -z "${POSITION}" -o -z "${NAME}" ] && continue
echo "${POSITION}" | grep -q "${LOADER_DEVICE_NAME}" && continue
echo "\"${POSITION}\" \"${NAME}\" \"off\"" >>"${TMP_PATH}/opts"
done < <(ls -l /dev/disk/by-path/ | sed 's|../..|/dev|g' | grep -E "/dev/sd|/dev/nvme" | awk -F' ' '{print $NF" "$(NF-2)}' | sort -uk 1,1)
dialog --backtitle "$(backtitle)" --colors --title "$(TEXT "Advanced")" \ dialog --backtitle "$(backtitle)" --colors --title "$(TEXT "Advanced")" \
--checklist "$(TEXT "Advanced")" 0 0 0 --file "${TMP_PATH}/opts" \ --checklist "$(TEXT "Advanced")" 0 0 0 --file "${TMP_PATH}/opts" \
2>${TMP_PATH}/resp 2>${TMP_PATH}/resp