2 * Source file for diva log facility
4 * Copyright (C) Eicon Technology Corporation, 2000.
6 * Eicon File Revision : 1.5
8 * This software may be used and distributed according to the terms
9 * of the GNU General Public License, incorporated herein by reference.
21 /*Counter to monitor number of messages */
24 #define MAX_BUFFERED_MSGS (1000)
26 /* Our Linked List Structure to hold message */
27 typedef struct klog_link{
29 struct klog_link *next;
32 /* First & Last structures in list*/
37 * retrieve message from FIFO buffer
38 * returns NULL if buffer empty
39 * otherwise returns pointer to entry
42 char *DivasLogFifoRead(void)
49 /* Buffer Empty - No Messages */
54 /* Keep track of message to be read & increment to next message*/
57 /*Return ptr to Msg */
58 return((char *)old_head);
62 * write message into FIFO buffer
65 void DivasLogFifoWrite(char *entry, int length)
72 /* No Entries in Log */
75 new_klog=UxAlloc(sizeof(KNODE));
83 memset(new_klog, 0, sizeof(KNODE));
85 /* Set head & tail to point to the new Msg Struct */
91 new_klog=UxAlloc(sizeof(KNODE));
99 memset(new_klog, 0, sizeof(KNODE));
101 /* Let last Msg Struct point to new Msg Struct & inc tail */
107 if (length > sizeof(klog_t))
109 length = sizeof(klog_t);
112 memcpy(&tail->klog, entry, length);
118 * DivaslogFifoEmpty:return TRUE if FIFO buffer is empty,otherwise FALSE
120 int DivasLogFifoEmpty(void)
122 return (m_count == 0);
126 *DivasLogFifoFull:return TRUE if FIFO buffer is full,otherwise FALSE
128 int DivasLogFifoFull(void)
130 return (m_count == MAX_BUFFERED_MSGS);
134 * generate an IDI log entry
137 void DivasLogIdi(card_t *card, ENTITY *e, int request)
142 memset(&klog, 0, sizeof(klog));
144 klog.time_stamp = UxTimeGet();
146 klog.length = sizeof(ENTITY) > sizeof(klog.buffer) ?
147 sizeof(klog.buffer) : sizeof(ENTITY);
149 klog.card = (int) (card - DivasCards);
151 klog.type = request ? KLOG_IDI_REQ : KLOG_IDI_CALLBACK;
153 memcpy(klog.buffer, e, klog.length);
155 /* send to the log driver and return */
157 DivasLogAdd(&klog, sizeof(klog));