Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 3be4bc0

Browse files
committedDec 27, 2023
Update libmetal to version v2023.10.0 - 1.5.0.
Signed-off-by: iabdalkader <[email protected]>
1 parent c2ad368 commit 3be4bc0

Some content is hidden

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

41 files changed

+2630
-2287
lines changed
 

‎libraries/openamp_arduino/src/device.c

Lines changed: 10 additions & 11 deletions
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

Lines changed: 56 additions & 0 deletions
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)
Please sign in to comment.