From b3e4809554c1c75bf196279f02cb4929fa3c0378 Mon Sep 17 00:00:00 2001 From: Iuliana Prodan Date: Mon, 16 Jun 2025 13:12:25 +0300 Subject: [PATCH] lib: open-amp: Add NXP-specific resource table implementation Implement NXP-specific support for the remote processor resource table, including custom definitions and initialization logic to meet NXP's communication requirements. Signed-off-by: Iuliana Prodan --- lib/open-amp/vendor/nxp_resource_table.c | 75 ++++++++++++++++++++++++ lib/open-amp/vendor/nxp_resource_table.h | 50 ++++++++++++++++ 2 files changed, 125 insertions(+) create mode 100644 lib/open-amp/vendor/nxp_resource_table.c create mode 100644 lib/open-amp/vendor/nxp_resource_table.h diff --git a/lib/open-amp/vendor/nxp_resource_table.c b/lib/open-amp/vendor/nxp_resource_table.c new file mode 100644 index 00000000000..3591e55b9d6 --- /dev/null +++ b/lib/open-amp/vendor/nxp_resource_table.c @@ -0,0 +1,75 @@ +/* + * Copyright 2025 NXP + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * NXP resource table + * + * Remote processors include a "resource table" section in addition + * to standard ELF segments. + * + * The resource table lists system resources needed before powering on, + * like contiguous memory allocation or IOMMU mapping. + * It also includes entries for supported features and configurations, + * such as trace buffers and virtio devices. + * + * Dependencies: + * Must be linked in the ".resource_table" section to comply with + * Linux kernel OS. + * + * Related documentation: + * https://www.kernel.org/doc/Documentation/remoteproc.txt + * https://openamp.readthedocs.io/en/latest/protocol_details/lifecyclemgmt.html + */ + +#include "../vendor/nxp_resource_table.h" + +#include + +#define __resource Z_GENERIC_SECTION(.resource_table) + +static struct nxp_resource_table __resource nxp_rsc_table = { + .hdr = { + .ver = 1, + .num = 2, + }, + .offset = { + offsetof(struct nxp_resource_table, imx_vs_entry), + offsetof(struct nxp_resource_table, vdev), + }, + .imx_vs_entry = { + .type = RSC_VENDOR_START, + /* length of the resource entry, without type, but including len */ + .len = 0x10, + /* FW_RSC_NXP_S_MAGIC, 'n''x''p''s' */ + .magic_num = 0x6E787073, + .version = 0x0, + /* require the host NOT to wait for a FW_READY response */ + .features = 0x1, + }, + /* 8 is the number of rpmsg buffers used */ + VDEV_ENTRY_HELPER(8) +}; + +void rsc_table_get(void **table_ptr, int *length) +{ + *length = sizeof(nxp_rsc_table); + *table_ptr = &nxp_rsc_table; +} + +struct fw_rsc_vdev *rsc_table_to_vdev(void *rsc_table) +{ + return &((struct nxp_resource_table *)rsc_table)->vdev; +} + +struct fw_rsc_vdev_vring *rsc_table_get_vring0(void *rsc_table) +{ + return &((struct nxp_resource_table *)rsc_table)->vring0; +} + +struct fw_rsc_vdev_vring *rsc_table_get_vring1(void *rsc_table) +{ + return &((struct nxp_resource_table *)rsc_table)->vring1; +} diff --git a/lib/open-amp/vendor/nxp_resource_table.h b/lib/open-amp/vendor/nxp_resource_table.h new file mode 100644 index 00000000000..e4ed33c2cec --- /dev/null +++ b/lib/open-amp/vendor/nxp_resource_table.h @@ -0,0 +1,50 @@ +/* + * Copyright 2025 NXP + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef NXP_RESOURCE_TABLE_H__ +#define NXP_RESOURCE_TABLE_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * struct fw_rsc_imx_dsp - i.MX DSP specific info + * + * @type: type of the resource entry + * @len: length of the resource entry, without @type, but including @len field + * @magic_num: 32-bit magic number + * @version: version of data structure + * @features: feature flags supported by the i.MX DSP firmware + * + * This represents a DSP-specific resource in the firmware's + * resource table, providing information on supported features. + */ +struct fw_rsc_imx_dsp { + uint32_t type; + uint32_t len; + uint32_t magic_num; + uint32_t version; + uint32_t features; +} __packed; + + +struct nxp_resource_table { + struct resource_table hdr; + uint32_t offset[2]; + struct fw_rsc_imx_dsp imx_vs_entry; + struct fw_rsc_vdev vdev; + struct fw_rsc_vdev_vring vring0; + struct fw_rsc_vdev_vring vring1; +} METAL_PACKED_END; + +#ifdef __cplusplus +} +#endif + +#endif