TF-RMM Release v0.1.0
This is the first external release of TF-RMM and provides a reference
implementation of Realm Management Monitor (RMM) as specified by the
RMM Beta0 specification[1].
The `docs/readme.rst` has more details about the project and
`docs/getting_started/getting-started.rst` has details on how to get
started with TF-RMM.
[1] https://developer.arm.com/documentation/den0137/1-0bet0/?lang=en
Signed-off-by: Soby Mathew <soby.mathew@arm.com>
Change-Id: I205ef14c015e4a37ae9ae1a64e4cd22eb8da746e
diff --git a/lib/common/include/bitmap.h b/lib/common/include/bitmap.h
new file mode 100644
index 0000000..0b93e25
--- /dev/null
+++ b/lib/common/include/bitmap.h
@@ -0,0 +1,33 @@
+/*
+ * SPDX-License-Identifier: BSD-3-Clause
+ * SPDX-FileCopyrightText: Copyright TF-RMM Contributors.
+ */
+
+#ifndef BITMAP_H
+#define BITMAP_H
+
+#include <sizes.h>
+
+/*
+ * Returns the index of the first bit set in @bitmap from @start inclusive.
+ * The index is zero-based from LSB (0) to MSB (63).
+ * When no such bits are set, returns BITS_PER_UL (64).
+ */
+static inline unsigned long bitmap_find_next_set_bit(unsigned long bitmap,
+ unsigned long start)
+{
+ if (start < BITS_PER_UL) {
+ bitmap &= ~0UL << start;
+ if (bitmap != 0UL) {
+ return (unsigned long)(__builtin_ffsl(bitmap) - 1);
+ }
+ }
+ return BITS_PER_UL;
+}
+
+#define bitmap_for_each_set_bit(_bit, _bitmap, _max) \
+ for ((_bit) = find_next_set_bit((_bitmap), 0); \
+ (_bit) < (_max); \
+ (_bit) = find_next_set_bit((_bitmap), (_bit) + 1))
+
+#endif /* BITMAP_H */