summaryrefslogtreecommitdiffstats
path: root/memory_devmem2.c
diff options
context:
space:
mode:
authorDenis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>2021-06-09 17:50:21 +0200
committerDenis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>2021-06-09 17:54:11 +0200
commit9890249a384db95450f3f1511ee39aaa766f04f4 (patch)
tree7de7d5ad0cad73227b1f834d452c9c5a086c74f4 /memory_devmem2.c
parent2214b529ca9f57d7bc9d81c78a701b7109b8e69f (diff)
downloadexynos-gpio-tool-9890249a384db95450f3f1511ee39aaa766f04f4.tar.gz
exynos-gpio-tool-9890249a384db95450f3f1511ee39aaa766f04f4.tar.bz2
exynos-gpio-tool-9890249a384db95450f3f1511ee39aaa766f04f4.zip
Add devmem2 backend
Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
Diffstat (limited to 'memory_devmem2.c')
-rw-r--r--memory_devmem2.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/memory_devmem2.c b/memory_devmem2.c
new file mode 100644
index 0000000..ac25fc2
--- /dev/null
+++ b/memory_devmem2.c
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2021 Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+#include <assert.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <sys/mman.h>
+#include <sys/stat.h>
+
+#include "devmem2.h"
+#include "memory.h"
+
+int init_memory_mapping(int debug, struct memory_mapping **memory_mapping_pp)
+{
+ return 0;
+}
+
+int read_word(int debug, struct memory_mapping *memory_mapping,
+ off_t addr, unsigned long *result)
+{
+ int rc;
+
+ rc = devmem2(debug, addr, 'w', result, NULL);
+ if (rc)
+ printf("%s: devmem2 failed with error %d\n", __func__, rc);
+
+ return rc;
+}