1 /*
2 * Copyright 2025 NXP
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7 /*
8 * NXP resource table
9 *
10 * Remote processors include a "resource table" section in addition
11 * to standard ELF segments.
12 *
13 * The resource table lists system resources needed before powering on,
14 * like contiguous memory allocation or IOMMU mapping.
15 * It also includes entries for supported features and configurations,
16 * such as trace buffers and virtio devices.
17 *
18 * Dependencies:
19 * Must be linked in the ".resource_table" section to comply with
20 * Linux kernel OS.
21 *
22 * Related documentation:
23 * https://www.kernel.org/doc/Documentation/remoteproc.txt
24 * https://openamp.readthedocs.io/en/latest/protocol_details/lifecyclemgmt.html
25 */
26
27 #include "../vendor/nxp_resource_table.h"
28
29 #include <zephyr/kernel.h>
30
31 #define __resource Z_GENERIC_SECTION(.resource_table)
32
33 static struct nxp_resource_table __resource nxp_rsc_table = {
34 .hdr = {
35 .ver = 1,
36 .num = 2,
37 },
38 .offset = {
39 offsetof(struct nxp_resource_table, imx_vs_entry),
40 offsetof(struct nxp_resource_table, vdev),
41 },
42 .imx_vs_entry = {
43 .type = RSC_VENDOR_START,
44 /* length of the resource entry, without type, but including len */
45 .len = 0x10,
46 /* FW_RSC_NXP_S_MAGIC, 'n''x''p''s' */
47 .magic_num = 0x6E787073,
48 .version = 0x0,
49 /* require the host NOT to wait for a FW_READY response */
50 .features = 0x1,
51 },
52 /* 8 is the number of rpmsg buffers used */
53 VDEV_ENTRY_HELPER(8)
54 };
55
rsc_table_get(void ** table_ptr,int * length)56 void rsc_table_get(void **table_ptr, int *length)
57 {
58 *length = sizeof(nxp_rsc_table);
59 *table_ptr = &nxp_rsc_table;
60 }
61
rsc_table_to_vdev(void * rsc_table)62 struct fw_rsc_vdev *rsc_table_to_vdev(void *rsc_table)
63 {
64 return &((struct nxp_resource_table *)rsc_table)->vdev;
65 }
66
rsc_table_get_vring0(void * rsc_table)67 struct fw_rsc_vdev_vring *rsc_table_get_vring0(void *rsc_table)
68 {
69 return &((struct nxp_resource_table *)rsc_table)->vring0;
70 }
71
rsc_table_get_vring1(void * rsc_table)72 struct fw_rsc_vdev_vring *rsc_table_get_vring1(void *rsc_table)
73 {
74 return &((struct nxp_resource_table *)rsc_table)->vring1;
75 }
76