msgqueue.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * linux/drivers/acorn/scsi/msgqueue.h
  4. *
  5. * Copyright (C) 1997 Russell King
  6. *
  7. * message queue handling
  8. */
  9. #ifndef MSGQUEUE_H
  10. #define MSGQUEUE_H
  11. struct message {
  12. char msg[8];
  13. int length;
  14. int fifo;
  15. };
  16. struct msgqueue_entry {
  17. struct message msg;
  18. struct msgqueue_entry *next;
  19. };
  20. #define NR_MESSAGES 4
  21. typedef struct {
  22. struct msgqueue_entry *qe;
  23. struct msgqueue_entry *free;
  24. struct msgqueue_entry entries[NR_MESSAGES];
  25. } MsgQueue_t;
  26. /*
  27. * Function: void msgqueue_initialise(MsgQueue_t *msgq)
  28. * Purpose : initialise a message queue
  29. * Params : msgq - queue to initialise
  30. */
  31. extern void msgqueue_initialise(MsgQueue_t *msgq);
  32. /*
  33. * Function: void msgqueue_free(MsgQueue_t *msgq)
  34. * Purpose : free a queue
  35. * Params : msgq - queue to free
  36. */
  37. extern void msgqueue_free(MsgQueue_t *msgq);
  38. /*
  39. * Function: int msgqueue_msglength(MsgQueue_t *msgq)
  40. * Purpose : calculate the total length of all messages on the message queue
  41. * Params : msgq - queue to examine
  42. * Returns : number of bytes of messages in queue
  43. */
  44. extern int msgqueue_msglength(MsgQueue_t *msgq);
  45. /*
  46. * Function: struct message *msgqueue_getmsg(MsgQueue_t *msgq, int msgno)
  47. * Purpose : return a message & its length
  48. * Params : msgq - queue to obtain message from
  49. * : msgno - message number
  50. * Returns : pointer to message string, or NULL
  51. */
  52. extern struct message *msgqueue_getmsg(MsgQueue_t *msgq, int msgno);
  53. /*
  54. * Function: int msgqueue_addmsg(MsgQueue_t *msgq, int length, ...)
  55. * Purpose : add a message onto a message queue
  56. * Params : msgq - queue to add message on
  57. * length - length of message
  58. * ... - message bytes
  59. * Returns : != 0 if successful
  60. */
  61. extern int msgqueue_addmsg(MsgQueue_t *msgq, int length, ...);
  62. /*
  63. * Function: void msgqueue_flush(MsgQueue_t *msgq)
  64. * Purpose : flush all messages from message queue
  65. * Params : msgq - queue to flush
  66. */
  67. extern void msgqueue_flush(MsgQueue_t *msgq);
  68. #endif