ARM Cortex-m __Disable_IRQ intrinsic setting PriMask bit

I seem to have forgotten or perhaps I never knew and it’s usually better to be more specific but how can you import the __disable_IRQ intrinsic. Import e.g. cmsis_gcc.h into the project or is it better to use the cpsid assembly instruction or is there another way?

Edit: I guess Ada Drivers Library uses Assembly for __DSB etc., so I’ll go with that.

Have you tried with Import, Convention => C, Link_Name => "__disable_IRQ"; on the appropriate subprogram? (The link-name might be wrong, double-check that.)

Embedded assembly is fine, but if the vendor provided you binaries (or source) you can use that to discover what you have to do on the Ada end.

__disable_irq is an inline function, so it can’t really be imported into Ada. Its C definition is:

__attribute__( ( always_inline ) ) __STATIC_INLINE void __disable_irq(void)
{
  __ASM volatile ("cpsid i" : : : "memory");
}

So you could do the equivalent in Ada:

procedure Disable_IRQ with Inline_Always is
begin
   Asm (Template => "cpsid i",
        Volatile => True,
        Clobber  => "memory");
end Disable_IRQ;