bitops.h 675 B

123456789101112131415161718192021222324252627282930313233
  1. .macro bitop, instr
  2. and r2, r0, #7
  3. mov r3, #1
  4. mov r3, r3, lsl r2
  5. save_and_disable_irqs ip, r2
  6. ldrb r2, [r1, r0, lsr #3]
  7. \instr r2, r2, r3
  8. strb r2, [r1, r0, lsr #3]
  9. restore_irqs ip
  10. mov pc, lr
  11. .endm
  12. /**
  13. * testop - implement a test_and_xxx_bit operation.
  14. * @instr: operational instruction
  15. * @store: store instruction
  16. *
  17. * Note: we can trivially conditionalise the store instruction
  18. * to avoid dirting the data cache.
  19. */
  20. .macro testop, instr, store
  21. add r1, r1, r0, lsr #3
  22. and r3, r0, #7
  23. mov r0, #1
  24. save_and_disable_irqs ip, r2
  25. ldrb r2, [r1]
  26. tst r2, r0, lsl r3
  27. \instr r2, r2, r0, lsl r3
  28. \store r2, [r1]
  29. restore_irqs ip
  30. moveq r0, #0
  31. mov pc, lr
  32. .endm