# ARM Cortex-m \_\_Disable\_IRQ intrinsic setting PriMask bit

**URL:** https://forum.ada-lang.io/t/arm-cortex-m-disable-irq-intrinsic-setting-primask-bit/4732
**Category:** General
**Tags:** embedded
**Created:** [September 10, 2026, 4:11pm UTC](https://forum.ada-lang.io/t/arm-cortex-m-disable-irq-intrinsic-setting-primask-bit/4732 "2026-09-10T16:11:07Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![kevlar700](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/kevlar700/32/40_2.png) [@kevlar700](https://forum.ada-lang.io/u/kevlar700)
#### Post date: [September 10, 2026, 4:11pm UTC](https://forum.ada-lang.io/t/arm-cortex-m-disable-irq-intrinsic-setting-primask-bit/4732/1 "2026-09-10T16:11:07Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![OneWingedShark](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/onewingedshark/32/305_2.png) [@OneWingedShark](https://forum.ada-lang.io/u/OneWingedShark)
#### Post date: [September 10, 2026, 9:03pm UTC](https://forum.ada-lang.io/t/arm-cortex-m-disable-irq-intrinsic-setting-primask-bit/4732/2 "2026-09-10T21:03:36Z")

</div>

> [@kevlar700](#):
>
> but how can you import the \_\_disable\_IRQ intrinsic

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.

---

<div class="post-metadata">

### Author: ![damaki](https://forum.ada-lang.io/letter_avatar_proxy/v4/letter/d/3bc359/32.png) [@damaki](https://forum.ada-lang.io/u/damaki)
#### Post date: [September 10, 2026, 9:06pm UTC](https://forum.ada-lang.io/t/arm-cortex-m-disable-irq-intrinsic-setting-primask-bit/4732/3 "2026-09-10T21:06:02Z")

</div>

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

```c
__attribute__ ( ( always_inline ) ) __STATIC_INLINE void__ disable_irq(void)
{
  __ASM volatile ("cpsid i" : : : "memory");
}

```

So you could do the equivalent in Ada:

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

```
