diff --git a/configs/arm64/imx8mp-inmate-demo.c
b/configs/arm64/imx8mp-inmate-demo.c
index 127392df..169177ad 100644
--- a/configs/arm64/imx8mp-inmate-demo.c
+++ b/configs/arm64/imx8mp-inmate-demo.c
@@ -1,126 +1,55 @@
/*
- * iMX8MM target - inmate-demo
+ * iMX8MP target - inmate-demo
*
- * Copyright 2020 NXP
+ * Copyright 2020-2021 NXP
*
* Authors:
* Peng Fan <[email protected]>
+ * Stephane Viau <[email protected]>
*
* This work is licensed under the terms of the GNU GPL, version 2. See
* the COPYING file in the top-level directory.
*/
-#include <jailhouse/types.h>
-#include <jailhouse/cell-config.h>
-
-struct {
- struct jailhouse_cell_desc cell;
- __u64 cpus[1];
- struct jailhouse_memory mem_regions[8];
- struct jailhouse_irqchip irqchips[1];
- struct jailhouse_pci_device pci_devices[1];
-} __attribute__((packed)) config = {
- .cell = {
- .signature = JAILHOUSE_CELL_DESC_SIGNATURE,
- .revision = JAILHOUSE_CONFIG_REVISION,
- .name = "inmate-demo",
- .flags = JAILHOUSE_CELL_PASSIVE_COMMREG,
-
- .cpu_set_size = sizeof(config.cpus),
- .num_memory_regions = ARRAY_SIZE(config.mem_regions),
- .num_irqchips = ARRAY_SIZE(config.irqchips),
- .num_pci_devices = ARRAY_SIZE(config.pci_devices),
- /* IVSHMEM_IRQ - 32 */
- .vpci_irq_base = 76, /* Not include 32 base */
-
- .console = {
- .address = 0x30890000,
- .type = JAILHOUSE_CON_TYPE_IMX,
- .flags = JAILHOUSE_CON_ACCESS_MMIO |
- JAILHOUSE_CON_REGDIST_4,
- },
- },
-
- .cpus = {
- 0x8,
- },
-
- .mem_regions = {
- /* IVSHMEM shared memory regions (demo) */
- {
- .phys_start = 0xfd900000,
- .virt_start = 0xfd900000,
- .size = 0x1000,
- .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_ROOTSHARED,
- },
- {
- .phys_start = 0xfd901000,
- .virt_start = 0xfd901000,
- .size = 0x9000,
- .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
- JAILHOUSE_MEM_ROOTSHARED,
- },
- {
- .phys_start = 0xfd90a000,
- .virt_start = 0xfd90a000,
- .size = 0x2000,
- .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_ROOTSHARED,
- },
- {
- .phys_start = 0xfd90c000,
- .virt_start = 0xfd90c000,
- .size = 0x2000,
- .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
- JAILHOUSE_MEM_ROOTSHARED,
- },
- {
- .phys_start = 0xfd90e000,
- .virt_start = 0xfd90e000,
- .size = 0x2000,
- .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_ROOTSHARED,
- },
- /* UART2 */ {
- .phys_start = 0x30890000,
- .virt_start = 0x30890000,
- .size = 0x1000,
- .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
- JAILHOUSE_MEM_IO | JAILHOUSE_MEM_ROOTSHARED,
- },
- /* RAM: start from the bottom of inmate memory */ {
- .phys_start = 0xc0000000,
- .virt_start = 0,
- .size = 0x00010000,
- .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
- JAILHOUSE_MEM_EXECUTE | JAILHOUSE_MEM_LOADABLE,
- },
- /* communication region */ {
- .virt_start = 0x80000000,
- .size = 0x00001000,
- .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
- JAILHOUSE_MEM_COMM_REGION,
- },
- },
-
- .irqchips = {
- /* GIC */ {
- .address = 0x38800000,
- .pin_base = 96,
- .pin_bitmap = {
- 0x1 << (76 + 32 - 96) /* SPI 76 */
- },
- },
- },
-
- .pci_devices = {
- {
- .type = JAILHOUSE_PCI_TYPE_IVSHMEM,
- .domain = 2,
- .bdf = 0 << 3,
- .bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
- .shmem_regions_start = 0,
- .shmem_dev_id = 1,
- .shmem_peers = 1,
- .shmem_protocol = JAILHOUSE_SHMEM_PROTO_UNDEFINED,
- },
- },
-};
+#include "cell-helper.h"
+
+/* Name, cores, entry point */
+#define CONFIG_INMATE_NAME "inmate-demo"
+#define CONFIG_INMATE_CORE_BITMAP (0b1000)
+#define CONFIG_INMATE_BASE (0x00000000)
+
+/* Memory & peripherals */
+#define CONFIG_INMATE_REGIONS \
+ MEM_REGION_RWXL(0xc0000000, CONFIG_INMATE_BASE, MB(16)), /* RAM */ \
+ \
+ MEM_REGION_ROS( 0xfd900000, 0xfd900000, KB(4)), /* IVSHMEM */ \
+ MEM_REGION_RWS( 0xfd901000, 0xfd901000, KB(36)), /* IVSHMEM */ \
+ MEM_REGION_ROS( 0xfd90a000, 0xfd90a000, KB(8)), /* IVSHMEM */ \
+ MEM_REGION_RWS( 0xfd90c000, 0xfd90c000, KB(8)), /* IVSHMEM */ \
+ MEM_REGION_ROS( 0xfd90e000, 0xfd90e000, KB(8)), /* IVSHMEM */ \