+/*
+ * Static start-of-day Xen EL2 MPU memory region layout:
+ *
+ * xen_mpumap[0] : Xen text
+ * xen_mpumap[1] : Xen read-only data
+ * xen_mpumap[2] : Xen read-only after init data
+ * xen_mpumap[3] : Xen read-write data
+ * xen_mpumap[4] : Xen BSS
+ * xen_mpumap[5] : Xen init text
+ * xen_mpumap[6] : Xen init data
+ *
+ * Clobbers x0 - x6
+ *
+ * It shall be compliant with what describes in xen.lds.S, or the below
+ * codes need adjustment.
+ */
+ENTRY(prepare_early_mappings)
+ /* x0: region sel */
+ mov x0, xzr
+ /* Xen text section. */
+ load_paddr x1, _stext
+ load_paddr x2, _etext
+ prepare_xen_region x0, x1, x2, x3, x4, x5, x6,
attr_prbar=REGION_TEXT_PRBAR
+
+ add x0, x0, #1
+ /* Xen read-only data section. */
+ load_paddr x1, _srodata
+ load_paddr x2, _erodata
+ prepare_xen_region x0, x1, x2, x3, x4, x5, x6,
attr_prbar=REGION_RO_PRBAR
+
+ add x0, x0, #1
+ /* Xen read-only after init data section. */
+ load_paddr x1, __ro_after_init_start
+ load_paddr x2, __ro_after_init_end
+ prepare_xen_region x0, x1, x2, x3, x4, x5, x6
+
+ add x0, x0, #1
+ /* Xen read-write data section. */
+ load_paddr x1, __ro_after_init_end
+ load_paddr x2, __init_begin
+ prepare_xen_region x0, x1, x2, x3, x4, x5, x6
+
+ add x0, x0, #1
+ /* Xen BSS section. */
+ load_paddr x1, __bss_start
+ load_paddr x2, __bss_end
+ prepare_xen_region x0, x1, x2, x3, x4, x5, x6
+
+ add x0, x0, #1
+ /* Xen init text section. */
+ load_paddr x1, _sinittext
+ load_paddr x2, _einittext
+ prepare_xen_region x0, x1, x2, x3, x4, x5, x6,
attr_prbar=REGION_TEXT_PRBAR
+
+ add x0, x0, #1
+ /* Xen init data section. */
+ /*
+ * Even though we are not using alternative instructions in MPU yet,
+ * we want to use "_einitext" for the start of the "Init data"
section
+ * to make sure they are included.
+ */
+ load_paddr x1, _einittext
+ roundup_section x1
+ load_paddr x2, __init_end
+ prepare_xen_region x0, x1, x2, x3, x4, x5, x6
+
+ /* Ensure any MPU memory mapping table updates made above have
occurred. */
+ dsb nshst
+ ret
+ENDPROC(prepare_early_mappings)