#ifndef __ELF_FILE_LOADER_HEADER__ #define __ELF_FILE_LOADER_HEADER__ #define pr_fmt(fmt) "%s: " fmt, __func__ #include #include #include #include //#include //#include struct firmware { size_t size; const uint8_t *data; struct page **pages; /* firmware loader private fields */ void *priv; }; //#include /** * struct resource_table - firmware resource table header * @ver: version number * @num: number of resource entries * @reserved: reserved (must be zero) * @offset: array of offsets pointing at the various resource entries * * A resource table is essentially a list of system resources required * by the remote processor. It may also include configuration entries. * If needed, the remote processor firmware should contain this table * as a dedicated ".resource_table" ELF section. * * Some resources entries are mere announcements, where the host is informed * of specific remoteproc configuration. Other entries require the host to * do something (e.g. allocate a system resource). Sometimes a negotiation * is expected, where the firmware requests a resource, and once allocated, * the host should provide back its details (e.g. address of an allocated * memory region). * * The header of the resource table, as expressed by this structure, * contains a version number (should we need to change this format in the * future), the number of available resource entries, and their offsets * in the table. * * Immediately following this header are the resource entries themselves, * each of which begins with a resource entry header (as described below). */ struct resource_table { uint32_t ver; uint32_t num; uint32_t reserved[2]; uint32_t offset[0]; };// __packed; /** * struct fw_rsc_hdr - firmware resource entry header * @type: resource type * @data: resource data * * Every resource entry begins with a 'struct fw_rsc_hdr' header providing * its @type. The content of the entry itself will immediately follow * this header, and it should be parsed according to the resource type. */ struct fw_rsc_hdr { uint32_t type; uint8_t data[0]; };// __packed; /** * enum fw_resource_type - types of resource entries * * @RSC_CARVEOUT: request for allocation of a physically contiguous * memory region. * @RSC_DEVMEM: request to iommu_map a memory-based peripheral. * @RSC_TRACE: announces the availability of a trace buffer into which * the remote processor will be writing logs. * @RSC_VDEV: declare support for a virtio device, and serve as its * virtio header. * @RSC_INTMEM: (deprecated) request to map into kernel an internal memory * region. * @RSC_CUSTOM: a custom resource type that needs to be handled outside * remoteproc core. * @RSC_LAST: just keep this one at the end * * For more details regarding a specific resource type, please see its * dedicated structure below. * * Please note that these values are used as indices to the rproc_handle_rsc * lookup table, so please keep them sane. Moreover, @RSC_LAST is used to * check the validity of an index before the lookup table is accessed, so * please update it as needed. */ enum fw_resource_type { RSC_CARVEOUT = 0, RSC_DEVMEM = 1, RSC_TRACE = 2, RSC_VDEV = 3, RSC_INTMEM = 4, RSC_CUSTOM = 5, RSC_LAST = 6, }; /* PRU_ICSS_PRU_CTRL registers */ #define PRU_CTRL_CTRL 0x0000 #define PRU_CTRL_STS 0x0004 #define PRU_CTRL_WAKEUP_EN 0x0008 #define PRU_CTRL_CYCLE 0x000C #define PRU_CTRL_STALL 0x0010 #define PRU_CTRL_CTBIR0 0x0020 #define PRU_CTRL_CTBIR1 0x0024 #define PRU_CTRL_CTPPR0 0x0028 #define PRU_CTRL_CTPPR1 0x002C /* CTRL register bit-fields */ #define CTRL_CTRL_SOFT_RST_N BIT(0) #define CTRL_CTRL_EN BIT(1) #define CTRL_CTRL_SLEEPING BIT(2) #define CTRL_CTRL_CTR_EN BIT(3) #define CTRL_CTRL_SINGLE_STEP BIT(8) #define CTRL_CTRL_RUNSTATE BIT(15) /* PRU_ICSS_PRU_DEBUG registers */ #define PRU_DEBUG_GPREG(x) (0x0000 + (x) * 4) #define PRU_DEBUG_CT_REG(x) (0x0080 + (x) * 4) /** * enum pru_mem - PRU core memory range identifiers */ enum pru_mem { PRU_MEM_IRAM = 0, PRU_MEM_CTRL, PRU_MEM_DEBUG, PRU_MEM_MAX, }; /** * struct pru_private_data - PRU core private data * @id: PRU index * @fw_name: firmware name to be used for the PRU core * @eth_fw_name: firmware name to be used for PRUSS ethernet usecases on IDKs */ struct pru_private_data { uint32_t id; const char *fw_name; const char *eth_fw_name; }; /** * struct pru_match_private_data - match private data to handle multiple instances * @device_name: device name of the PRU processor core instance * @priv_data: PRU driver private data for this PRU processor core instance */ struct pru_match_private_data { const char *device_name; struct pru_private_data *priv_data; }; /** * struct pru_rproc: PRU remoteproc structure * @id: id of the PRU core within the PRUSS * @pruss: back-reference to parent PRUSS structure * @rproc: remoteproc pointer for this PRU core * @mbox: mailbox channel handle used for vring signalling with MPU * @client: mailbox client to request the mailbox channel * @mem_regions: data for each of the PRU memory regions * @intc_config: PRU INTC configuration data * @rmw_lock: lock for read, modify, write operations on registers * @iram_da: device address of Instruction RAM for this PRU * @pdram_da: device address of primary Data RAM for this PRU * @sdram_da: device address of secondary Data RAM for this PRU * @shrdram_da: device address of shared Data RAM * @fw_name: name of firmware image used during loading * @dbg_single_step: debug flag to set PRU into single step mode * @dbg_continuous: debug flag to restore PRU execution mode */ /* struct pru_rproc { int id; struct pruss *pruss; struct rproc *rproc; struct mbox_chan *mbox; struct mbox_client client; struct pruss_mem_region mem_regions[PRU_MEM_MAX]; struct pruss_intc_config intc_config; spinlock_t rmw_lock; // register access lock uint32_t iram_da; uint32_t pdram_da; uint32_t sdram_da; uint32_t shrdram_da; const char *fw_name; uint32_t dbg_single_step; uint32_t dbg_continuous; }; //#include //#include "remoteproc_internal.h" int load_elf_fw( const char *name, const struct firmware *fw ); int elf_sanity_check( const struct firmware *fw ); uint32_t elf_get_boot_addr( const struct firmware *fw ); int elf_load_segments( const struct firmware *fw ); */ #endif