Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/legacy_apps/examples/echo/freertos/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include <metal/version.h>
#include <openamp/open_amp.h>
#include <openamp/version.h>
#include "platform_info.h"
#include "platform_info_common.h"
#include "rpmsg-echo.h"
#include <stdio.h>
#include "task.h"
Expand Down
2 changes: 1 addition & 1 deletion examples/legacy_apps/examples/echo/generic/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <metal/version.h>
#include <openamp/open_amp.h>
#include <openamp/version.h>
#include "platform_info.h"
#include "platform_info_common.h"
#include "rpmsg-echo.h"
#include <stdio.h>

Expand Down
2 changes: 1 addition & 1 deletion examples/legacy_apps/examples/echo/rpmsg-echo.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include <openamp/version.h>
#include <metal/alloc.h>
#include <metal/version.h>
#include "platform_info.h"
#include "platform_info_common.h"
#include "rpmsg-echo.h"

#define SHUTDOWN_MSG 0xEF56A55A
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#ifndef MATRIX_MULTIPLY_H
#define MATRIX_MULTIPLY_H

#include <openamp/rpmsg.h>

#define RPMSG_SERVICE_NAME "rpmsg-openamp-demo-channel"

int rpmsg_matrix_app(struct rpmsg_device *rdev, void *priv);
Expand Down
5 changes: 5 additions & 0 deletions examples/legacy_apps/machine/xlnx/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ cmake_minimum_required(VERSION 3.24)

enable_language(C ASM )

if (NOT DEFINED ${OPENAMP_APP_NAME})
add_subdirectory(${MACHINE})
return()
endif(NOT DEFINED ${OPENAMP_APP_NAME})

set_property (GLOBAL PROPERTY OPENAMP_APP_NAME "${OPENAMP_APP_NAME}")
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/")

Expand Down
2 changes: 1 addition & 1 deletion examples/legacy_apps/machine/xlnx/zynqmp_r5/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ endif(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_SYSTEM}/gic_init.c")

# If not provided, add default value for resource table
if(NOT DEFINED ${RSC_TABLE})
set(RSC_TABLE 0x3ed00000 CACHE STRING "")
set(RSC_TABLE 0x9800000 CACHE STRING "")
endif(NOT DEFINED ${RSC_TABLE})

set (_linker_script "${CMAKE_CURRENT_SOURCE_DIR}/linker_remote.ld")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ _UNDEF_STACK_SIZE = DEFINED(_UNDEF_STACK_SIZE) ? _UNDEF_STACK_SIZE : 1024;
/* TCM size is set to 2*0x20000 for R5 in lockstep mode */
MEMORY
{
psu_ddr_S_AXI_BASEADDR : ORIGIN = 0x3ED00000, LENGTH = 0x00040000
psu_ddr_S_AXI_BASEADDR : ORIGIN = 0x9800000, LENGTH = 0x00060000
psu_ocm_ram_1_S_AXI_BASEADDR : ORIGIN = 0xFFFF0000, LENGTH = 0x10000
psu_r5_tcm_ram_0_S_AXI_BASEADDR : ORIGIN = 0x00000, LENGTH = 0x10000
psu_r5_tcm_ram_1_S_AXI_BASEADDR : ORIGIN = 0x20000, LENGTH = 0x10000
Expand Down Expand Up @@ -275,7 +275,7 @@ _SDA2_BASE_ = __sdata2_start + ((__sbss2_end - __sdata2_start) / 2 );
. += _HEAP_SIZE;
_heap_end = .;
HeapLimit = .;
} > psu_r5_tcm_ram_0_S_AXI_BASEADDR
} > psu_ddr_S_AXI_BASEADDR

.stack (NOLOAD) : {
. = ALIGN(16);
Expand Down
4 changes: 2 additions & 2 deletions examples/legacy_apps/machine/xlnx/zynqmp_r5/linker_remote.ld
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ _UNDEF_STACK_SIZE = DEFINED(_UNDEF_STACK_SIZE) ? _UNDEF_STACK_SIZE : 1024;
/* TCM size is set to 2*0x20000 for R5 in lockstep mode */
MEMORY
{
psu_ddr_S_AXI_BASEADDR : ORIGIN = 0x3ED00000, LENGTH = 0x00040000
psu_ddr_S_AXI_BASEADDR : ORIGIN = 0x9800000, LENGTH = 0x00060000
psu_ocm_ram_1_S_AXI_BASEADDR : ORIGIN = 0xFFFF0000, LENGTH = 0x10000
psu_r5_tcm_ram_0_S_AXI_BASEADDR : ORIGIN = 0x00000, LENGTH = 0x10000
psu_r5_tcm_ram_1_S_AXI_BASEADDR : ORIGIN = 0x20000, LENGTH = 0x10000
Expand Down Expand Up @@ -275,7 +275,7 @@ _SDA2_BASE_ = __sdata2_start + ((__sbss2_end - __sdata2_start) / 2 );
. += _HEAP_SIZE;
_heap_end = .;
HeapLimit = .;
} > psu_r5_tcm_ram_0_S_AXI_BASEADDR
} > psu_ddr_S_AXI_BASEADDR

.stack (NOLOAD) : {
. = ALIGN(16);
Expand Down
80 changes: 62 additions & 18 deletions examples/legacy_apps/machine/xlnx/zynqmp_r5/platform_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

Expand All @@ -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 \
{ \
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -248,12 +263,56 @@ 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, ...)
{
char msg[128];
char *p;
int32_t len = 0;
va_list args;

if (level > METAL_LOG_DEBUG)
level = METAL_LOG_EMERGENCY;

static const char * const level_strs[] = {
"emergency",
"alert",
"critical",
"error",
"warning",
"notice",
"info",
"debug",
};

len = sprintf(msg, "%s: ", level_strs[level]);

if (len < 0 || len > (int32_t)sizeof(msg))
len = 0;
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)
circ.c_pos = circ.c_cnt = 0;

metal_init(&metal_param);

if (!kick_device.irq_info) {
Expand Down Expand Up @@ -297,21 +356,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;
Expand Down
32 changes: 24 additions & 8 deletions examples/legacy_apps/machine/xlnx/zynqmp_r5/rsc_table.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)

static struct remote_resource_table *initial_resources;
static char rsc_trace_buf[RSC_TRACE_SZ];

struct remote_resource_table __resource resources = {
/* Version */
Expand All @@ -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 = {
Expand All @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions examples/legacy_apps/machine/xlnx/zynqmp_r5/rsc_table.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ struct remote_resource_table {
struct fw_rsc_vdev rpmsg_vdev;
struct fw_rsc_vdev_vring rpmsg_vring0;
struct fw_rsc_vdev_vring rpmsg_vring1;
struct fw_rsc_trace rsc_trace;
}__attribute__((packed, aligned(0x100)));

struct remote_resource_table_metadata {
Expand All @@ -44,6 +45,7 @@ struct remote_resource_table_metadata {
const uintptr_t rsc_tbl;
}__attribute__((packed));

char *get_rsc_trace_info(uint32_t *len);
void *get_resource_table (int rsc_id, int *len);
void free_resource_table (void);
void restore_initial_rsc_table (void);
Expand Down