spinlock.h 673 B

1234567891011121314151617181920212223242526272829303132333435
  1. /*
  2. * Copyright (c) 2013-2024, Arm Limited and Contributors. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #ifndef SPINLOCK_H
  7. #define SPINLOCK_H
  8. #ifndef __ASSEMBLER__
  9. #include <stdint.h>
  10. typedef struct spinlock {
  11. volatile uint32_t lock;
  12. } spinlock_t;
  13. typedef struct bitlock {
  14. volatile uint8_t lock;
  15. } bitlock_t;
  16. void spin_lock(spinlock_t *lock);
  17. void spin_unlock(spinlock_t *lock);
  18. void bit_lock(bitlock_t *lock, uint8_t mask);
  19. void bit_unlock(bitlock_t *lock, uint8_t mask);
  20. #else
  21. /* Spin lock definitions for use in assembly */
  22. #define SPINLOCK_ASM_ALIGN 2
  23. #define SPINLOCK_ASM_SIZE 4
  24. #endif /* __ASSEMBLER__ */
  25. #endif /* SPINLOCK_H */