#include <sbi/sbi_scratch.h>
#include <sbi/sbi_version.h>
-struct sbi_domain;
+struct sbi_domain_memregion;
struct sbi_trap_info;
struct sbi_trap_regs;
*/
int (*misa_get_xlen)(void);
+ /** Get platform specific root domain memory regions */
+ struct sbi_domain_memregion *(*domains_root_regions)(void);
/** Initialize (or populate) domains for the platform */
int (*domains_init)(void);
}
/**
+ * Get platform specific root domain memory regions
+ *
+ * @param plat pointer to struct sbi_platform
+ *
+ * @return an array of memory regions terminated by a region with order zero
+ * or NULL for no memory regions
+ */
+static inline struct sbi_domain_memregion *
+sbi_platform_domains_root_regions(const struct sbi_platform *plat)
+{
+ if (plat && sbi_platform_ops(plat)->domains_root_regions)
+ return sbi_platform_ops(plat)->domains_root_regions();
+ return NULL;
+}
+
+/**
* Initialize (or populate) domains for the platform
*
* @param plat pointer to struct sbi_platform
int sbi_domain_init(struct sbi_scratch *scratch, u32 cold_hartid)
{
u32 i;
+ struct sbi_domain_memregion *memregs;
const struct sbi_platform *plat = sbi_platform_ptr(scratch);
/* Root domain firmware memory region */
/* Root domain memory region end */
root_memregs[ROOT_END_REGION].order = 0;
+ /* Use platform specific root memory regions when available */
+ memregs = sbi_platform_domains_root_regions(plat);
+ if (memregs)
+ root.regions = memregs;
+
/* Root domain boot HART id is same as coldboot HART id */
root.boot_hartid = cold_hartid;
root.next_addr = scratch->next_addr;
root.next_mode = scratch->next_mode;
- /* Select root domain for all valid HARTs */
+ /* Root domain possible and assigned HARTs */
for (i = 0; i < SBI_HARTMASK_MAX_BITS; i++) {
if (sbi_platform_hart_invalid(plat, i))
continue;
sbi_hartmask_set_hart(i, &root_hmask);
- hartid_to_domain_table[i] = &root;
- sbi_hartmask_set_hart(i, &root.assigned_harts);
}
- /* Set root domain index */
- root.index = domain_count++;
- domidx_to_domain_table[root.index] = &root;
-
- return 0;
+ return sbi_domain_register(&root, &root_hmask);
}