You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ja...@apache.org on 2026/10/26 18:58:14 UTC

(mynewt-core) 03/09: hw/mcu: Use __asm instead of asm

This is an automated email from the ASF dual-hosted git repository.

sjanc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git

commit f17d0f677002f15ca3f852d4320e3912e88bcc13
Author: Szymon Janc <sz...@codecoup.pl>
AuthorDate: Tue Oct 20 00:54:03 2026 +0200

    hw/mcu: Use __asm instead of asm
    
    asm is a GNU extension keyword that is not available when compiling
    with -std=c11. Use __asm which is always available in GCC and clang.
    
    Assisted-by: Claude:claude-opus-5-5
---
 hw/mcu/dialog/cmac/src/cmac_timer.c              |  8 +++----
 hw/mcu/dialog/cmac/src/hal_system.c              |  2 +-
 hw/mcu/dialog/da1469x/src/hal_system_start.c     | 22 +++++++++----------
 hw/mcu/microchip/pic32mz/src/hal_gpio.c          |  2 +-
 hw/mcu/microchip/pic32mz/src/hal_spi.c           |  2 +-
 hw/mcu/nordic/nrf51xxx/src/hal_system_start.c    | 14 ++++++------
 hw/mcu/nordic/nrf52xxx/src/hal_system_start.c    | 14 ++++++------
 hw/mcu/nordic/nrf5340/src/hal_system_start.c     | 28 ++++++++++++------------
 hw/mcu/nordic/nrf5340_net/src/hal_system_start.c | 14 ++++++------
 hw/mcu/nordic/nrf54lxx/src/hal_system_start.c    | 14 ++++++------
 hw/mcu/nordic/nrf91xx/src/hal_system_start.c     | 14 ++++++------
 11 files changed, 67 insertions(+), 67 deletions(-)

diff --git a/hw/mcu/dialog/cmac/src/cmac_timer.c b/hw/mcu/dialog/cmac/src/cmac_timer.c
index 1820362ee..f44daf62d 100644
--- a/hw/mcu/dialog/cmac/src/cmac_timer.c
+++ b/hw/mcu/dialog/cmac/src/cmac_timer.c
@@ -215,10 +215,10 @@ compensate_ll_timer(uint32_t slept_us)
      * Compiler barrier to make sure calculations are already done prior to
      * this line since code below has strict time constraints.
      */
-    asm volatile(""
-                 :
-                 :"r" (comp_ll_timer_36), "r" (comp_ll_timer_09)
-                 : "memory");
+    __asm volatile(""
+                   :
+                   : "r"(comp_ll_timer_36), "r"(comp_ll_timer_09)
+                   : "memory");
 
     /*
      * Normally we should only wait for next 1MHz tick but since prior to
diff --git a/hw/mcu/dialog/cmac/src/hal_system.c b/hw/mcu/dialog/cmac/src/hal_system.c
index cf2be99fe..e9ee39fd4 100644
--- a/hw/mcu/dialog/cmac/src/hal_system.c
+++ b/hw/mcu/dialog/cmac/src/hal_system.c
@@ -37,7 +37,7 @@ hal_system_reset(void)
     __disable_irq();
 
     if (hal_debugger_connected()) {
-        asm("bkpt");
+        __asm("bkpt");
     }
 
     CMAC->CM_EXC_STAT_REG = CMAC_CM_EXC_STAT_REG_EXC_FW_ERROR_Msk;
diff --git a/hw/mcu/dialog/da1469x/src/hal_system_start.c b/hw/mcu/dialog/da1469x/src/hal_system_start.c
index 1937a7d83..024a8362f 100644
--- a/hw/mcu/dialog/da1469x/src/hal_system_start.c
+++ b/hw/mcu/dialog/da1469x/src/hal_system_start.c
@@ -46,17 +46,17 @@ hal_system_start(void *img_start)
 
     img_data = (uint32_t *)img_data_addr;
 
-    asm volatile (".syntax unified        \n"
-                  /* Reset MSPLIM */
-                  "    mov  r0, #0        \n"
-                  "    msr  msplim, r0    \n"
-                  /* 1st word is stack pointer */
-                  "    msr  msp, %0       \n"
-                  /* 2nd word is a reset handler (image entry) */
-                  "    bx   %1            \n"
-                  : /* no output */
-                  : "r" (img_data[0]), "r" (img_data[1])
-                  : "r0");
+    __asm volatile(".syntax unified        \n"
+                   /* Reset MSPLIM */
+                   "    mov  r0, #0        \n"
+                   "    msr  msplim, r0    \n"
+                   /* 1st word is stack pointer */
+                   "    msr  msp, %0       \n"
+                   /* 2nd word is a reset handler (image entry) */
+                   "    bx   %1            \n"
+                   : /* no output */
+                   : "r"(img_data[0]), "r"(img_data[1])
+                   : "r0");
 }
 
 void
diff --git a/hw/mcu/microchip/pic32mz/src/hal_gpio.c b/hw/mcu/microchip/pic32mz/src/hal_gpio.c
index 3687c8709..6e12f8f9e 100644
--- a/hw/mcu/microchip/pic32mz/src/hal_gpio.c
+++ b/hw/mcu/microchip/pic32mz/src/hal_gpio.c
@@ -398,7 +398,7 @@ hal_gpio_toggle(int pin)
      * One instruction cycle is required between a write and a read
      * operation on the same port.
      */
-    asm volatile ("nop");
+    __asm volatile("nop");
 
     return !!(PORTx(port) & mask);
 }
diff --git a/hw/mcu/microchip/pic32mz/src/hal_spi.c b/hw/mcu/microchip/pic32mz/src/hal_spi.c
index 79b2f1e65..0d53fef23 100644
--- a/hw/mcu/microchip/pic32mz/src/hal_spi.c
+++ b/hw/mcu/microchip/pic32mz/src/hal_spi.c
@@ -692,7 +692,7 @@ hal_spi_abort(int spi_num)
 
     /* Clear TX and RX FIFO by turning off and on module */
     SPIxCONCLR(spi_num) = _SPI1CON_ON_MASK;
-    asm volatile ("nop");
+    __asm volatile("nop");
     SPIxCONSET(spi_num) = _SPI1CON_ON_MASK;
 
     return 0;
diff --git a/hw/mcu/nordic/nrf51xxx/src/hal_system_start.c b/hw/mcu/nordic/nrf51xxx/src/hal_system_start.c
index 93e0a7e89..b4cd866ea 100644
--- a/hw/mcu/nordic/nrf51xxx/src/hal_system_start.c
+++ b/hw/mcu/nordic/nrf51xxx/src/hal_system_start.c
@@ -32,13 +32,13 @@ hal_system_start(void *img_start)
 {
     uint32_t *img_data = img_start;
 
-    asm volatile (".syntax unified        \n"
-                  /* 1st word is stack pointer */
-                  "    msr  msp, %0       \n"
-                  /* 2nd word is a reset handler (image entry) */
-                  "    bx   %1            \n"
-                  : /* no output */
-                  : "r" (img_data[0]), "r" (img_data[1]));
+    __asm volatile(".syntax unified        \n"
+                   /* 1st word is stack pointer */
+                   "    msr  msp, %0       \n"
+                   /* 2nd word is a reset handler (image entry) */
+                   "    bx   %1            \n"
+                   : /* no output */
+                   : "r"(img_data[0]), "r"(img_data[1]));
 }
 
 /**
diff --git a/hw/mcu/nordic/nrf52xxx/src/hal_system_start.c b/hw/mcu/nordic/nrf52xxx/src/hal_system_start.c
index 25e35b1a8..289e2e088 100644
--- a/hw/mcu/nordic/nrf52xxx/src/hal_system_start.c
+++ b/hw/mcu/nordic/nrf52xxx/src/hal_system_start.c
@@ -32,13 +32,13 @@ hal_system_start(void *img_start)
 {
     uint32_t *img_data = img_start;
 
-    asm volatile (".syntax unified        \n"
-                  /* 1st word is stack pointer */
-                  "    msr  msp, %0       \n"
-                  /* 2nd word is a reset handler (image entry) */
-                  "    bx   %1            \n"
-                  : /* no output */
-                  : "r" (img_data[0]), "r" (img_data[1]));
+    __asm volatile(".syntax unified        \n"
+                   /* 1st word is stack pointer */
+                   "    msr  msp, %0       \n"
+                   /* 2nd word is a reset handler (image entry) */
+                   "    bx   %1            \n"
+                   : /* no output */
+                   : "r"(img_data[0]), "r"(img_data[1]));
 }
 
 /**
diff --git a/hw/mcu/nordic/nrf5340/src/hal_system_start.c b/hw/mcu/nordic/nrf5340/src/hal_system_start.c
index 17753e1dc..4fc11b966 100644
--- a/hw/mcu/nordic/nrf5340/src/hal_system_start.c
+++ b/hw/mcu/nordic/nrf5340/src/hal_system_start.c
@@ -159,13 +159,13 @@ hal_system_start(void *img_start)
      * Normal loop here is inlined by GCC to call to memset hence asm version of
      * memset that does not use stack (that just get erased).
      */
-    asm volatile("    mov     r0, #0        \n"
-                 "1:  stmia   %0!, {r0}     \n"
-                 "    cmp     %0, %1        \n"
-                 "    blt     1b            \n"
-        :
-        : "r" (&_ram_start), "r" (&__StackTop)
-        : "r0");
+    __asm volatile("    mov     r0, #0        \n"
+                   "1:  stmia   %0!, {r0}     \n"
+                   "    cmp     %0, %1        \n"
+                   "    blt     1b            \n"
+                   :
+                   : "r"(&_ram_start), "r"(&__StackTop)
+                   : "r0");
     /* Application startup code expects interrupts to be enabled */
     __enable_irq();
 
@@ -187,13 +187,13 @@ hal_system_start(void *img_start)
 {
     uint32_t *img_data = img_start;
 
-    asm volatile (".syntax unified        \n"
-                  /* 1st word is stack pointer */
-                  "    msr  msp, %0       \n"
-                  /* 2nd word is a reset handler (image entry) */
-                  "    bx   %1            \n"
-                  : /* no output */
-                  : "r" (img_data[0]), "r" (img_data[1]));
+    __asm volatile(".syntax unified        \n"
+                   /* 1st word is stack pointer */
+                   "    msr  msp, %0       \n"
+                   /* 2nd word is a reset handler (image entry) */
+                   "    bx   %1            \n"
+                   : /* no output */
+                   : "r"(img_data[0]), "r"(img_data[1]));
 }
 
 #endif
diff --git a/hw/mcu/nordic/nrf5340_net/src/hal_system_start.c b/hw/mcu/nordic/nrf5340_net/src/hal_system_start.c
index f34f0f63c..c4303b89f 100644
--- a/hw/mcu/nordic/nrf5340_net/src/hal_system_start.c
+++ b/hw/mcu/nordic/nrf5340_net/src/hal_system_start.c
@@ -32,13 +32,13 @@ hal_system_start(void *img_start)
 {
     uint32_t *img_data = img_start;
 
-    asm volatile (".syntax unified        \n"
-                  /* 1st word is stack pointer */
-                  "    msr  msp, %0       \n"
-                  /* 2nd word is a reset handler (image entry) */
-                  "    bx   %1            \n"
-                  : /* no output */
-                  : "r" (img_data[0]), "r" (img_data[1]));
+    __asm volatile(".syntax unified        \n"
+                   /* 1st word is stack pointer */
+                   "    msr  msp, %0       \n"
+                   /* 2nd word is a reset handler (image entry) */
+                   "    bx   %1            \n"
+                   : /* no output */
+                   : "r"(img_data[0]), "r"(img_data[1]));
 }
 
 /**
diff --git a/hw/mcu/nordic/nrf54lxx/src/hal_system_start.c b/hw/mcu/nordic/nrf54lxx/src/hal_system_start.c
index c00221cab..d32cb6075 100644
--- a/hw/mcu/nordic/nrf54lxx/src/hal_system_start.c
+++ b/hw/mcu/nordic/nrf54lxx/src/hal_system_start.c
@@ -32,13 +32,13 @@ hal_system_start(void *img_start)
 {
     uint32_t *img_data = img_start;
 
-    asm volatile(".syntax unified        \n"
-                 /* 1st word is stack pointer */
-                 "    msr  msp, %0       \n"
-                 /* 2nd word is a reset handler (image entry) */
-                 "    bx   %1            \n"
-                 : /* no output */
-                 : "r"(img_data[0]), "r"(img_data[1]));
+    __asm volatile(".syntax unified        \n"
+                   /* 1st word is stack pointer */
+                   "    msr  msp, %0       \n"
+                   /* 2nd word is a reset handler (image entry) */
+                   "    bx   %1            \n"
+                   : /* no output */
+                   : "r"(img_data[0]), "r"(img_data[1]));
 }
 
 /**
diff --git a/hw/mcu/nordic/nrf91xx/src/hal_system_start.c b/hw/mcu/nordic/nrf91xx/src/hal_system_start.c
index e8b86b77a..b4eedaab9 100644
--- a/hw/mcu/nordic/nrf91xx/src/hal_system_start.c
+++ b/hw/mcu/nordic/nrf91xx/src/hal_system_start.c
@@ -32,13 +32,13 @@ hal_system_start(void *img_start)
 {
     uint32_t *img_data = img_start;
 
-    asm volatile (".syntax unified        \n"
-                  /* 1st word is stack pointer */
-                  "    msr  msp, %0       \n"
-                  /* 2nd word is a reset handler (image entry) */
-                  "    bx   %1            \n"
-                  : /* no output */
-                  : "r" (img_data[0]), "r" (img_data[1]));
+    __asm volatile(".syntax unified        \n"
+                   /* 1st word is stack pointer */
+                   "    msr  msp, %0       \n"
+                   /* 2nd word is a reset handler (image entry) */
+                   "    bx   %1            \n"
+                   : /* no output */
+                   : "r"(img_data[0]), "r"(img_data[1]));
 }
 
 /**