From bf4667d05a1386df2dffcbf1eb652f79d25b4cb2 Mon Sep 17 00:00:00 2001 From: Stefan Markovic Date: Fri, 10 Aug 2018 19:21:07 +0200 Subject: mips_malta: Fix semihosting argument passing for nanoMIPS bare metal MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix passing argument for nanoMIPS bare metal related to the semihosting regime. Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Aleksandar Markovic Signed-off-by: Yongbok Kim Signed-off-by: Aleksandar Markovic Signed-off-by: Stefan Markovic --- hw/mips/mips_malta.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'hw/mips') diff --git a/hw/mips/mips_malta.c b/hw/mips/mips_malta.c index f261dd6a94..40041d5ec0 100644 --- a/hw/mips/mips_malta.c +++ b/hw/mips/mips_malta.c @@ -630,8 +630,14 @@ static void write_bootloader_nanomips(uint8_t *base, int64_t run_addr, /* nop */ /* to_here: */ - stw_p(p++, 0x0080); stw_p(p++, 0x0002); + if (semihosting_get_argc()) { + /* Preserve a0 content as arguments have been passed */ + stw_p(p++, 0x8000); stw_p(p++, 0xc000); + /* nop */ + } else { + stw_p(p++, 0x0080); stw_p(p++, 0x0002); /* li a0,2 */ + } stw_p(p++, 0xe3a0 | NM_HI1(ENVP_ADDR - 64)); -- cgit v1.2.3