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