blob: 2942fe6ccfe73d86745de5a49c12e3bba7fb7057 [file] [log] [blame]
Arnaud Pouliquen25ec7392019-09-20 11:41:38 +02001/*
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.h>
30#include <resource_table.h>
31
32extern char ram_console[];
33
34#define __resource Z_GENERIC_SECTION(.resource_table)
35
Arnaud Pouliquen25ec7392019-09-20 11:41:38 +020036static struct fw_resource_table __resource resource_table = {
37 .ver = 1,
38 .num = RSC_TABLE_NUM_ENTRY,
39 .offset = {
40
41#if (CONFIG_OPENAMP_RSC_TABLE_NUM_RPMSG_BUFF > 0)
42 offsetof(struct fw_resource_table, vdev),
43#endif
44
45#if defined(CONFIG_RAM_CONSOLE)
46 offsetof(struct fw_resource_table, cm_trace),
47#endif
48 },
49
50#if (CONFIG_OPENAMP_RSC_TABLE_NUM_RPMSG_BUFF > 0)
51 /* Virtio device entry */
52 .vdev = {
53 RSC_VDEV, VIRTIO_ID_RPMSG, 0, RPMSG_IPU_C0_FEATURES, 0, 0, 0,
54 VRING_COUNT, {0, 0},
55 },
56
57 /* Vring rsc entry - part of vdev rsc entry */
58 .vring0 = {VRING_TX_ADDRESS, VRING_ALIGNMENT,
59 CONFIG_OPENAMP_RSC_TABLE_NUM_RPMSG_BUFF,
60 VRING0_ID, 0},
61 .vring1 = {VRING_RX_ADDRESS, VRING_ALIGNMENT,
62 CONFIG_OPENAMP_RSC_TABLE_NUM_RPMSG_BUFF,
63 VRING1_ID, 0},
64#endif
65
66#if defined(CONFIG_RAM_CONSOLE)
67 .cm_trace = {
68 RSC_TRACE,
69 (uint32_t)ram_console, CONFIG_RAM_CONSOLE_BUFFER_SIZE + 1, 0,
70 "Zephyr_log",
71 },
72#endif
73};
74
75void rsc_table_get(void **table_ptr, int *length)
76{
77 *table_ptr = (void *)&resource_table;
78 *length = sizeof(resource_table);
79}