|
| 1 | +/** |
| 2 | + * Xilinx SDAccel xclbin container definition |
| 3 | + * Copyright (C) 2015-2016, Xilinx Inc - All rights reserved |
| 4 | + */ |
| 5 | + |
| 6 | +#ifndef _XCLBIN_H_ |
| 7 | +#define _XCLBIN_H_ |
| 8 | + |
| 9 | +#if defined(__KERNEL__) |
| 10 | +#include <linux/types.h> |
| 11 | +#elif defined(__cplusplus) |
| 12 | +#include <cstdlib> |
| 13 | +#include <cstdint> |
| 14 | +#else |
| 15 | +#include <stdlib.h> |
| 16 | +#include <stdint.h> |
| 17 | +#endif |
| 18 | + |
| 19 | +#ifdef __cplusplus |
| 20 | +extern "C" { |
| 21 | +#endif |
| 22 | + |
| 23 | + /** |
| 24 | + * Container format for Xilinx bitstreams, metadata and other |
| 25 | + * binary blobs. |
| 26 | + * Every segment must be aligned at 8 byte boundary with null byte padding |
| 27 | + * between adjacent segments if required. |
| 28 | + * For segements which are not present both offset and length must be 0 in |
| 29 | + * the header. |
| 30 | + * Currently only xclbin0\0 is recognized as file magic. In future if/when file |
| 31 | + * format is updated the magic string will be changed to xclbin1\0 and so on. |
| 32 | + */ |
| 33 | + enum XCLBIN_MODE { |
| 34 | + XCLBIN_FLAT, |
| 35 | + XCLBIN_PR, |
| 36 | + XCLBIN_TANDEM_STAGE2, |
| 37 | + XCLBIN_TANDEM_STAGE2_WITH_PR, |
| 38 | + XCLBIN_MODE_MAX |
| 39 | + }; |
| 40 | + |
| 41 | + struct xclBin { |
| 42 | + char m_magic[8]; /* should be xclbin0\0 */ |
| 43 | + uint64_t m_length; /* total size of the xclbin file */ |
| 44 | + uint64_t m_timeStamp; /* number of seconds since epoch when xclbin was created */ |
| 45 | + uint64_t m_version; /* tool version used to create xclbin */ |
| 46 | + unsigned m_mode; /* XCLBIN_MODE */ |
| 47 | + char m_nextXclBin[24]; /* Name of next xclbin file in the daisy chain */ |
| 48 | + uint64_t m_metadataOffset; /* file offset of embedded metadata */ |
| 49 | + uint64_t m_metadataLength; /* size of the embedded metdata */ |
| 50 | + uint64_t m_primaryFirmwareOffset; /* file offset of bitstream or emulation archive */ |
| 51 | + uint64_t m_primaryFirmwareLength; /* size of the bistream or emulation archive */ |
| 52 | + uint64_t m_secondaryFirmwareOffset; /* file offset of clear bitstream if any */ |
| 53 | + uint64_t m_secondaryFirmwareLength; /* size of the clear bitstream */ |
| 54 | + uint64_t m_driverOffset; /* file offset of embedded device driver if any (currently unused) */ |
| 55 | + uint64_t m_driverLength; /* size of the embedded device driver (currently unused) */ |
| 56 | + |
| 57 | + // Extra debug information for hardware and hardware emulation debug |
| 58 | + |
| 59 | + uint64_t m_dwarfOffset ; |
| 60 | + uint64_t m_dwarfLength ; |
| 61 | + uint64_t m_ipiMappingOffset ; |
| 62 | + uint64_t m_ipiMappingLength ; |
| 63 | + }; |
| 64 | + |
| 65 | + /* |
| 66 | + * XCLBIN1 LAYOUT |
| 67 | + * -------------- |
| 68 | + * |
| 69 | + * ----------------------------------------- |
| 70 | + * | Magic | |
| 71 | + * ----------------------------------------- |
| 72 | + * | Header | |
| 73 | + * ----------------------------------------- |
| 74 | + * | One or more section headers | |
| 75 | + * ----------------------------------------- |
| 76 | + * | Matching number of sections with data | |
| 77 | + * ----------------------------------------- |
| 78 | + * |
| 79 | + */ |
| 80 | + enum xclBin1SectionKind { |
| 81 | + BITSTREAM, |
| 82 | + CLEARING_BITSTREAM, |
| 83 | + EMBEDDED_METADATA, |
| 84 | + FIRMWARE, |
| 85 | + DEBUG_DATA |
| 86 | + }; |
| 87 | + |
| 88 | + struct xclBin1SectionHeader { |
| 89 | + unsigned m_sectionKind; /* Section type */ |
| 90 | + unsigned short m_freq[4]; /* Target frequency for the section if applicable */ |
| 91 | + char m_sectionName[16]; /* Examples: "stage2", "clear1", "clear2", "ocl1", "ocl2, "ublaze" */ |
| 92 | + unsigned m_customFlagsA; /* Example: Number of Kernels in this region */ |
| 93 | + unsigned m_customFlagsB; /* Example: Number of Kernels in this region */ |
| 94 | + uint64_t m_sectionOffset; /* File offset of section data */ |
| 95 | + uint64_t m_sectionSize; /* Size of section data */ |
| 96 | + }; |
| 97 | + |
| 98 | + struct xclBin1Header { |
| 99 | + uint64_t m_length; /* Total size of the xclbin file */ |
| 100 | + uint64_t m_timeStamp; /* Number of seconds since epoch when xclbin was created */ |
| 101 | + unsigned m_version; /* Tool version used to create xclbin */ |
| 102 | + unsigned m_mode; /* XCLBIN_MODE */ |
| 103 | + uint64_t m_platformId; /* 64 bit platform ID: vendor-device-subvendor-subdev */ |
| 104 | + uint64_t m_featureId; /* 64 bit feature id */ |
| 105 | + char m_nextXclBin[16]; /* Name of next xclbin file in the daisy chain */ |
| 106 | + char m_debugBin[16]; /* Name of binary with debug information */ |
| 107 | + unsigned m_numSections; /* Number of section headers */ |
| 108 | + }; |
| 109 | + |
| 110 | + struct xclBin1 { |
| 111 | + char m_magic[8]; /* Should be xclbin1\0 */ |
| 112 | + uint64_t m_signature[4]; /* File signature for validation of binary */ |
| 113 | + struct xclBin1Header m_header; /* Inline header */ |
| 114 | + struct xclBin1SectionHeader m_sections[1]; /* One or more section headers follow */ |
| 115 | + }; |
| 116 | + |
| 117 | + |
| 118 | +#ifdef __cplusplus |
| 119 | +} |
| 120 | +#endif |
| 121 | + |
| 122 | +#endif |
| 123 | + |
| 124 | +// XSIP watermark, do not delete 67d7842dbbe25473c3c32b93c0da8047785f30d78e8a024de1b57352245f9689 |
0 commit comments