Skip to content

Update libmetal and Open-AMP to v2023.10.0 - 1.5.0 #803

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 3 commits into from
Jan 12, 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
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