diff options
author | Mikael Olsson <mikael.olsson@arm.com> | 2023-05-31 19:00:48 +0200 |
---|---|---|
committer | Mikael Olsson <mikael.olsson@arm.com> | 2023-09-28 11:53:42 +0200 |
commit | 67add21188c70240b8966cdd707b03c02bd41a56 (patch) | |
tree | 77219fcd0095e060063ac90ce0afbbc18b052cb3 /applications/message_handler_openamp/remoteproc.hpp | |
parent | fdd8b41d12a8fd729619dee12080e65ec151865c (diff) | |
download | ethos-u-core-platform-67add21188c70240b8966cdd707b03c02bd41a56.tar.gz |
Add resource table entry for address translation
To avoid having to use a hardcoded memory map to translate between the
Linux physical addresses and device addresses, a new entry type has been
added to the resource table where the host can provide the memory map to
use for the translation.
Change-Id: I668bba3aeac27c358647c969c5504326e1c91d24
Signed-off-by: Mikael Olsson <mikael.olsson@arm.com>
Diffstat (limited to 'applications/message_handler_openamp/remoteproc.hpp')
-rw-r--r-- | applications/message_handler_openamp/remoteproc.hpp | 85 |
1 files changed, 48 insertions, 37 deletions
diff --git a/applications/message_handler_openamp/remoteproc.hpp b/applications/message_handler_openamp/remoteproc.hpp index eec7b44..090a3ea 100644 --- a/applications/message_handler_openamp/remoteproc.hpp +++ b/applications/message_handler_openamp/remoteproc.hpp @@ -1,6 +1,5 @@ /* * SPDX-FileCopyrightText: Copyright 2022-2023 Arm Limited and/or its affiliates <open-source-office@arm.com> - * * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the License); you may @@ -36,13 +35,47 @@ * Resource table *****************************************************************************/ +static constexpr uint32_t RSC_MAPPING = RSC_VENDOR_START + 1; + +/** + * struct fw_rsc_map_range - memory map range + * @da: Start device address of the memory address range + * @pa: Start physical address of the memory address range + * @len: length of memory address range + * + * Memory range to translate between physical and device addresses. + */ +METAL_PACKED_BEGIN +struct fw_rsc_map_range { + uint32_t da; + uint32_t pa; + uint32_t len; +} METAL_PACKED_END; + +/** + * struct fw_rsc_mapping - memory map for address translation + * @type: RSC_MAPPING + * @num_ranges: Number of ranges in the memory map + * @range: Array of the ranges in the memory map + * + * This resource entry requests the host to provide information for how to + * translate between physical and device addresses. + */ +METAL_PACKED_BEGIN +struct fw_rsc_mapping { + uint32_t type; + uint8_t num_ranges; + struct fw_rsc_map_range range[0]; +} METAL_PACKED_END; + struct ResourceTable { static constexpr uint32_t VERSION = 1; #if defined(REMOTEPROC_TRACE_BUFFER) - static constexpr uint32_t NUM_RESOURCES = 3; + static constexpr uint32_t NUM_RESOURCES = 4; #else - static constexpr uint32_t NUM_RESOURCES = 2; + static constexpr uint32_t NUM_RESOURCES = 3; #endif + static constexpr uint32_t NUM_RANGES = 2; static constexpr uint32_t NUM_VRINGS = 2; static constexpr uint32_t VRING_ALIGN = 0x100; static constexpr uint32_t VRING_SIZE = 0x08; @@ -50,6 +83,8 @@ struct ResourceTable { resource_table table; uint32_t offset[NUM_RESOURCES]; + fw_rsc_mapping mapping; + fw_rsc_map_range range[NUM_RANGES]; #if defined(REMOTEPROC_TRACE_BUFFER) fw_rsc_trace trace; #endif @@ -59,31 +94,12 @@ struct ResourceTable { } __attribute__((packed)); /***************************************************************************** - * MetalIO - *****************************************************************************/ - -class MetalIO { -public: - MetalIO(); - - remoteproc_mem *operator&(); - -private: - static metal_phys_addr_t offsetToPhys(metal_io_region *io, unsigned long offset); - static unsigned long physToOffset(metal_io_region *io, metal_phys_addr_t phys); - - metal_io_ops ops; - metal_io_region region; - remoteproc_mem mem; -}; - -/***************************************************************************** * RProc *****************************************************************************/ class RProc { public: - RProc(Mailbox::Mailbox &_mailbox, resource_table &table, size_t tableSize, MetalIO &_mem); + RProc(Mailbox::Mailbox &_mailbox, resource_table &table, size_t tableSize); ~RProc(); remoteproc *getRProc(); @@ -99,30 +115,25 @@ private: // Remote proc ops static struct remoteproc *init(remoteproc *rproc, const remoteproc_ops *ops, void *arg); static void remove(remoteproc *rproc); - static void *mmap(remoteproc *rproc, - metal_phys_addr_t *pa, - metal_phys_addr_t *da, - size_t size, - unsigned int attribute, - metal_io_region **io); + static int handle_rsc(struct remoteproc *rproc, void *rsc, size_t len); static int notify(remoteproc *rproc, uint32_t id); - static struct remoteproc_mem *getMem(remoteproc *rproc, - const char *name, - metal_phys_addr_t pa, - metal_phys_addr_t da, - void *va, - size_t size, - remoteproc_mem *buf); // IRQ notification Mailbox::Mailbox &mailbox; // Remoteproc - MetalIO &mem; remoteproc rproc; remoteproc_ops ops; virtio_device *vdev; + // Resource table memory region + remoteproc_mem rsc_mem; + metal_io_region rsc_region; + + // Host provided memory regions + remoteproc_mem mems[ResourceTable::NUM_RANGES]; + metal_io_region regions[ResourceTable::NUM_RANGES]; + // FreeRTOS SemaphoreHandle_t notifySemaphore; TaskHandle_t notifyHandle; |