Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  *  linux/drivers/acorn/scsi/msgqueue.h
0004  *
0005  *  Copyright (C) 1997 Russell King
0006  *
0007  *  message queue handling
0008  */
0009 #ifndef MSGQUEUE_H
0010 #define MSGQUEUE_H
0011 
0012 struct message {
0013     char msg[8];
0014     int length;
0015     int fifo;
0016 };
0017 
0018 struct msgqueue_entry {
0019     struct message msg;
0020     struct msgqueue_entry *next;
0021 };
0022 
0023 #define NR_MESSAGES 4
0024 
0025 typedef struct {
0026     struct msgqueue_entry *qe;
0027     struct msgqueue_entry *free;
0028     struct msgqueue_entry entries[NR_MESSAGES];
0029 } MsgQueue_t;
0030 
0031 /*
0032  * Function: void msgqueue_initialise(MsgQueue_t *msgq)
0033  * Purpose : initialise a message queue
0034  * Params  : msgq - queue to initialise
0035  */
0036 extern void msgqueue_initialise(MsgQueue_t *msgq);
0037 
0038 /*
0039  * Function: void msgqueue_free(MsgQueue_t *msgq)
0040  * Purpose : free a queue
0041  * Params  : msgq - queue to free
0042  */
0043 extern void msgqueue_free(MsgQueue_t *msgq);
0044 
0045 /*
0046  * Function: int msgqueue_msglength(MsgQueue_t *msgq)
0047  * Purpose : calculate the total length of all messages on the message queue
0048  * Params  : msgq - queue to examine
0049  * Returns : number of bytes of messages in queue
0050  */
0051 extern int msgqueue_msglength(MsgQueue_t *msgq);
0052 
0053 /*
0054  * Function: struct message *msgqueue_getmsg(MsgQueue_t *msgq, int msgno)
0055  * Purpose : return a message & its length
0056  * Params  : msgq   - queue to obtain message from
0057  *         : msgno  - message number
0058  * Returns : pointer to message string, or NULL
0059  */
0060 extern struct message *msgqueue_getmsg(MsgQueue_t *msgq, int msgno);
0061 
0062 /*
0063  * Function: int msgqueue_addmsg(MsgQueue_t *msgq, int length, ...)
0064  * Purpose : add a message onto a message queue
0065  * Params  : msgq   - queue to add message on
0066  *       length - length of message
0067  *       ...    - message bytes
0068  * Returns : != 0 if successful
0069  */
0070 extern int msgqueue_addmsg(MsgQueue_t *msgq, int length, ...);
0071 
0072 /*
0073  * Function: void msgqueue_flush(MsgQueue_t *msgq)
0074  * Purpose : flush all messages from message queue
0075  * Params  : msgq - queue to flush
0076  */
0077 extern void msgqueue_flush(MsgQueue_t *msgq);
0078 
0079 #endif