1
0
Fork 0
mirror of https://github.com/anrieff/libcpuid synced 2025-06-07 00:51:40 +00:00

Utils: improve parse_arm_arm_pdf for ARM ARM version L.a

This commit is contained in:
The Tumultuous Unicorn Of Darkness 2025-05-01 15:24:24 +02:00
parent ae5b2a24c9
commit a0f35743a6
No known key found for this signature in database
GPG key ID: 1E55EE2EFF18BC1A

View file

@ -16,19 +16,22 @@ PDF_FILE="$1"
TMP_DIR="$(mktemp -d -t libcpuid.XXXXXX)" TMP_DIR="$(mktemp -d -t libcpuid.XXXXXX)"
TMP_LIBCPUID_H="$TMP_DIR/cpu_feature.h" TMP_LIBCPUID_H="$TMP_DIR/cpu_feature.h"
TMP_CPUID_MAIN_C="$TMP_DIR/matchtable.c" TMP_CPUID_MAIN_C="$TMP_DIR/matchtable.c"
TMP_RECOG_ARM_C="$TMP_DIR/features_map.c"
echo "typedef enum {" > "$TMP_LIBCPUID_H" echo "typedef enum {" > "$TMP_LIBCPUID_H"
echo " matchtable[] = {" > "$TMP_CPUID_MAIN_C" echo " matchtable[] = {" > "$TMP_CPUID_MAIN_C"
echo -e "\tconst struct arm_feature_map_t features_map[NUM_CPU_FEATURES] = {" > "$TMP_RECOG_ARM_C"
IFS=' IFS='
' '
for line in $(pdfgrep --cache -e 'A[0-9]+\.[0-9]+\.[0-9]+\s+The Armv[0-9]\.[0-9] architecture extension' -e ' FEAT_[a-zA-Z0-9_]+, ' "$PDF_FILE"); do for line in $(pdftk "$PDF_FILE" dump_data_utf8 | grep -E '^BookmarkTitle' | sed 's/BookmarkTitle: //g'); do
if [[ "$line" == "A"* ]]; then if [[ "$line" =~ ^A[0-9]+\.[0-9]+\.[0-9]+[[:blank:]]The[[:blank:]]Armv[0-9]\.[0-9][[:blank:]]architecture[[:blank:]]extension$ ]]; then
echo "$line" echo "$line"
echo -e "\t/* $line */" >> "$TMP_LIBCPUID_H" echo -e "\t/* $line */" >> "$TMP_LIBCPUID_H"
echo -e "\t\t/* $line */" >> "$TMP_CPUID_MAIN_C" echo -e "\t\t/* $line */" >> "$TMP_CPUID_MAIN_C"
elif [[ "$line" == " FEAT_"* ]]; then elif [[ "$line" =~ ^FEAT_[a-zA-Z0-9_]+, ]]; then
feat="$(echo "$line" | awk '{ print $1 }' | cut -d, -f1)" feat="$(echo "$line" | awk '{ print $1 }' | cut -d, -f1)"
echo -e "\t$feat"
#pdfgrep --cache "$feat implements the functionality identified by the value" "$PDF_FILE" #pdfgrep --cache "$feat implements the functionality identified by the value" "$PDF_FILE"
feat_upper="${feat^^}" feat_upper="${feat^^}"
feat_lower="${feat,,}" feat_lower="${feat,,}"
@ -37,11 +40,23 @@ for line in $(pdfgrep --cache -e 'A[0-9]+\.[0-9]+\.[0-9]+\s+The Armv[0-9]\.[0-9]
feat_descr="$(echo "$line" | cut -d, -f2-)" feat_descr="$(echo "$line" | cut -d, -f2-)"
echo -e "\t$feat_enum, /*!< ARM:$feat_descr */" >> "$TMP_LIBCPUID_H" echo -e "\t$feat_enum, /*!< ARM:$feat_descr */" >> "$TMP_LIBCPUID_H"
echo -e "\t\t{ $feat_enum, \"$feat_name\" }," >> "$TMP_CPUID_MAIN_C" echo -e "\t\t{ $feat_enum, \"$feat_name\" }," >> "$TMP_CPUID_MAIN_C"
cat<<EOF >> "$TMP_RECOG_ARM_C"
[$feat_enum] = {
.ver_optional = -1,
.ver_mandatory = -1,
.fields = {
{ .aarch32_reg = NULL, .aarch64_reg = &raw->arm_id_aa64[], .highbit = , .lowbit = , .value = },
{ .aarch32_reg = NULL, .aarch64_reg = NULL, .highbit = 0, .lowbit = 0, .value = 0 }
}
},
EOF
fi fi
done done
echo "} cpu_feature_t;" >> "$TMP_LIBCPUID_H" echo "} cpu_feature_t;" >> "$TMP_LIBCPUID_H"
echo " };" >> "$TMP_CPUID_MAIN_C" echo " };" >> "$TMP_CPUID_MAIN_C"
echo -e "\t};" >> "$TMP_RECOG_ARM_C"
echo "Extracted data for enum cpu_feature_t written to '$TMP_LIBCPUID_H' file." echo "Extracted data for enum cpu_feature_t written to '$TMP_LIBCPUID_H' file."
echo "Extracted data for cpu_feature_str() matchtable written to '$TMP_CPUID_MAIN_C' file." echo "Extracted data for cpu_feature_str() matchtable written to '$TMP_CPUID_MAIN_C' file."
echo "Extracted data for struct arm_feature_map_t features_map written to '$TMP_RECOG_ARM_C' file."