ext: libmetal: Update libmetal to v2018.10 release

Since there's an official release lets update to it.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
This commit is contained in:
Kumar Gala 2018-11-09 13:06:50 -06:00 committed by Kumar Gala
parent 73f7e81d21
commit d60dfdf481
5 changed files with 52 additions and 6 deletions

View File

@ -39,7 +39,7 @@ unsigned int sys_irq_save_disable(void)
void metal_machine_cache_flush(void *addr, unsigned int len)
{
if (!addr & !len)
if (!addr && !len)
Xil_DCacheFlush();
else
Xil_DCacheFlushRange((intptr_t)addr, len);
@ -47,7 +47,7 @@ void metal_machine_cache_flush(void *addr, unsigned int len)
void metal_machine_cache_invalidate(void *addr, unsigned int len)
{
if (!addr & !len)
if (!addr && !len)
Xil_DCacheInvalidate();
else
Xil_DCacheInvalidateRange((intptr_t)addr, len);

View File

@ -39,7 +39,7 @@ unsigned int sys_irq_save_disable(void)
void metal_machine_cache_flush(void *addr, unsigned int len)
{
if (!addr & !len)
if (!addr && !len)
Xil_DCacheFlush();
else
Xil_DCacheFlushRange((intptr_t)addr, len);
@ -47,7 +47,7 @@ void metal_machine_cache_flush(void *addr, unsigned int len)
void metal_machine_cache_invalidate(void *addr, unsigned int len)
{
if (!addr & !len)
if (!addr && !len)
Xil_DCacheInvalidate();
else
Xil_DCacheInvalidateRange((intptr_t)addr, len);

View File

@ -102,7 +102,7 @@ static int metal_uio_dev_bind(struct linux_device *ldev,
return 0;
if (strcmp(ldev->sdev->driver_name, SYSFS_UNKNOWN) != 0) {
metal_log(METAL_LOG_ERROR, "device %s in use by driver %s\n",
metal_log(METAL_LOG_INFO, "device %s in use by driver %s\n",
ldev->dev_name, ldev->sdev->driver_name);
return -EBUSY;
}
@ -368,6 +368,16 @@ static struct linux_bus linux_bus[] = {
.dev_dma_map = metal_uio_dev_dma_map,
.dev_dma_unmap = metal_uio_dev_dma_unmap,
},
{
.drv_name = "uio_dmem_genirq",
.mod_name = "uio_dmem_genirq",
.cls_name = "uio",
.dev_open = metal_uio_dev_open,
.dev_close = metal_uio_dev_close,
.dev_irq_ack = metal_uio_dev_irq_ack,
.dev_dma_map = metal_uio_dev_dma_map,
.dev_dma_unmap = metal_uio_dev_dma_unmap,
},
{ 0 /* sentinel */ }
}
},
@ -636,3 +646,24 @@ int metal_generic_dev_sys_open(struct metal_device *dev)
return 0;
}
int metal_linux_get_device_property(struct metal_device *device,
const char *property_name,
void *output, int len)
{
int fd = 0;
int status = 0;
const int flags = O_RDONLY;
const int mode = S_IRUSR | S_IRGRP | S_IROTH;
struct linux_device *ldev = to_linux_device(device);
char path[PATH_MAX];
snprintf(path, sizeof(path), "%s/of_node/%s",
ldev->sdev->path, property_name);
fd = open(path, flags, mode);
if (fd < 0)
return -errno;
status = read(fd, output, len);
return status < 0 ? -errno : 0;
}

View File

@ -135,7 +135,7 @@ int metal_sys_init(const struct metal_init_params *params)
strerror(errno));
return -errno;
}
if (sizeof(int) != fread(&seed, sizeof(int), 1, urandom)) {
if (fread(&seed, 1, sizeof(seed), urandom) <= 0) {
metal_log(METAL_LOG_DEBUG, "Failed fread /dev/urandom\n");
}
fclose(urandom);

View File

@ -46,6 +46,8 @@ extern "C" {
#define METAL_INVALID_VADDR NULL
#define MAX_PAGE_SIZES 32
struct metal_device;
/** Structure of shared page or hugepage sized data. */
struct metal_page_size {
/** Page size. */
@ -111,6 +113,19 @@ extern void metal_mktemp_template(char template[PATH_MAX],
const char *name);
extern int metal_virt2phys(void *addr, unsigned long *phys);
/**
* @brief Read a device tree property of a device
*
* @param[in] device metal_device of the intended DT node
* @param[in] property_name name of the property to be read
* @param[out] output output buffer to store read data
* @param[in] len number of bytes to be read
* @return 0 on success, or -errno on error.
*/
extern int metal_linux_get_device_property(struct metal_device *device,
const char *property_name,
void *output, int len);
#define metal_for_each_page_size_up(ps) \
for ((ps) = &_metal.page_sizes[0]; \
(ps) <= &_metal.page_sizes[_metal.num_page_sizes - 1]; \