msgqueue.h 2.1 KB

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