summaryrefslogtreecommitdiffstats
path: root/bsps/arm/atsam/start/iocopy.c
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2018-04-22 15:11:43 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2018-04-23 15:18:42 +0200
commit54aabb70eb9ad64d3bcb9f95968de6a4473ebe3b (patch)
treeb331279d24731b596df743fb7752d67bc30f3545 /bsps/arm/atsam/start/iocopy.c
parentbsp/altera-cyclone-v: Move hwlib to bsps (diff)
downloadrtems-54aabb70eb9ad64d3bcb9f95968de6a4473ebe3b.tar.bz2
bsp/atsam: Move libraries to bsps
This patch is a part of the BSP source reorganization. Update #3285.
Diffstat (limited to 'bsps/arm/atsam/start/iocopy.c')
-rw-r--r--bsps/arm/atsam/start/iocopy.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/bsps/arm/atsam/start/iocopy.c b/bsps/arm/atsam/start/iocopy.c
new file mode 100644
index 0000000000..b91282dac6
--- /dev/null
+++ b/bsps/arm/atsam/start/iocopy.c
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2018 embedded brains GmbH. All rights reserved.
+ *
+ * embedded brains GmbH
+ * Dornierstr. 4
+ * 82178 Puchheim
+ * Germany
+ * <rtems@embedded-brains.de>
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.org/license/LICENSE.
+ */
+
+#include <bsp/iocopy.h>
+
+static void atsam_do_copy(
+ uint8_t *dst,
+ const uint8_t *src,
+ size_t n,
+ bool aligned
+)
+{
+ if (aligned) {
+ while (n > 3) {
+ *(uint32_t *)dst = *(uint32_t *)src;
+ dst += 4;
+ src += 4;
+ n -= 4;
+ }
+ }
+
+ while (n > 0) {
+ *dst = *src;
+ ++dst;
+ ++src;
+ --n;
+ }
+}
+
+void atsam_copy_to_io(void *dst, const void *src, size_t n)
+{
+ atsam_do_copy(dst, src, n, ((uintptr_t)dst) % 4 == 0);
+}
+
+void atsam_copy_from_io(void *dst, const void *src, size_t n)
+{
+ atsam_do_copy(dst, src, n, ((uintptr_t)src) % 4 == 0);
+}