Changeset View
Changeset View
Standalone View
Standalone View
sys/tools/arm_kernel_boothdr.awk
Show First 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | if (hdrtype != "v7jump" && | ||||
hdrtype != "v8booti") { | hdrtype != "v8booti") { | ||||
print "arm_kernel_boothdr.awk: " \ | print "arm_kernel_boothdr.awk: " \ | ||||
"missing or invalid '-v hdrtype=' argument" >"/dev/stderr" | "missing or invalid '-v hdrtype=' argument" >"/dev/stderr" | ||||
gHdrType = "error_reported" | gHdrType = "error_reported" | ||||
exit 1 | exit 1 | ||||
} | } | ||||
gHdrType = hdrtype | gHdrType = hdrtype | ||||
for (i = 0; i < 16; i++) { | |||||
hex[sprintf("%x", i)] = i; | |||||
hex[sprintf("%X", i)] = i; | |||||
} | } | ||||
} | |||||
function addr_to_offset(addr) { | function addr_to_offset(addr) { | ||||
# Turn an address into an offset from the start of the loaded image. | # Turn an address into an offset from the start of the loaded image. | ||||
return addr % gKernbase | return addr % gKernbase | ||||
} | } | ||||
function hexstr_to_num(str) { | function hexstr_to_num(str) { | ||||
# Prepend a 0x onto the string, then coerce it to a number by doing | sum = 0; | ||||
# arithmetic with it, which makes awk run it through strtod(), | len = length(str); | ||||
# which handles hex numbers that have a 0x prefix. | for (i = 1; i <= len; i++) { | ||||
sum = sum * 16 + hex[substr(str, i, 1)]; | |||||
} | |||||
return 0 + ("0x" str) | return sum; | ||||
} | } | ||||
function write_le32(num) { | function write_le32(num) { | ||||
for (i = 0; i < 4; i++) { | for (i = 0; i < 4; i++) { | ||||
printf("%c", num % 256); | printf("%c", num % 256); | ||||
num /= 256 | num /= 256 | ||||
} | } | ||||
▲ Show 20 Lines • Show All 118 Lines • Show Last 20 Lines |