On 2018-05-07 14:12, Ralf Ramsauer wrote:
> We will enter this function if we hit unrecoverable state.
> 
> Signed-off-by: Ralf Ramsauer <[email protected]>
> ---
>  inmates/lib/arm-common/include/inmate.h | 6 ++++++
>  inmates/lib/x86/inmate.h                | 6 ++++++
>  2 files changed, 12 insertions(+)
> 
> diff --git a/inmates/lib/arm-common/include/inmate.h 
> b/inmates/lib/arm-common/include/inmate.h
> index 921fde96..1dfbdfbb 100644
> --- a/inmates/lib/arm-common/include/inmate.h
> +++ b/inmates/lib/arm-common/include/inmate.h
> @@ -88,6 +88,12 @@ static inline void cpu_relax(void)
>       asm volatile("" : : : "memory");
>  }
>  
> +static inline void __attribute__((noreturn)) spin_forever(void)

The function sounds a bit like a busy loop. But it's not. In fact, if
IRQs are off, there will be no loop at all.

Let's just call it halt(). In fact, we can use it some demos that just
receive interrupts and don't do anything anymore in main() -> conversion
patch welcome.

> +{
> +     for (;;)

I prefer "while (1)" / "while (true)" for such cases, but that's just
personal taste.

> +             asm volatile("wfi" : : : "memory");
> +}
> +
>  typedef void (*irq_handler_t)(unsigned int);
>  void gic_setup(irq_handler_t handler);
>  void gic_enable_irq(unsigned int irq);
> diff --git a/inmates/lib/x86/inmate.h b/inmates/lib/x86/inmate.h
> index 964a5435..f3c57d33 100644
> --- a/inmates/lib/x86/inmate.h
> +++ b/inmates/lib/x86/inmate.h
> @@ -106,6 +106,12 @@ static inline void cpu_relax(void)
>       asm volatile("rep; nop" : : : "memory");
>  }
>  
> +static inline void __attribute__((noreturn)) spin_forever(void)
> +{
> +     for (;;)
> +             asm volatile ("hlt" : : : "memory");
> +}
> +
>  static inline void outb(u8 v, u16 port)
>  {
>       asm volatile("outb %0,%1" : : "a" (v), "dN" (port));
> 

Jan

-- 
Siemens AG, Corporate Technology, CT RDA IOT SES-DE
Corporate Competence Center Embedded Linux

-- 
You received this message because you are subscribed to the Google Groups 
"Jailhouse" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to