-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
resource table: add helper to add resource table in project. #2
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# | ||
# Copyright (c) 2019 STMicroelectronics | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
|
||
zephyr_include_directories_ifdef(CONFIG_RSC_TABLE .) | ||
zephyr_sources_ifdef(CONFIG_RSC_TABLE resource_table.c) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
|
||
Description: | ||
|
||
In addition to the standard ELF segments, most remote processors would | ||
also include a special section which we call "the resource table". | ||
|
||
The resource table contains system resources that the remote processor | ||
requires before it should be powered on, such as allocation of physically | ||
contiguous memory, or iommu mapping of certain on-chip peripherals. | ||
|
||
In addition to system resources, the resource table may also contain | ||
resource entries that publish the existence of supported features | ||
or configurations by the remote processor, such as trace buffers and | ||
supported virtio devices (and their configurations). | ||
|
||
Dependencies: | ||
to be compliant with Linux kernel OS the resource table must be linked in a | ||
specific section named ".resource_table". | ||
|
||
Related documentation: | ||
https://www.kernel.org/doc/Documentation/remoteproc.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* Copyright (c) 2019 STMicroelectronics | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#include <zephyr.h> | ||
#include <resource_table.h> | ||
|
||
extern char ram_console[]; | ||
|
||
#define __section_t(S) __attribute__((__section__(#S))) | ||
#define __resource __section_t(.resource_table) | ||
|
||
#if (CONFIG_RSC_TABLE_NUM_RPMSG_BUFF > 0) || defined(CONFIG_RAM_CONSOLE) | ||
|
||
static struct fw_resource_table __resource resource_table = { | ||
.ver = 1, | ||
.num = RSC_TABLE_NUM_ENTRY, | ||
.offset = { | ||
#if (CONFIG_RSC_TABLE_NUM_RPMSG_BUFF > 0) | ||
offsetof(struct fw_resource_table, vdev), | ||
#endif | ||
#if defined(CONFIG_RAM_CONSOLE) | ||
offsetof(struct fw_resource_table, cm_trace), | ||
#endif | ||
}, | ||
|
||
#if (CONFIG_RSC_TABLE_NUM_RPMSG_BUFF > 0) | ||
/* Virtio device entry */ | ||
.vdev = { | ||
RSC_VDEV, VIRTIO_ID_RPMSG, 0, RPMSG_IPU_C0_FEATURES, 0, 0, 0, | ||
VRING_COUNT, {0, 0}, | ||
}, | ||
|
||
/* Vring rsc entry - part of vdev rsc entry */ | ||
.vring0 = {VRING_TX_ADDRESS, VRING_ALIGNMENT, | ||
CONFIG_RSC_TABLE_NUM_RPMSG_BUFF, | ||
VRING0_ID, 0}, | ||
.vring1 = {VRING_RX_ADDRESS, VRING_ALIGNMENT, | ||
CONFIG_RSC_TABLE_NUM_RPMSG_BUFF, | ||
VRING1_ID, 0}, | ||
#endif | ||
|
||
#if defined(CONFIG_RAM_CONSOLE) | ||
.cm_trace = { | ||
RSC_TRACE, | ||
(uint32_t)ram_console, CONFIG_RAM_CONSOLE_BUFFER_SIZE + 1, 0, | ||
"Zephyr_log", | ||
}, | ||
#endif | ||
}; | ||
|
||
void rsc_table_get(void **table_ptr, int *length) | ||
{ | ||
*table_ptr = (void *)&resource_table; | ||
*length = sizeof(resource_table); | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
* Copyright (c) 2019 STMicroelectronics | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#ifndef RESOURCE_TABLE_H__ | ||
#define RESOURCE_TABLE_H__ | ||
|
||
#include <openamp/remoteproc.h> | ||
#include <openamp/virtio.h> | ||
|
||
#if (CONFIG_RSC_TABLE_NUM_RPMSG_BUFF > 0) | ||
|
||
#define VDEV_ID 0xFF | ||
#define VRING0_ID 0 /* (master to remote) fixed to 0 for Linux compatibility */ | ||
#define VRING1_ID 1 /* (remote to master) fixed to 1 for Linux compatibility */ | ||
|
||
#define VRING_COUNT 2 | ||
#define RPMSG_IPU_C0_FEATURES 1 | ||
|
||
#define VRING_RX_ADDRESS -1 /* allocated by Master processor */ | ||
#define VRING_TX_ADDRESS -1 /* allocated by Master processor */ | ||
#define VRING_BUFF_ADDRESS -1 /* allocated by Master processor */ | ||
#define VRING_ALIGNMENT 16 /* fixed to match with Linux constraint */ | ||
|
||
#endif | ||
|
||
enum rsc_table_entries { | ||
#if (CONFIG_RSC_TABLE_NUM_RPMSG_BUFF > 0) | ||
RSC_TABLE_VDEV_ENTRY, | ||
#endif | ||
#if defined(CONFIG_RAM_CONSOLE) | ||
RSC_TABLE_TRACE_ENTRY, | ||
#endif | ||
RSC_TABLE_NUM_ENTRY | ||
}; | ||
|
||
struct fw_resource_table { | ||
unsigned int ver; | ||
unsigned int num; | ||
unsigned int reserved[2]; | ||
unsigned int offset[RSC_TABLE_NUM_ENTRY]; | ||
|
||
struct fw_rsc_vdev vdev; | ||
struct fw_rsc_vdev_vring vring0; | ||
struct fw_rsc_vdev_vring vring1; | ||
|
||
#if defined(CONFIG_RAM_CONSOLE) | ||
/* rpmsg trace entry */ | ||
struct fw_rsc_trace cm_trace; | ||
#endif | ||
} OPENAMP_PACKED_END; | ||
|
||
void rsc_table_get(void **table_ptr, int *length); | ||
|
||
inline struct fw_rsc_vdev *rsc_table_to_vdev(void *rsc_table) | ||
{ | ||
return &((struct fw_resource_table *)rsc_table)->vdev; | ||
} | ||
|
||
inline struct fw_rsc_vdev_vring *rsc_table_get_vring0(void *rsc_table) | ||
{ | ||
return &((struct fw_resource_table *)rsc_table)->vring0; | ||
} | ||
|
||
inline struct fw_rsc_vdev_vring *rsc_table_get_vring1(void *rsc_table) | ||
{ | ||
return &((struct fw_resource_table *)rsc_table)->vring1; | ||
} | ||
|
||
#endif |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like these files would be better to live in the Zephyr code base and not here. So maybe adding them in lib/open-amp/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the suggestion. I was not convince either that this was the best place for these files....
So I'll move them, and close this pull request