[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC PATCH v2 05/23] hw: add register access utility functions
From: |
Octavian Purdila |
Subject: |
[RFC PATCH v2 05/23] hw: add register access utility functions |
Date: |
Sat, 17 Aug 2024 03:25:48 -0700 |
Add register access utility functions for device models, like checking
aligned access.
Signed-off-by: Octavian Purdila <tavip@google.com>
---
include/hw/regs.h | 34 ++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
create mode 100644 include/hw/regs.h
diff --git a/include/hw/regs.h b/include/hw/regs.h
new file mode 100644
index 0000000000..692428af12
--- /dev/null
+++ b/include/hw/regs.h
@@ -0,0 +1,34 @@
+/*
+ * Useful macros/functions for register handling.
+ *
+ * Copyright (c) 2021 Google LLC
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#ifndef HW_REGS_H
+#define HW_REGS_H
+
+#include "exec/hwaddr.h"
+
+/*
+ * reg32_aligned_access
+ * @addr: address to check
+ * @size: size of access
+ *
+ * Check if access to a hardware address is 32bit aligned.
+ *
+ * Returns: true if access is 32bit aligned, false otherwise
+ */
+static inline bool reg32_aligned_access(hwaddr addr, unsigned size)
+{
+ if (size != 4 || addr % 4 != 0) {
+ return false;
+ }
+ return true;
+}
+
+#endif /* HW_REGS_H */
--
2.46.0.184.g6999bdac58-goog
- [RFC PATCH v2 00/23] NXP i.MX RT595, ARM SVD and device model unit tests, Octavian Purdila, 2024/08/17
- [RFC PATCH v2 02/23] tests/unit: add fifo test, Octavian Purdila, 2024/08/17
- [RFC PATCH v2 01/23] fifo32: add peek function, Octavian Purdila, 2024/08/17
- [RFC PATCH v2 05/23] hw: add register access utility functions,
Octavian Purdila <=
- [RFC PATCH v2 03/23] scripts: add script to generate C header files from SVD XML files, Octavian Purdila, 2024/08/17
- [RFC PATCH v2 10/23] hw/char: add support for flexcomm usart, Octavian Purdila, 2024/08/17
- [RFC PATCH v2 04/23] Add mcux-soc-svd subproject, Octavian Purdila, 2024/08/17
- [RFC PATCH v2 13/23] test/unit: add i2c-tester, Octavian Purdila, 2024/08/17
- [RFC PATCH v2 09/23] test/unit: add flexcomm unit test, Octavian Purdila, 2024/08/17
- [RFC PATCH v2 11/23] test/unit: add flexcomm usart unit test, Octavian Purdila, 2024/08/17
- [RFC PATCH v2 06/23] hw/misc: add basic flexcomm device model, Octavian Purdila, 2024/08/17
- [RFC PATCH v2 08/23] test/unit: add register access macros and functions, Octavian Purdila, 2024/08/17
- [RFC PATCH v2 07/23] tests/unit: add system bus mock, Octavian Purdila, 2024/08/17
- [RFC PATCH v2 16/23] test/unit: add spi-tester, Octavian Purdila, 2024/08/17