airq.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. * Copyright IBM Corp. 2002, 2007
  3. * Author(s): Ingo Adlung <adlung@de.ibm.com>
  4. * Cornelia Huck <cornelia.huck@de.ibm.com>
  5. * Arnd Bergmann <arndb@de.ibm.com>
  6. * Peter Oberparleiter <peter.oberparleiter@de.ibm.com>
  7. */
  8. #ifndef _ASM_S390_AIRQ_H
  9. #define _ASM_S390_AIRQ_H
  10. #include <linux/bit_spinlock.h>
  11. struct airq_struct {
  12. struct hlist_node list; /* Handler queueing. */
  13. void (*handler)(struct airq_struct *); /* Thin-interrupt handler */
  14. u8 *lsi_ptr; /* Local-Summary-Indicator pointer */
  15. u8 lsi_mask; /* Local-Summary-Indicator mask */
  16. u8 isc; /* Interrupt-subclass */
  17. u8 flags;
  18. };
  19. #define AIRQ_PTR_ALLOCATED 0x01
  20. int register_adapter_interrupt(struct airq_struct *airq);
  21. void unregister_adapter_interrupt(struct airq_struct *airq);
  22. /* Adapter interrupt bit vector */
  23. struct airq_iv {
  24. unsigned long *vector; /* Adapter interrupt bit vector */
  25. unsigned long *avail; /* Allocation bit mask for the bit vector */
  26. unsigned long *bitlock; /* Lock bit mask for the bit vector */
  27. unsigned long *ptr; /* Pointer associated with each bit */
  28. unsigned int *data; /* 32 bit value associated with each bit */
  29. unsigned long bits; /* Number of bits in the vector */
  30. unsigned long end; /* Number of highest allocated bit + 1 */
  31. spinlock_t lock; /* Lock to protect alloc & free */
  32. };
  33. #define AIRQ_IV_ALLOC 1 /* Use an allocation bit mask */
  34. #define AIRQ_IV_BITLOCK 2 /* Allocate the lock bit mask */
  35. #define AIRQ_IV_PTR 4 /* Allocate the ptr array */
  36. #define AIRQ_IV_DATA 8 /* Allocate the data array */
  37. struct airq_iv *airq_iv_create(unsigned long bits, unsigned long flags);
  38. void airq_iv_release(struct airq_iv *iv);
  39. unsigned long airq_iv_alloc_bit(struct airq_iv *iv);
  40. void airq_iv_free_bit(struct airq_iv *iv, unsigned long bit);
  41. unsigned long airq_iv_scan(struct airq_iv *iv, unsigned long start,
  42. unsigned long end);
  43. static inline unsigned long airq_iv_end(struct airq_iv *iv)
  44. {
  45. return iv->end;
  46. }
  47. static inline void airq_iv_lock(struct airq_iv *iv, unsigned long bit)
  48. {
  49. const unsigned long be_to_le = BITS_PER_LONG - 1;
  50. bit_spin_lock(bit ^ be_to_le, iv->bitlock);
  51. }
  52. static inline void airq_iv_unlock(struct airq_iv *iv, unsigned long bit)
  53. {
  54. const unsigned long be_to_le = BITS_PER_LONG - 1;
  55. bit_spin_unlock(bit ^ be_to_le, iv->bitlock);
  56. }
  57. static inline void airq_iv_set_data(struct airq_iv *iv, unsigned long bit,
  58. unsigned int data)
  59. {
  60. iv->data[bit] = data;
  61. }
  62. static inline unsigned int airq_iv_get_data(struct airq_iv *iv,
  63. unsigned long bit)
  64. {
  65. return iv->data[bit];
  66. }
  67. static inline void airq_iv_set_ptr(struct airq_iv *iv, unsigned long bit,
  68. unsigned long ptr)
  69. {
  70. iv->ptr[bit] = ptr;
  71. }
  72. static inline unsigned long airq_iv_get_ptr(struct airq_iv *iv,
  73. unsigned long bit)
  74. {
  75. return iv->ptr[bit];
  76. }
  77. #endif /* _ASM_S390_AIRQ_H */