summaryrefslogtreecommitdiffstats
path: root/tools/bus_space/C
diff options
context:
space:
mode:
Diffstat (limited to 'tools/bus_space/C')
-rw-r--r--tools/bus_space/C/Makefile1
-rw-r--r--tools/bus_space/C/lang.c43
-rw-r--r--tools/bus_space/C/libbus_space.h32
3 files changed, 65 insertions, 11 deletions
diff --git a/tools/bus_space/C/Makefile b/tools/bus_space/C/Makefile
index 9d767e8..cb4d43f 100644
--- a/tools/bus_space/C/Makefile
+++ b/tools/bus_space/C/Makefile
@@ -3,6 +3,7 @@
LIB= bus_space
SHLIB_MAJOR= 0
SRCS= lang.c
+INCS= libbus_space.h
CFLAGS+= -I${.CURDIR}/..
diff --git a/tools/bus_space/C/lang.c b/tools/bus_space/C/lang.c
index 6408343..84fd780 100644
--- a/tools/bus_space/C/lang.c
+++ b/tools/bus_space/C/lang.c
@@ -31,9 +31,10 @@ __FBSDID("$FreeBSD$");
#include <errno.h>
#include "bus_space.h"
+#include "busdma.h"
#include "libbus_space.h"
-int
+int16_t
bus_space_read_1(int rid, long ofs)
{
uint8_t val;
@@ -41,7 +42,7 @@ bus_space_read_1(int rid, long ofs)
return ((!bs_read(rid, ofs, &val, sizeof(val))) ? -1 : (int)val);
}
-int
+int32_t
bus_space_read_2(int rid, long ofs)
{
uint16_t val;
@@ -98,3 +99,41 @@ bus_space_subregion(int rid, long ofs, long sz)
return (bs_subregion(rid, ofs, sz));
}
+
+int
+busdma_tag_create(const char *dev, bus_addr_t align, bus_addr_t bndry,
+ bus_addr_t maxaddr, bus_size_t maxsz, u_int nsegs, bus_size_t maxsegsz,
+ u_int datarate, u_int flags, busdma_tag_t *out_p)
+{
+ int res;
+
+ res = bd_tag_create(dev, align, bndry, maxaddr, maxsz, nsegs, maxsegsz,
+ datarate, flags);
+ if (res == -1)
+ return (errno);
+ *out_p = res;
+ return (0);
+}
+
+int
+busdma_tag_derive(busdma_tag_t tag, bus_addr_t align, bus_addr_t bndry,
+ bus_addr_t maxaddr, bus_size_t maxsz, u_int nsegs, bus_size_t maxsegsz,
+ u_int datarate, u_int flags, busdma_tag_t *out_p)
+{
+ int res;
+
+ res = bd_tag_derive(tag, align, bndry, maxaddr, maxsz, nsegs, maxsegsz,
+ datarate, flags);
+ if (res == -1)
+ return (errno);
+ *out_p = res;
+ return (0);
+}
+
+int
+busdma_tag_destroy(busdma_tag_t tag)
+{
+
+ return (bd_tag_destroy(tag));
+}
+
diff --git a/tools/bus_space/C/libbus_space.h b/tools/bus_space/C/libbus_space.h
index 3e8860f..c7ff06c 100644
--- a/tools/bus_space/C/libbus_space.h
+++ b/tools/bus_space/C/libbus_space.h
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 2014 Marcel Moolenaar
+ * Copyright (c) 2014, 2015 Marcel Moolenaar
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -29,14 +29,28 @@
#ifndef _LIBBUS_SPACE_H_
#define _LIBBUS_SPACE_H_
-int bus_space_map(const char *dev);
-int bus_space_read_1(int rid, long ofs);
-int bus_space_read_2(int rid, long ofs);
+int bus_space_map(const char *dev);
+int16_t bus_space_read_1(int rid, long ofs);
+int32_t bus_space_read_2(int rid, long ofs);
int64_t bus_space_read_4(int rid, long ofs);
-int bus_space_subregion(int rid, long ofs, long sz);
-int bus_space_unmap(int rid);
-int bus_space_write_1(int rid, long ofs, uint8_t val);
-int bus_space_write_2(int rid, long ofs, uint16_t val);
-int bus_space_write_4(int rid, long ofs, uint32_t val);
+int bus_space_subregion(int rid, long ofs, long sz);
+int bus_space_unmap(int rid);
+int bus_space_write_1(int rid, long ofs, uint8_t val);
+int bus_space_write_2(int rid, long ofs, uint16_t val);
+int bus_space_write_4(int rid, long ofs, uint32_t val);
+
+typedef unsigned long bus_addr_t;
+typedef unsigned long bus_size_t;
+typedef int busdma_tag_t;
+
+int busdma_tag_create(const char *dev, bus_addr_t align, bus_addr_t bndry,
+ bus_addr_t maxaddr, bus_size_t maxsz, u_int nsegs,
+ bus_size_t maxsegsz, u_int datarate, u_int flags,
+ busdma_tag_t *out_p);
+int busdma_tag_derive(busdma_tag_t tag, bus_addr_t align, bus_addr_t bndry,
+ bus_addr_t maxaddr, bus_size_t maxsz, u_int nsegs,
+ bus_size_t maxsegsz, u_int datarate, u_int flags,
+ busdma_tag_t *out_p);
+int busdma_tag_destroy(busdma_tag_t tag);
#endif /* _LIBBUS_SPACE_H_ */
OpenPOWER on IntegriCloud