feat(manifest): disallow overlap with `load-address`

Disallow overlaps between memory regions and `load-address`, unless the
memory region is relative.

Change-Id: I78a788925f97bdc056711b21371d63d8b8eb32d8
Signed-off-by: Karl Meakin <karl.meakin@arm.com>
diff --git a/inc/hf/boot_params.h b/inc/hf/boot_params.h
index 56f2bd8..02a9b4b 100644
--- a/inc/hf/boot_params.h
+++ b/inc/hf/boot_params.h
@@ -8,22 +8,11 @@
 
 #pragma once
 
-#include <stdbool.h>
-
-#include "hf/arch/cpu.h"
-
-#include "hf/fdt.h"
-#include "hf/mm.h"
-#include "hf/mpool.h"
+#include "hf/mem_range.h"
 
 #define MAX_MEM_RANGES 20
 #define MAX_DEVICE_MEM_RANGES 10
 
-struct mem_range {
-	paddr_t begin;
-	paddr_t end;
-};
-
 struct boot_params {
 	cpu_id_t cpu_ids[MAX_CPUS];
 	size_t cpu_count;
diff --git a/inc/hf/ffa_partition_manifest.h b/inc/hf/ffa_partition_manifest.h
index 011ccd4..5005d8c 100644
--- a/inc/hf/ffa_partition_manifest.h
+++ b/inc/hf/ffa_partition_manifest.h
@@ -84,6 +84,8 @@
 	 * for S-EL1 partitions - optional.
 	 */
 	uintptr_t base_address;
+	/** True if `load-address-relative-offset` was specified. */
+	bool is_relative;
 	/** Page count - mandatory */
 	uint32_t page_count;
 	/** Memory attributes - mandatory */
diff --git a/inc/hf/mem_range.h b/inc/hf/mem_range.h
new file mode 100644
index 0000000..27e2461
--- /dev/null
+++ b/inc/hf/mem_range.h
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2024 The Hafnium Authors.
+ *
+ * Use of this source code is governed by a BSD-style
+ * license that can be found in the LICENSE file or at
+ * https://opensource.org/licenses/BSD-3-Clause.
+ */
+
+#pragma once
+
+#include "hf/addr.h"
+#include "hf/mm.h"
+
+struct mem_range {
+	paddr_t begin;
+	paddr_t end;
+};
+
+static inline struct mem_range make_mem_range(uintptr_t base_address,
+					      uint32_t page_count)
+{
+	return (struct mem_range){
+		.begin = pa_init(base_address),
+		.end = pa_init(base_address + page_count * PAGE_SIZE - 1),
+	};
+}