-
Notifications
You must be signed in to change notification settings - Fork 20
Xlnx add trace buf and update address space #98
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
Open
tnmysh
wants to merge
5
commits into
OpenAMP:main
Choose a base branch
from
tnmysh:xlnx_add_trace_buf_and_update_address_space
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
00d9840
legacy_apps: xlnx: fix native cmake compilation
tnmysh 7b61454
examples: legacy_apps: echo: include new header
tnmysh 32d2068
legacy_apps: matrix_multiply: fix compiler warning
tnmysh d2f01c7
exampples: legacy_apps: xlnx: update reserved mem regions
tnmysh b59ecf4
legacy_apps: zynqmp_r5: add trace buffer support
tnmysh 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
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -101,9 +101,9 @@ | |
| #endif /* versal */ | ||
| #ifndef SHARED_MEM_PA | ||
| #if XPAR_CPU_ID == 0 | ||
| #define SHARED_MEM_PA 0x3ED40000UL | ||
| #define SHARED_MEM_PA 0x9860000UL | ||
| #else | ||
| #define SHARED_MEM_PA 0x3EF40000UL | ||
| #define SHARED_MEM_PA 0x9C60000UL | ||
| #endif /* XPAR_CPU_ID */ | ||
| #endif /* !SHARED_MEM_PA */ | ||
|
|
||
|
|
@@ -122,7 +122,7 @@ | |
| #define XLNX_METAL_LOG_LEVEL METAL_LOG_INFO | ||
| #endif | ||
|
|
||
| void xlnx_log_handler(enum metal_log_level level, const char *format, ...); | ||
| static void xlnx_log_handler(enum metal_log_level level, const char *format, ...); | ||
|
|
||
| #define XLNX_PLATFORM_METAL_INIT_PARAMS \ | ||
| { \ | ||
|
|
@@ -184,6 +184,21 @@ int xlnx_hw_to_bsp_irq(int sys_irq); | |
| /* RPMsg virtio shared buffer pool */ | ||
| static struct rpmsg_virtio_shm_pool shpool; | ||
|
|
||
| /* circular buffer for trace buffer */ | ||
| static struct { | ||
| char *c_buf; | ||
| uint32_t c_len; | ||
| uint32_t c_pos; | ||
| uint32_t c_cnt; | ||
| } circ; | ||
|
|
||
| static void rsc_trace_putchar(char c) | ||
| { | ||
| if (circ.c_pos >= circ.c_len) | ||
| circ.c_pos = 0; | ||
| circ.c_buf[circ.c_pos++] = c; | ||
| } | ||
|
|
||
| static void xlnx_irq_isr(void *arg) | ||
| { | ||
| int vector; | ||
|
|
@@ -248,12 +263,54 @@ platform_create_proc(int proc_index, int rsc_index) | |
| return &rproc_inst; | ||
| } | ||
|
|
||
| static void xlnx_log_handler(enum metal_log_level level, | ||
| const char *format, ...) | ||
| { | ||
| static const char * const level_strs[] = { | ||
| "emergency", | ||
| "alert", | ||
| "critical", | ||
| "error", | ||
| "warning", | ||
| "notice", | ||
| "info", | ||
| "debug", | ||
| }; | ||
tnmysh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| char msg[128]; | ||
| char *p; | ||
| int32_t len; | ||
| va_list args; | ||
|
|
||
|
|
||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. useless double blank line |
||
| if (level > METAL_LOG_DEBUG) | ||
| level = METAL_LOG_EMERGENCY; | ||
|
|
||
| len = snprintf(msg, sizeof(msg), "%s: ", level_strs[level]); | ||
|
|
||
| circ.c_cnt++; | ||
|
|
||
| va_start(args, format); | ||
| vsnprintf(msg + len, (int32_t)sizeof(msg) - len, format, args); | ||
| va_end(args); | ||
|
|
||
| /* copy at most sizeof(msg) to the circular buffer */ | ||
| for (len = 0, p = msg; *p && len < (int32_t)sizeof(msg); ++len, ++p) | ||
| rsc_trace_putchar(*p); | ||
|
|
||
| xil_printf("%s", msg); | ||
| } | ||
|
|
||
| static int xlnx_machine_init(void) | ||
| { | ||
|
|
||
| struct metal_init_params metal_param = XLNX_PLATFORM_METAL_INIT_PARAMS; | ||
| int ret; | ||
|
|
||
| /* Init circular buffer */ | ||
| circ.c_buf = get_rsc_trace_info(&circ.c_len); | ||
| if (circ.c_buf && circ.c_len) | ||
arnopo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| circ.c_pos = circ.c_cnt = 0; | ||
|
|
||
| metal_init(&metal_param); | ||
|
|
||
| if (!kick_device.irq_info) { | ||
|
|
@@ -297,21 +354,6 @@ static void xlnx_machine_cleanup(void) | |
| Xil_ICacheInvalidate(); | ||
| } | ||
|
|
||
| void xlnx_log_handler(enum metal_log_level level, const char *format, ...) | ||
| { | ||
| char msg[1024]; | ||
| va_list args; | ||
|
|
||
| va_start(args, format); | ||
| vsnprintf(msg, sizeof(msg), format, args); | ||
| va_end(args); | ||
|
|
||
| if (level > metal_get_log_level()) | ||
| return; | ||
|
|
||
| xil_printf("RPU%d: %s", XPAR_CPU_ID, msg); | ||
| } | ||
|
|
||
| int platform_init(int argc, char *argv[], void **platform) | ||
| { | ||
| unsigned long proc_id = 0; | ||
|
|
||
This file contains hidden or 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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -37,9 +37,11 @@ | |||||
| #endif /* RING_RX */ | ||||||
| #define VRING_SIZE 256 | ||||||
|
|
||||||
| #define NUM_TABLE_ENTRIES 1 | ||||||
| #define NUM_TABLE_ENTRIES 2 | ||||||
| #define RSC_TRACE_SZ (4*1024) | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nitpicking. The trace contain char, why not just just
Suggested change
|
||||||
|
|
||||||
| static struct remote_resource_table *initial_resources; | ||||||
| static char rsc_trace_buf[RSC_TRACE_SZ]; | ||||||
|
|
||||||
| struct remote_resource_table __resource resources = { | ||||||
| /* Version */ | ||||||
|
|
@@ -51,19 +53,27 @@ struct remote_resource_table __resource resources = { | |||||
| {0, 0,}, | ||||||
|
|
||||||
| /* Offsets of rsc entries */ | ||||||
| { | ||||||
| offsetof(struct remote_resource_table, rpmsg_vdev), | ||||||
| }, | ||||||
| .offset[0] = offsetof(struct remote_resource_table, rpmsg_vdev), | ||||||
| .offset[1] = offsetof(struct remote_resource_table, rsc_trace), | ||||||
|
|
||||||
| /* Virtio device entry */ | ||||||
| { | ||||||
| RSC_VDEV, VIRTIO_ID_RPMSG_, 31, RPMSG_VDEV_DFEATURES, 0, 0, 0, | ||||||
| NUM_VRINGS, {0, 0}, | ||||||
| }, | ||||||
| .rpmsg_vdev = { | ||||||
| RSC_VDEV, VIRTIO_ID_RPMSG_, 31, RPMSG_VDEV_DFEATURES, 0, 0, 0, | ||||||
| NUM_VRINGS, {0, 0}, | ||||||
| }, | ||||||
|
|
||||||
| /* Vring rsc entry - part of vdev rsc entry */ | ||||||
| {RING_TX, VRING_ALIGN, VRING_SIZE, 1, 0}, | ||||||
| {RING_RX, VRING_ALIGN, VRING_SIZE, 2, 0}, | ||||||
|
|
||||||
| /* trace buffer for logs, accessible via debugfs */ | ||||||
| .rsc_trace = { | ||||||
| .type = RSC_TRACE, | ||||||
| .da = (uint32_t)rsc_trace_buf, | ||||||
| .len = sizeof(rsc_trace_buf), | ||||||
| .reserved = 0, | ||||||
| .name = "r5_trace", | ||||||
| }, | ||||||
| }; | ||||||
|
|
||||||
| struct remote_resource_table_metadata __resource_metadata resources_metadata = { | ||||||
|
|
@@ -74,6 +84,12 @@ struct remote_resource_table_metadata __resource_metadata resources_metadata = { | |||||
| .rsc_tbl = (uintptr_t)&resources | ||||||
| }; | ||||||
|
|
||||||
| char *get_rsc_trace_info(uint32_t *len) | ||||||
| { | ||||||
| *len = sizeof(rsc_trace_buf); | ||||||
| return rsc_trace_buf; | ||||||
| } | ||||||
|
|
||||||
| void *get_resource_table (int rsc_id, int *len) | ||||||
| { | ||||||
| (void) rsc_id; | ||||||
|
|
||||||
This file contains hidden or 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
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.
Uh oh!
There was an error while loading. Please reload this page.