Project

General

Profile

Submit #3042 ยป 0001-firmware-endianness-support-for-fw_stub.awk.patch

Anonymous, 06/03/2017 03:26 AM

View differences:

sys/tools/fw_stub.awk
print s > "/dev/stdout";
}
# The function prints call of firmware_register() function for
# registering a firmware within the firmware subsystem.
# Return value of the firmware_register() C call is placed into the C
# fp variable.
# Paremeter reg is only a local variable. It is not used for passing
# arguments to the AWK function.
function print_firmware_register(file_i, short, symb, version, parent, reg) {
reg = "\t\tfp = ";
reg = reg "firmware_register(\"" short "\", _binary_" symb "_start , ";
reg = reg "(size_t)(_binary_" symb "_end - _binary_" symb "_start), ";
reg = reg version ", ";
if (file_i == 0)
reg = reg "NULL);";
else
reg = reg "parent);";
printc(reg);
}
BEGIN {
#
......
versions[num_files] = int(curr[3]);
else
versions[num_files] = 0;
# Get path to a big-endian version of the firmware if it was
# entered
if (length(curr[4]) > 0)
big_endian_filenames[num_files] = curr[4];
else
big_endian_filenames[num_files] = "";
num_files++;
}
}
......
for (file_i = 0; file_i < num_files; file_i++) {
symb = filenames[file_i];
big_endian_symb = big_endian_filenames[file_i];
# '-', '.' and '/' are converted to '_' by ld/objcopy
gsub(/-|\.|\//, "_", symb);
gsub(/-|\.|\//, "_", big_endian_symb);
printc("extern char _binary_" symb "_start[], _binary_" symb "_end[];");
printc("extern char _binary_" big_endian_symb "_start[], _binary_" big_endian_symb "_end[];");
}
printc("\nstatic int\n"\
......
short = shortnames[file_i];
symb = filenames[file_i];
version = versions[file_i];
big_endian_symb = big_endian_filenames[file_i];
# '-', '.' and '/' are converted to '_' by ld/objcopy
gsub(/-|\.|\//, "_", symb);
reg = "\t\tfp = ";
reg = reg "firmware_register(\"" short "\", _binary_" symb "_start , ";
reg = reg "(size_t)(_binary_" symb "_end - _binary_" symb "_start), ";
reg = reg version ", ";
if (length(big_endian_symb) > 0) {
gsub(/-|\.|\//, "_", big_endian_symb);
printc("#if BYTE_ORDER == BIG_ENDIAN");
print_firmware_register(file_i, short, big_endian_symb, version, parent);
printc("#else");
}
if (file_i == 0)
reg = reg "NULL);";
else
reg = reg "parent);";
print_firmware_register(file_i, short, symb, version, parent);
printc(reg);
if (length(big_endian_symb) > 0) {
printc("#endif");
}
printc("\t\tif (fp == NULL)");
printc("\t\t\tgoto fail_" file_i ";");
    (1-1/1)