Skip to content

Commit a8d8d13

Browse files
authored
Merge pull request #44 from arduino/rpc_fixes
RPC fixes
2 parents f29e7da + 5d34121 commit a8d8d13

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+10788
-6226
lines changed

Makefile

+4-2
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,13 @@ SIZE = $(CROSS_COMPILE)size
2222

2323
LINKER_SCRIPT = linker/STM32H747AIIX_FLASH.ld
2424

25-
CFLAGS = -O2 -Wall -Werror -pedantic -mcpu=cortex-m7 -mfpu=fpv5-d16 -mfloat-abi=hard -mthumb -std=gnu11 -g3 -ffunction-sections -fdata-sections -fstack-usage
25+
CFLAGS = -O2 -Wall -Werror -mcpu=cortex-m7 -mfpu=fpv5-d16 -mfloat-abi=hard -mthumb -std=gnu11 -g3 -ffunction-sections -fdata-sections -fstack-usage
2626
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
2727
ASFLAGS = -O2 -mcpu=cortex-m7 -mfpu=fpv5-d16 -mfloat-abi=hard -mthumb -c -x assembler-with-cpp -g3
2828
LDFLAGS = --specs=nosys.specs -Wl,--gc-sections -static --specs=nano.specs -T$(LINKER_SCRIPT) -Wl,--start-group -lc -lm -Wl,--end-group
2929

30+
CFLAGS += -Wno-variadic-macros -Wno-discarded-qualifiers
31+
3032
TAG_COMMIT := $(shell git rev-list --abbrev-commit --tags --max-count=1)
3133
TAG := $(shell git describe --abbrev=0 --tags ${TAG_COMMIT} 2>/dev/null || true)
3234
COMMIT := $(shell git rev-parse --short HEAD)
@@ -48,7 +50,7 @@ DEFINES = \
4850
-DSTM32H747xx \
4951
-DVECT_TAB_SRAM \
5052
-DMETAL_INTERNAL \
51-
-DVIRTIO_MASTER_ONLY \
53+
-DVIRTIO_DRIVER_ONLY \
5254
-DNO_ATOMIC_64_SUPPORT \
5355
-DMETAL_MAX_DEVICE_REGIONS=2 \
5456
-DRPMSG_BUFFER_SIZE=2000 \

include/debug.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,12 @@
2222
/**************************************************************************************
2323
* DEFINE
2424
**************************************************************************************/
25+
#include <stdio.h>
2526

2627
#ifdef DEBUG
2728
#define dbg_printf(...) printf(__VA_ARGS__)
2829
#else
29-
#define dbg_printf(...)
30+
#define dbg_printf(...) do {} while (0)
3031
#endif
3132

3233
#endif /* PORTENTAX8_STM32H7_FW_DEBUG_H */

libraries/openamp_arduino/library.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ sentence=Enables the communication between H747 cores via shared memory and open
66
paragraph=
77
category=Communication
88
url=
9-
architectures=mbed,mbed_portenta
9+
architectures=mbed,mbed_portenta,mbed_nicla,mbed_opta
1010
dot_a_linkage=true

libraries/openamp_arduino/src/device.c

+10-11
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
*/
66

77
#include <string.h>
8-
#include <metal/errno.h>
98
#include <metal/assert.h>
109
#include <metal/device.h>
10+
#include <metal/errno.h>
1111
#include <metal/list.h>
1212
#include <metal/log.h>
1313
#include <metal/sys.h>
@@ -43,11 +43,10 @@ int metal_bus_find(const char *name, struct metal_bus **result)
4343

4444
metal_list_for_each(&_metal.common.bus_list, node) {
4545
bus = metal_container_of(node, struct metal_bus, node);
46-
if (strcmp(bus->name, name) != 0)
47-
continue;
48-
if (result)
46+
if (strcmp(bus->name, name) == 0 && result) {
4947
*result = bus;
50-
return 0;
48+
return 0;
49+
}
5150
}
5251
return -ENOENT;
5352
}
@@ -106,10 +105,10 @@ int metal_generic_dev_open(struct metal_bus *bus, const char *dev_name,
106105

107106
metal_list_for_each(&_metal.common.generic_device_list, node) {
108107
dev = metal_container_of(node, struct metal_device, node);
109-
if (strcmp(dev->name, dev_name) != 0)
110-
continue;
111-
*device = dev;
112-
return metal_generic_dev_sys_open(dev);
108+
if (strcmp(dev->name, dev_name) == 0) {
109+
*device = dev;
110+
return metal_generic_dev_sys_open(dev);
111+
}
113112
}
114113

115114
return -ENODEV;
@@ -122,9 +121,9 @@ int metal_generic_dev_dma_map(struct metal_bus *bus,
122121
int nents_in,
123122
struct metal_sg *sg_out)
124123
{
124+
int i;
125125
(void)bus;
126126
(void)device;
127-
int i;
128127

129128
if (sg_out != sg_in)
130129
memcpy(sg_out, sg_in, nents_in*(sizeof(struct metal_sg)));
@@ -144,10 +143,10 @@ void metal_generic_dev_dma_unmap(struct metal_bus *bus,
144143
struct metal_sg *sg,
145144
int nents)
146145
{
146+
int i;
147147
(void)bus;
148148
(void)device;
149149
(void)dir;
150-
int i;
151150

152151
for (i = 0; i < nents; i++) {
153152
metal_cache_invalidate(sg[i].virt, sg[i].len);

libraries/openamp_arduino/src/dma.c

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
* Copyright (c) 2015, Xilinx Inc. and Contributors. All rights reserved.
3+
*
4+
* SPDX-License-Identifier: BSD-3-Clause
5+
*/
6+
7+
#include <metal/errno.h>
8+
#include <string.h>
9+
#include <metal/device.h>
10+
#include <metal/log.h>
11+
#include <metal/dma.h>
12+
#include <metal/atomic.h>
13+
14+
int metal_dma_map(struct metal_device *dev,
15+
uint32_t dir,
16+
struct metal_sg *sg_in,
17+
int nents_in,
18+
struct metal_sg *sg_out)
19+
{
20+
int nents_out;
21+
22+
if (!dev || !sg_in || !sg_out)
23+
return -EINVAL;
24+
if (!dev->bus->ops.dev_dma_map)
25+
return -ENODEV;
26+
27+
/* memory barrier */
28+
if (dir == METAL_DMA_DEV_R)
29+
/* If it is device read, apply memory write fence. */
30+
atomic_thread_fence(memory_order_release);
31+
else
32+
/* If it is device write or r/w, apply memory r/w fence. */
33+
atomic_thread_fence(memory_order_acq_rel);
34+
nents_out = dev->bus->ops.dev_dma_map(dev->bus,
35+
dev, dir, sg_in, nents_in, sg_out);
36+
return nents_out;
37+
}
38+
39+
void metal_dma_unmap(struct metal_device *dev,
40+
uint32_t dir,
41+
struct metal_sg *sg,
42+
int nents)
43+
{
44+
/* memory barrier */
45+
if (dir == METAL_DMA_DEV_R)
46+
/* If it is device read, apply memory write fence. */
47+
atomic_thread_fence(memory_order_release);
48+
else
49+
/*If it is device write or r/w, apply memory r/w fence */
50+
atomic_thread_fence(memory_order_acq_rel);
51+
52+
if (!dev || !dev->bus->ops.dev_dma_unmap || !sg)
53+
return;
54+
dev->bus->ops.dev_dma_unmap(dev->bus,
55+
dev, dir, sg, nents);
56+
}

0 commit comments

Comments
 (0)