MA-14318-1 Support dual bootloader for xen

Trusty is not supported for xen so we don't need to check
the keyslot package or rollback index in spl. Reassign the
dram address for spl and u-boot to avoid conflicts.

Support serial init functions to enable debug console
in spl when xen is running.

Test: Boot and A/B slot switch on imx8qm_mek.

Change-Id: If6829252f1ec2e32255f951715c8747181951fd0
Signed-off-by: Ji Luo <ji.luo@nxp.com>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
This commit is contained in:
Ji Luo 2019-03-12 16:15:54 +08:00
parent 40f95bfc01
commit e0343ea466
4 changed files with 65 additions and 3 deletions

View File

@ -136,6 +136,7 @@ serial_initfunc(ml2_serial_initialize);
serial_initfunc(mpc85xx_serial_initialize);
serial_initfunc(mpc8xx_serial_initialize);
serial_initfunc(mxc_serial_initialize);
serial_initfunc(xen_serial_initialize);
serial_initfunc(serial_lpuart_initialize);
serial_initfunc(mxs_auart_initialize);
serial_initfunc(ns16550_serial_initialize);
@ -225,6 +226,7 @@ void serial_initialize(void)
mpc85xx_serial_initialize();
mpc8xx_serial_initialize();
mxc_serial_initialize();
xen_serial_initialize();
serial_lpuart_initialize();
mxs_auart_initialize();
ns16550_serial_initialize();

View File

@ -182,9 +182,43 @@ U_BOOT_DRIVER(serial_xen) = {
.flags = DM_FLAG_PRE_RELOC,
};
#else
static void xen_serial_putc(const char c)
{
(void)HYPERVISOR_console_io(CONSOLEIO_write, 1, &c);
}
static void xen_serial_puts(const char *str)
{
(void)HYPERVISOR_console_io(CONSOLEIO_write, strlen(str), str);
}
static int xen_serial_tstc(void)
{
return 0;
}
static int xen_serial_init(void)
{
}
static void xen_serial_setbrg(void)
{
}
static struct serial_device xen_serial_drv = {
.name = "xen_serial",
.start = xen_serial_init,
.stop = NULL,
.setbrg = xen_serial_setbrg,
.getc = NULL,
.putc = xen_serial_putc,
.puts = xen_serial_puts,
.tstc = xen_serial_tstc,
};
__weak struct serial_device *default_serial_console(void)
{
return NULL;
return &xen_serial_drv;
}
#endif

View File

@ -24,7 +24,7 @@
#undef CONFIG_LOADADDR
#define CONFIG_LOADADDR 0x80080000
#undef CONFIG_SYS_INIT_SP_ADDR
#define CONFIG_SYS_INIT_SP_ADDR 0x80200000
#define CONFIG_SYS_INIT_SP_ADDR 0x81200000
#undef CONFIG_REQUIRE_SERIAL_CONSOLE
#undef CONFIG_IMX_SMMU
@ -38,6 +38,22 @@
#endif
#define SC_IPC_CH 0x5d1d0000
#ifdef CONFIG_SPL_BUILD
#undef CONFIG_SPL_BSS_START_ADDR
#undef CONFIG_SYS_SPL_MALLOC_START
#undef CONFIG_MALLOC_F_ADDR
#undef CONFIG_SPL_TEXT_BASE
#undef CONFIG_SPL_STACK
#define CONFIG_SPL_TEXT_BASE 0x80080000
#define CONFIG_MALLOC_F_ADDR 0x80100000
#define CONFIG_SYS_SPL_MALLOC_START 0x80200000
#define CONFIG_SPL_BSS_START_ADDR 0x80300000
#define CONFIG_SPL_STACK 0x80400000
#define CONFIG_SYS_SPL_PTE_RAM_BASE 0x80500000
#endif
#define AVB_AB_I_UNDERSTAND_LIBAVB_AB_IS_DEPRECATED
#endif /* IMX8QM_MEK_ANDROID_AUTO_XEN_H */

View File

@ -214,6 +214,7 @@ int fsl_load_metadata_dual_uboot(struct blk_desc *dev_desc,
}
}
#ifndef CONFIG_XEN
static int spl_verify_rbidx(struct mmc *mmc, AvbABSlotData *slot,
struct spl_image_info *spl_image)
{
@ -273,6 +274,7 @@ static int spl_verify_rbidx(struct mmc *mmc, AvbABSlotData *slot,
}
}
#endif /* CONFIG_XEN */
#ifdef CONFIG_PARSE_CONTAINER
int mmc_load_image_parse_container_dual_uboot(
@ -284,7 +286,9 @@ int mmc_load_image_parse_container_dual_uboot(
struct blk_desc *dev_desc;
AvbABData ab_data, ab_data_orig;
size_t slot_index_to_boot, target_slot;
#ifndef CONFIG_XEN
struct keyslot_package kp;
#endif
/* Check if gpt is valid */
dev_desc = mmc_get_blk_desc(mmc);
@ -298,7 +302,8 @@ int mmc_load_image_parse_container_dual_uboot(
return -1;
}
/* Read RPMB keyslot package */
#ifndef CONFIG_XEN
/* Read RPMB keyslot package, xen won't check this. */
read_keyslot_package(&kp);
if (strcmp(kp.magic, KEYPACK_MAGIC)) {
if (rpmbkey_is_set()) {
@ -313,6 +318,8 @@ int mmc_load_image_parse_container_dual_uboot(
return -1;
}
}
#endif
/* Load AB metadata from misc partition */
if (fsl_load_metadata_dual_uboot(dev_desc, &ab_data,
&ab_data_orig)) {
@ -342,6 +349,8 @@ int mmc_load_image_parse_container_dual_uboot(
} else {
ret = mmc_load_image_parse_container(spl_image, mmc, info.start);
/* Don't need to check rollback index for xen. */
#ifndef CONFIG_XEN
/* Image loaded successfully, go to verify rollback index */
if (!ret && rpmbkey_is_set())
ret = spl_verify_rbidx(mmc, &ab_data.slots[target_slot], spl_image);
@ -349,6 +358,7 @@ int mmc_load_image_parse_container_dual_uboot(
/* Copy rpmb keyslot to secure memory. */
if (!ret)
fill_secure_keyslot_package(&kp);
#endif
}
/* Set current slot to unbootable if load/verify fail. */