Difference between revisions of "ARM processor"
m (→^ Synchronization Primitives LDREX and STREX: - add example code excerpt from Arm Developer documentation site) |
m (→^ Synchronization Primitives LDREX and STREX) |
||
Line 50: | Line 50: | ||
Excerpt: | Excerpt: | ||
− | < | + | <pre> |
MOV r1, #0x1 ; load the 'lock taken' value | MOV r1, #0x1 ; load the 'lock taken' value | ||
try | try | ||
Line 59: | Line 59: | ||
BNE try ; no - try again | BNE try ; no - try again | ||
.... ; yes - we have the lock | .... ; yes - we have the lock | ||
− | </ | + | </pre> |
<!-- comentario --> | <!-- comentario --> |
Revision as of 18:19, 17 April 2023
^ OVERVIEW
This page for notes on ARM processor architecture, and related ARM IP works.
ARM Architecture and Instruction Set Notes
- http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0040d/Cabdcdci.html . . . ARM BX "branch and exchange" instruction (branch and change to thumb mode)
[ ] . . . 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."
- (1) https://developer.arm.com/documentation/dht0008/a/ch01s02s01
- (2) https://developer.arm.com/documentation/dht0008/a/arm-synchronization-primitives/exclusive-accesses/exclusive-monitors
- (3) https://developer.arm.com/documentation/dht0008/a/arm-synchronization-primitives/exclusive-accesses/memory-barriers
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:
- 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:
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