Root/qiboot/tools/usb_dfu_trailer.h

1#ifndef _USB_DFU_TRAILER_H
2#define _USB_DFU_TRAILER_H
3
4/* trailer handling for DFU files */
5
6#define UBOOT_DFU_TRAILER_V1 1
7#define UBOOT_DFU_TRAILER_MAGIC 0x19731978
8struct uboot_dfu_trailer {
9    u_int32_t magic;
10    u_int16_t version;
11    u_int16_t length;
12    u_int16_t vendor;
13    u_int16_t product;
14    u_int32_t revision;
15} __attribute__((packed));
16
17/* we mirror the trailer because we want it to be longer in later versions
18 * while keeping backwards compatibility */
19static inline void dfu_trailer_mirror(struct uboot_dfu_trailer *trailer,
20                      unsigned char *eof)
21{
22    int i;
23    int len = sizeof(struct uboot_dfu_trailer);
24    unsigned char *src = eof - len;
25    unsigned char *dst = (unsigned char *) trailer;
26
27    for (i = 0; i < len; i++)
28        dst[len-1-i] = src[i];
29}
30
31#endif /* _USB_DFU_TRAILER_H */
32

Archive Download this file



interactive