1 /*
2 * Copyright (c) 2020 STMicroelectronics
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7 /*
8 * In addition to the standard ELF segments, most remote processors would
9 * also include a special section which we call "the resource table".
10 *
11 * The resource table contains system resources that the remote processor
12 * requires before it should be powered on, such as allocation of physically
13 * contiguous memory, or iommu mapping of certain on-chip peripherals.
14
15 * In addition to system resources, the resource table may also contain
16 * resource entries that publish the existence of supported features
17 * or configurations by the remote processor, such as trace buffers and
18 * supported virtio devices (and their configurations).
19
20 * Dependencies:
21 * to be compliant with Linux kernel OS the resource table must be linked in a
22 * specific section named ".resource_table".
23
24 * Related documentation:
25 * https://www.kernel.org/doc/Documentation/remoteproc.txt
26 * https://github.com/OpenAMP/open-amp/wiki/OpenAMP-Life-Cycle-Management
27 */
28
29 #include <zephyr/kernel.h>
30 #include <resource_table.h>
31
32 extern char ram_console_buf[];
33
34 #define __resource Z_GENERIC_SECTION(.resource_table)
35
36 static struct fw_resource_table __resource resource_table = {
37 .hdr = {
38 .ver = 1,
39 .num = RSC_TABLE_NUM_ENTRY,
40 },
41 .offset = {
42
43 #if (CONFIG_OPENAMP_RSC_TABLE_NUM_RPMSG_BUFF > 0)
44 offsetof(struct fw_resource_table, vdev),
45 #endif
46
47 #if defined(CONFIG_RAM_CONSOLE)
48 offsetof(struct fw_resource_table, cm_trace),
49 #endif
50 },
51
52 #if (CONFIG_OPENAMP_RSC_TABLE_NUM_RPMSG_BUFF > 0)
53 /* Virtio device entry */
54 .vdev = {
55 RSC_VDEV, VIRTIO_ID_RPMSG, 0, RPMSG_IPU_C0_FEATURES, 0, 0, 0,
56 VRING_COUNT, {0, 0},
57 },
58
59 /* Vring rsc entry - part of vdev rsc entry */
60 .vring0 = {VRING_TX_ADDRESS, VRING_ALIGNMENT,
61 CONFIG_OPENAMP_RSC_TABLE_NUM_RPMSG_BUFF,
62 VRING0_ID, 0},
63 .vring1 = {VRING_RX_ADDRESS, VRING_ALIGNMENT,
64 CONFIG_OPENAMP_RSC_TABLE_NUM_RPMSG_BUFF,
65 VRING1_ID, 0},
66 #endif
67
68 #if defined(CONFIG_RAM_CONSOLE)
69 .cm_trace = {
70 RSC_TRACE,
71 (uint32_t)ram_console_buf, CONFIG_RAM_CONSOLE_BUFFER_SIZE, 0,
72 "Zephyr_log",
73 },
74 #endif
75 };
76
rsc_table_get(struct fw_resource_table ** table_ptr,int * length)77 void rsc_table_get(struct fw_resource_table **table_ptr, int *length)
78 {
79 *table_ptr = &resource_table;
80 *length = sizeof(resource_table);
81 }
82