feat(lib/realm): modify struct granule
This patch makes the following changes:
- val of spinlock_t type changes from unsigned int
to unsigned char;
- 'enum granule_state' removed and replaced with
macro definitions;
- type of 'struct granule' state changed to unsigned char;
- type of 'struct granule' refcount changed from unsigned long
to unsigned short, as its maximum value cannot exceed 512.
- 'refcount' access functions modified to use 16-bit values.
These modifications change the size of 'struct granule' from
16 to 4 bytes and reduce the total size of 'granules[]'
array from 16MB to 4MB for default RMM_MAX_GRANULES = 0x100000.
Change-Id: I611ed3f349806b033e03c52c5f60a0f903f93e11
Signed-off-by: AlexeiFedorov <Alexei.Fedorov@arm.com>
diff --git a/lib/arch/include/fake_host/memory.h b/lib/arch/include/fake_host/memory.h
index 3f182a4..645f5d2 100644
--- a/lib/arch/include/fake_host/memory.h
+++ b/lib/arch/include/fake_host/memory.h
@@ -37,4 +37,19 @@
}
#define SCA_READ64_ACQUIRE(_p) ((typeof(*(_p)))__sca_read64_acquire((uint64_t *)(_p)))
+/* Single-Copy Atomic 16-bit read */
+static inline uint16_t __sca_read16(uint16_t *ptr)
+{
+ return *ptr;
+}
+#define SCA_READ16(_p) ((typeof(*(_p)))__sca_read16((uint16_t *)(_p)))
+
+/* Single-Copy Atomic 16-bit read with ACQUIRE memory ordering semantics */
+static inline uint16_t __sca_read16_acquire(uint16_t *ptr)
+{
+ return *ptr;
+}
+#define SCA_READ16_ACQUIRE(_p) ((typeof(*(_p)))__sca_read16_acquire((uint16_t *)(_p)))
+
+
#endif /* MEMORY_H */