Parse a Binary Firmware Header
Problem statement
Parse the following authored practice header and return [version,imageSize] as nonnegative64-bit values. This is a practice format, not a documented AMD firmware layout.
- Bytes0..3: ASCII GPUF magic.
- Byte4: byte-order tag,0=little-endian and1=big-endian.
- Bytes5..6: unsigned16-bit version.
- Bytes7..10: unsigned32-bit imageSize.
The tag applies to both numeric fields. The input contains only the11-byte header; imageSize is metadata and does not imply a payload is included. Inputs are valid headers; validation of malformed files is outside this contract.
Function
parseFirmwareHeader(data: int[]) → long[]Examples
Example 1
data = [71,80,85,70,0,2,1,4,3,2,1]return = [258,16909060]Little-endian bytes [2,1] give version258; [4,3,2,1] give imageSize16909060.
Example 2
data = [71,80,85,70,1,255,255,255,255,255,255]return = [65535,4294967295]All-one numeric fields are the maximum unsigned16 and unsigned32 values, returned positively.
Constraints
data.length == 11.0 <= data[i] <= 255.- The first four bytes are [71,80,85,70] (ASCII GPUF), and data[4] is either 0 or 1.