Difference between revisions of "ARM processor"

From Wiki at Neela Nurseries
Jump to: navigation, search
m (^ Synchronization Primitives LDREX and STREX: - adding notes on assembly examples search)
m (^ Synchronization Primitives LDREX and STREX: - add example code excerpt from Arm Developer documentation site)
Line 47: Line 47:
  
 
*  https://codemachine.com/articles/arm_assembler_primer.html
 
*  https://codemachine.com/articles/arm_assembler_primer.html
 +
*  https://developer.arm.com/documentation/dui0489/c/arm-and-thumb-instructions/memory-access-instructions/ldrex-and-strex
 +
 +
Excerpt:
 +
<code>
 +
    MOV r1, #0x1                ; load the 'lock taken' value
 +
try
 +
    LDREX r0, [LockAddr]        ; load the lock value
 +
    CMP r0, #0                  ; is the lock free?
 +
    STREXEQ r0, r1, [LockAddr]  ; try and claim the lock
 +
    CMPEQ r0, #0                ; did this succeed?
 +
    BNE try                    ; no - try again
 +
    ....                        ; yes - we have the lock
 +
</code>
  
 
<!-- comentario -->
 
<!-- comentario -->
  
  
 
 
 
<!-- EOF -->
 
  
  
  
 
<!-- EOF -->
 
<!-- EOF -->

Revision as of 18:16, 17 April 2023

^ OVERVIEW

This page for notes on ARM processor architecture, and related ARM IP works.


ARM Architecture and Instruction Set Notes

[ ] . . . search for Armv8-M Architecture Reference Manual ID28092022


^ Advanced Hardware Bus AHB

ARM architecture and related IP, link to AHB paper by Rinku 1, Pawan Kumar Dahiya 2


^ Synchronization Primitives LDREX and STREX

ARM Synchronization Primitives LDREX and STREX, split a normally atomic memory write operation and allow for checking whether other Processing Elements or "bus primaries" (note 1) are also accessing the given memory location. From the short documentations linked below, it looks like LDREX updates local and global resource access monitors in certain ARM variants, and STREX either succeeds or fails based on checking one or both of those monitors, depending on whether the memory or resource is shared or not shared among multiple processing elements (PEs).

Article locally numbered (3) in the following list of URLs introduces a comparative concept in its text "The Data Memory Barrier existed before ARMv7 as a cp15 operation, but ARMv7 introduced a dedicated instruction, DMB."

Abbreviations:

abbr ERG Exclusive Reservation Granuale, refers to smallest memory regions which Exclusive Monitors are able to tag for exclusive access
abbr SCU Snoop Control Unit

2023-04-17 Monday

Searching for an example assembly code snippet calling `STREX` and branching conditionally based on result. Search string is "arm assembly strex and branch example". First found results include:

Excerpt:

   MOV r1, #0x1                ; load the 'lock taken' value

try

   LDREX r0, [LockAddr]        ; load the lock value
   CMP r0, #0                  ; is the lock free?
   STREXEQ r0, r1, [LockAddr]  ; try and claim the lock
   CMPEQ r0, #0                ; did this succeed?
   BNE try                     ; no - try again
   ....                        ; yes - we have the lock