Skip to content

Instantly share code, notes, and snippets.

@chmanie
Created December 13, 2024 17:50
Show Gist options
  • Save chmanie/82a944f551a3d56e9d16fe6e95051129 to your computer and use it in GitHub Desktop.
Save chmanie/82a944f551a3d56e9d16fe6e95051129 to your computer and use it in GitHub Desktop.
asm acquire/release
.section ".text.<embassy_rp::critical_section_impl::RpSpinlockCs as critical_section::Impl>::acquire","ax",%progbits
.p2align 1
.type <embassy_rp::critical_section_impl::RpSpinlockCs as critical_section::Impl>::acquire,%function
.code 16
.thumb_func
<embassy_rp::critical_section_impl::RpSpinlockCs as critical_section::Impl>::acquire:
.fnstart
.cfi_startproc
.save {r7, lr}
push {r7, lr}
.cfi_def_cfa_offset 8
.cfi_offset lr, -4
.cfi_offset r7, -8
.setfp r7, sp
mov r7, sp
.cfi_def_cfa_register r7
mov.w r1, #-805306368
movw r3, #65184
ldr r0, [r1]
mov.w r2, #256
movt r3, #65535
movw r12, :lower16:embassy_rp::critical_section_impl::LOCK_OWNER.0
movt r12, :upper16:embassy_rp::critical_section_impl::LOCK_OWNER.0
lsls r0, r0, #24
it eq
moveq.w r2, #512
movw r0, #380
movt r0, #53248
str r2, [r0, r3]
@APP
mrs lr, primask
@NO_APP
ldr r2, [r1]
ldab r1, [r12]
adds r2, #1
uxtb r3, r2
cmp r1, r3
itt eq
moveq r0, #2
popeq {r7, pc}
and r3, lr, #1
@APP
cpsid i
@NO_APP
.LBB146_2:
@MEMBARRIER
ldr r1, [r0]
cbnz r1, .LBB146_6
cbnz r3, .LBB146_5
@MEMBARRIER
@APP
cpsie i
@NO_APP
.LBB146_5:
@APP
cpsid i
@NO_APP
b .LBB146_2
.LBB146_6:
eor r0, r3, #1
strb.w r2, [r12]
pop {r7, pc}
.section .text._critical_section_1_0_release,"ax",%progbits
.globl _critical_section_1_0_release
.p2align 1
.type _critical_section_1_0_release,%function
.code 16
.thumb_func
_critical_section_1_0_release:
.fnstart
.cfi_startproc
movs r1, #36
uxtb r2, r0
movt r1, #53248
cmp r2, #2
beq .LBB150_3
movw r2, :lower16:embassy_rp::critical_section_impl::LOCK_OWNER.0
movs r3, #0
movt r2, :upper16:embassy_rp::critical_section_impl::LOCK_OWNER.0
lsls r0, r0, #24
strb r3, [r2]
mov.w r2, #1
@MEMBARRIER
str.w r2, [r1, #344]
beq .LBB150_3
@MEMBARRIER
@APP
cpsie i
@NO_APP
.LBB150_3:
mov.w r0, #-805306368
ldr r0, [r0]
lsls r0, r0, #24
mov.w r0, #256
it eq
moveq.w r0, #512
str r0, [r1]
bx lr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment