This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
Re: [PATCH][Newlib][AArch32] Add support for HLT to Mixed Mode models
- From: Tamar Christina <Tamar dot Christina at arm dot com>
- To: "newlib at sourceware dot org" <newlib at sourceware dot org>
- Cc: nd <nd at arm dot com>, Richard Earnshaw <Richard dot Earnshaw at arm dot com>, "alfedotov at gmail dot com" <alfedotov at gmail dot com>
- Date: Fri, 8 Feb 2019 10:21:53 +0000
- Subject: Re: [PATCH][Newlib][AArch32] Add support for HLT to Mixed Mode models
- References: <20190207160553.GA2205@arm.com> <20190207182613.GF13951@calimero.vinschen.de>
Hi Corinna,
So sorry, I had been busy sending patches all day and forgot about the different
format for newlib.
I have updated my scripts to generate git format patches for newlib so it
shouldn't happen again!
Ok for master?
Thanks,
Tamar
The 02/07/2019 19:26, Corinna Vinschen wrote:
> On Feb 7 16:05, Tamar Christina wrote:
> > Hi All,
> >
> > The Semihosting v2 protocol requires us to output the Armv8-a HLT instruction
> > when in mixed mode (SEMIHOST_V2_MIXED_MODE), however it also requires this to
> > be done for Armv7-a and earlier architectures.
> >
> > The HLT instruction is defined in the undefined encoding space for older
> > architectures but simulators such as QEMU already trap on it [1] for all
> > architectures and is a requirement for semihosting v2 [2]
> >
> > Unfortunately the GAS restricts the use of HLT to Armv8-a which requires us to
> > use the instruction encodings we want directly in crt0.
> >
> > This patch does this, I have not updated newlib/libc/* as that is quite out of
> > date already. A proper sync is needed in order to get things back in sync.
> >
> > A different patch for this would be best.
> >
> > [1] https://github.com/qemu/qemu/commit/19a6e31c9d2701ef648b70ddcfc3bf64cec8c37e
> > [2] https://developer.arm.com/docs/100863/latest/the-semihosting-interface
> >
> > Regtested on arm-none-eabi and no issues.
> >
> > Ok for trunk?
>
> Sorry, no.
>
> > Thanks,
> > Tamar
> >
> > libgloss/ChangeLog:
> >
> > 2019-02-07 Tamar Christina <tamar.christina@arm.com>
> >
> > PR libgloss/24070
> > * arm/crt0.S: Convert macros to function Macros.
> > * arm/swi.h (AngelSWI_ARM, AngelSWI): Use raw insn encoding for
> > SEMIHOST_V2_MIXED_MODE case.
> > (AngelSWIAsm): Make function.
> > (AngelSWIInsn, AngelSWIAsm): Use .inst directive as instruction.
>
> Did you have a look into libgloss/ChangeLog lately? We're using git for
> three years now. Please provide patches in git format-patch format and
> provide a normal git log entry explaining what the patch does and why.
> We don't do CVS ChangeLogs anymore.
>
>
> Thanks,
> Corinna
>
> --
> Corinna Vinschen
> Cygwin Maintainer
> Red Hat
--
From 2f69cf1de05cdd124195574df5b7bef4a43481e3 Mon Sep 17 00:00:00 2001
From: Tamar Christina <tamar.christina@arm.com>
Date: Wed, 6 Feb 2019 11:27:12 +0000
Subject: [PATCH] AArch32: Add support for HLT to Mixed Mode models
The Semihosting v2 protocol requires us to output the Armv8-a HLT instruction
when in mixed mode (SEMIHOST_V2_MIXED_MODE), however it also requires this to
be done for Armv7-a and earlier architectures.
The HLT instruction is defined in the undefined encoding space for older
architectures but simulators such as QEMU already trap on it [1] for all
architectures and is a requirement for semihosting v2 [2].
Unfortunately the GAS restricts the use of HLT to Armv8-a which requires us to
use the instruction encodings we want directly in crt0.
This patch does this, I have not updated newlib/libc/* as that is quite out of
date already. A proper sync is needed in order to get things back in sync.
A different patch for this would be best.
[1] https://github.com/qemu/qemu/commit/19a6e31c9d2701ef648b70ddcfc3bf64cec8c37e
[2] https://developer.arm.com/docs/100863/latest/the-semihosting-interface
---
libgloss/arm/crt0.S | 6 +++---
libgloss/arm/swi.h | 14 ++++++++++----
2 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/libgloss/arm/crt0.S b/libgloss/arm/crt0.S
index 48f3d6b1db..c708f63d83 100644
--- a/libgloss/arm/crt0.S
+++ b/libgloss/arm/crt0.S
@@ -116,10 +116,10 @@
bkpt AngelSWI
#elif defined(__thumb2__)
/* We are in thumb mode for startup on armv7 architectures. */
- AngelSWIAsm AngelSWI
+ AngelSWIAsm (AngelSWI)
#else
/* We are always in ARM mode for startup on pre armv7 archs. */
- AngelSWIAsm AngelSWI_ARM
+ AngelSWIAsm (AngelSWI_ARM)
#endif
ldr r0, .LC0 /* point at values read */
@@ -297,7 +297,7 @@ __change_mode:
#else
movs r0, #AngelSWI_Reason_GetCmdLine
ldr r1, .LC30 /* Space for command line */
- AngelSWIAsm AngelSWI
+ AngelSWIAsm (AngelSWI)
ldr r1, .LC30
ldr r1, [r1]
#endif
diff --git a/libgloss/arm/swi.h b/libgloss/arm/swi.h
index 67eb36b3fa..8f50ee7d9b 100644
--- a/libgloss/arm/swi.h
+++ b/libgloss/arm/swi.h
@@ -31,9 +31,9 @@
/* Now the SWI numbers and reason codes for RDI (Angel) monitors. */
#if defined (SEMIHOST_V2) && defined (SEMIHOST_V2_MIXED_MODE)
- #define AngelSWI_ARM 0xF000 /* HLT A32. */
+ #define AngelSWI_ARM 0xE10F0070 /* HLT #0xF000 A32. */
#ifdef __thumb__
- #define AngelSWI 0x3C /* HLT T32. */
+ #define AngelSWI 0xBABC /* HLT #0x3c T32. */
#else /* __thumb__. */
#define AngelSWI AngelSWI_ARM
#endif /* __thumb__. */
@@ -49,10 +49,16 @@
/* For thumb only architectures use the BKPT instruction instead of SWI. */
#ifdef THUMB_VXM
#define AngelSWIInsn "bkpt"
- #define AngelSWIAsm bkpt
+ #define AngelSWIAsm(IMM) bkpt IMM
+#elif defined (SEMIHOST_V2) && defined (SEMIHOST_V2_MIXED_MODE)
+ /* This is actually encoding the HLT instruction, however we don't have
+ support for this in older assemblers. So we have to encode the
+ instruction manually. */
+ #define AngelSWIInsn ".inst"
+ #define AngelSWIAsm(IMM) .inst IMM
#else
#define AngelSWIInsn "swi"
- #define AngelSWIAsm swi
+ #define AngelSWIAsm(IMM) swi IMM
#endif
/* The reason codes: */
--
2.20.1