Skip to content

RPC fixes #44

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

Merged
merged 8 commits into from
Jan 17, 2024
Merged
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
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@ SIZE = $(CROSS_COMPILE)size

LINKER_SCRIPT = linker/STM32H747AIIX_FLASH.ld

CFLAGS = -O2 -Wall -Werror -pedantic -mcpu=cortex-m7 -mfpu=fpv5-d16 -mfloat-abi=hard -mthumb -std=gnu11 -g3 -ffunction-sections -fdata-sections -fstack-usage
CFLAGS = -O2 -Wall -Werror -mcpu=cortex-m7 -mfpu=fpv5-d16 -mfloat-abi=hard -mthumb -std=gnu11 -g3 -ffunction-sections -fdata-sections -fstack-usage
CXXFLAGS = -O2 -Wall -Werror -pedantic -mcpu=cortex-m7 -mfpu=fpv5-d16 -mfloat-abi=hard -mthumb -std=c++11 -g3 -ffunction-sections -fdata-sections -fstack-usage
ASFLAGS = -O2 -mcpu=cortex-m7 -mfpu=fpv5-d16 -mfloat-abi=hard -mthumb -c -x assembler-with-cpp -g3
LDFLAGS = --specs=nosys.specs -Wl,--gc-sections -static --specs=nano.specs -T$(LINKER_SCRIPT) -Wl,--start-group -lc -lm -Wl,--end-group

CFLAGS += -Wno-variadic-macros -Wno-discarded-qualifiers

TAG_COMMIT := $(shell git rev-list --abbrev-commit --tags --max-count=1)
TAG := $(shell git describe --abbrev=0 --tags ${TAG_COMMIT} 2>/dev/null || true)
COMMIT := $(shell git rev-parse --short HEAD)
Expand All @@ -48,7 +50,7 @@ DEFINES = \
-DSTM32H747xx \
-DVECT_TAB_SRAM \
-DMETAL_INTERNAL \
-DVIRTIO_MASTER_ONLY \
-DVIRTIO_DRIVER_ONLY \
-DNO_ATOMIC_64_SUPPORT \
-DMETAL_MAX_DEVICE_REGIONS=2 \
-DRPMSG_BUFFER_SIZE=2000 \
Expand Down
3 changes: 2 additions & 1 deletion include/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@
/**************************************************************************************
* DEFINE
**************************************************************************************/
#include <stdio.h>

#ifdef DEBUG
#define dbg_printf(...) printf(__VA_ARGS__)
#else
#define dbg_printf(...)
#define dbg_printf(...) do {} while (0)
#endif

#endif /* PORTENTAX8_STM32H7_FW_DEBUG_H */
2 changes: 1 addition & 1 deletion libraries/openamp_arduino/library.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ sentence=Enables the communication between H747 cores via shared memory and open
paragraph=
category=Communication
url=
architectures=mbed,mbed_portenta
architectures=mbed,mbed_portenta,mbed_nicla,mbed_opta
dot_a_linkage=true
21 changes: 10 additions & 11 deletions libraries/openamp_arduino/src/device.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
*/

#include <string.h>
#include <metal/errno.h>
#include <metal/assert.h>
#include <metal/device.h>
#include <metal/errno.h>
#include <metal/list.h>
#include <metal/log.h>
#include <metal/sys.h>
Expand Down Expand Up @@ -43,11 +43,10 @@ int metal_bus_find(const char *name, struct metal_bus **result)

metal_list_for_each(&_metal.common.bus_list, node) {
bus = metal_container_of(node, struct metal_bus, node);
if (strcmp(bus->name, name) != 0)
continue;
if (result)
if (strcmp(bus->name, name) == 0 && result) {
*result = bus;
return 0;
return 0;
}
}
return -ENOENT;
}
Expand Down Expand Up @@ -106,10 +105,10 @@ int metal_generic_dev_open(struct metal_bus *bus, const char *dev_name,

metal_list_for_each(&_metal.common.generic_device_list, node) {
dev = metal_container_of(node, struct metal_device, node);
if (strcmp(dev->name, dev_name) != 0)
continue;
*device = dev;
return metal_generic_dev_sys_open(dev);
if (strcmp(dev->name, dev_name) == 0) {
*device = dev;
return metal_generic_dev_sys_open(dev);
}
}

return -ENODEV;
Expand All @@ -122,9 +121,9 @@ int metal_generic_dev_dma_map(struct metal_bus *bus,
int nents_in,
struct metal_sg *sg_out)
{
int i;
(void)bus;
(void)device;
int i;

if (sg_out != sg_in)
memcpy(sg_out, sg_in, nents_in*(sizeof(struct metal_sg)));
Expand All @@ -144,10 +143,10 @@ void metal_generic_dev_dma_unmap(struct metal_bus *bus,
struct metal_sg *sg,
int nents)
{
int i;
(void)bus;
(void)device;
(void)dir;
int i;

for (i = 0; i < nents; i++) {
metal_cache_invalidate(sg[i].virt, sg[i].len);
Expand Down
56 changes: 56 additions & 0 deletions libraries/openamp_arduino/src/dma.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* Copyright (c) 2015, Xilinx Inc. and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/

#include <metal/errno.h>
#include <string.h>
#include <metal/device.h>
#include <metal/log.h>
#include <metal/dma.h>
#include <metal/atomic.h>

int metal_dma_map(struct metal_device *dev,
uint32_t dir,
struct metal_sg *sg_in,
int nents_in,
struct metal_sg *sg_out)
{
int nents_out;

if (!dev || !sg_in || !sg_out)
return -EINVAL;
if (!dev->bus->ops.dev_dma_map)
return -ENODEV;

/* memory barrier */
if (dir == METAL_DMA_DEV_R)
/* If it is device read, apply memory write fence. */
atomic_thread_fence(memory_order_release);
else
/* If it is device write or r/w, apply memory r/w fence. */
atomic_thread_fence(memory_order_acq_rel);
nents_out = dev->bus->ops.dev_dma_map(dev->bus,
dev, dir, sg_in, nents_in, sg_out);
return nents_out;
}

void metal_dma_unmap(struct metal_device *dev,
uint32_t dir,
struct metal_sg *sg,
int nents)
{
/* memory barrier */
if (dir == METAL_DMA_DEV_R)
/* If it is device read, apply memory write fence. */
atomic_thread_fence(memory_order_release);
else
/*If it is device write or r/w, apply memory r/w fence */
atomic_thread_fence(memory_order_acq_rel);

if (!dev || !dev->bus->ops.dev_dma_unmap || !sg)
return;
dev->bus->ops.dev_dma_unmap(dev->bus,
dev, dir, sg, nents);
}
Loading