You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

112 lines
3.9 KiB

7 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #ifndef __ELF_FILE_LOADER_HEADER__
  2. #define __ELF_FILE_LOADER_HEADER__
  3. #define pr_fmt(fmt) "%s: " fmt, __func__
  4. #include <stdint.h>
  5. //#include <linux/module.h>
  6. //#include <linux/firmware.h>
  7. struct firmware {
  8. size_t size;
  9. const uint8_t *data;
  10. struct page **pages;
  11. /* firmware loader private fields */
  12. void *priv;
  13. };
  14. //#include <linux/remoteproc.h>
  15. /**
  16. * struct resource_table - firmware resource table header
  17. * @ver: version number
  18. * @num: number of resource entries
  19. * @reserved: reserved (must be zero)
  20. * @offset: array of offsets pointing at the various resource entries
  21. *
  22. * A resource table is essentially a list of system resources required
  23. * by the remote processor. It may also include configuration entries.
  24. * If needed, the remote processor firmware should contain this table
  25. * as a dedicated ".resource_table" ELF section.
  26. *
  27. * Some resources entries are mere announcements, where the host is informed
  28. * of specific remoteproc configuration. Other entries require the host to
  29. * do something (e.g. allocate a system resource). Sometimes a negotiation
  30. * is expected, where the firmware requests a resource, and once allocated,
  31. * the host should provide back its details (e.g. address of an allocated
  32. * memory region).
  33. *
  34. * The header of the resource table, as expressed by this structure,
  35. * contains a version number (should we need to change this format in the
  36. * future), the number of available resource entries, and their offsets
  37. * in the table.
  38. *
  39. * Immediately following this header are the resource entries themselves,
  40. * each of which begins with a resource entry header (as described below).
  41. */
  42. struct resource_table {
  43. uint32_t ver;
  44. uint32_t num;
  45. uint32_t reserved[2];
  46. uint32_t offset[0];
  47. };// __packed;
  48. /**
  49. * struct fw_rsc_hdr - firmware resource entry header
  50. * @type: resource type
  51. * @data: resource data
  52. *
  53. * Every resource entry begins with a 'struct fw_rsc_hdr' header providing
  54. * its @type. The content of the entry itself will immediately follow
  55. * this header, and it should be parsed according to the resource type.
  56. */
  57. struct fw_rsc_hdr {
  58. uint32_t type;
  59. uint8_t data[0];
  60. };// __packed;
  61. /**
  62. * enum fw_resource_type - types of resource entries
  63. *
  64. * @RSC_CARVEOUT: request for allocation of a physically contiguous
  65. * memory region.
  66. * @RSC_DEVMEM: request to iommu_map a memory-based peripheral.
  67. * @RSC_TRACE: announces the availability of a trace buffer into which
  68. * the remote processor will be writing logs.
  69. * @RSC_VDEV: declare support for a virtio device, and serve as its
  70. * virtio header.
  71. * @RSC_INTMEM: (deprecated) request to map into kernel an internal memory
  72. * region.
  73. * @RSC_CUSTOM: a custom resource type that needs to be handled outside
  74. * remoteproc core.
  75. * @RSC_LAST: just keep this one at the end
  76. *
  77. * For more details regarding a specific resource type, please see its
  78. * dedicated structure below.
  79. *
  80. * Please note that these values are used as indices to the rproc_handle_rsc
  81. * lookup table, so please keep them sane. Moreover, @RSC_LAST is used to
  82. * check the validity of an index before the lookup table is accessed, so
  83. * please update it as needed.
  84. */
  85. enum fw_resource_type {
  86. RSC_CARVEOUT = 0,
  87. RSC_DEVMEM = 1,
  88. RSC_TRACE = 2,
  89. RSC_VDEV = 3,
  90. RSC_INTMEM = 4,
  91. RSC_CUSTOM = 5,
  92. RSC_LAST = 6,
  93. };
  94. //#include <linux/elf.h>
  95. //#include "remoteproc_internal.h"
  96. int load_elf_fw( const char *name, const struct firmware *fw );
  97. int elf_sanity_check( const struct firmware *fw );
  98. uint32_t elf_get_boot_addr( const struct firmware *fw );
  99. int elf_load_segments( const struct firmware *fw );
  100. #endif