[ARM] pxa: update defconfig for Verdex Pro
[linux-2.6/verdex.git] / drivers / staging / hv / RingBuffer.h
blob6202157e145dc791b1412149c0dc94eb0066a2e8
1 /*
3 * Copyright (c) 2009, Microsoft Corporation.
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU General Public License,
7 * version 2, as published by the Free Software Foundation.
9 * This program is distributed in the hope it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
16 * Place - Suite 330, Boston, MA 02111-1307 USA.
18 * Authors:
19 * Haiyang Zhang <haiyangz@microsoft.com>
20 * Hank Janssen <hjanssen@microsoft.com>
25 #ifndef _RING_BUFFER_H_
26 #define _RING_BUFFER_H_
28 #include <linux/scatterlist.h>
30 typedef struct _RING_BUFFER {
31 /* Offset in bytes from the start of ring data below */
32 volatile u32 WriteIndex;
34 /* Offset in bytes from the start of ring data below */
35 volatile u32 ReadIndex;
37 volatile u32 InterruptMask;
39 /* Pad it to PAGE_SIZE so that data starts on page boundary */
40 u8 Reserved[4084];
42 /* NOTE:
43 * The InterruptMask field is used only for channels but since our
44 * vmbus connection also uses this data structure and its data starts
45 * here, we commented out this field.
47 /* volatile u32 InterruptMask; */
50 * Ring data starts here + RingDataStartOffset
51 * !!! DO NOT place any fields below this !!!
53 u8 Buffer[0];
54 } __attribute__((packed)) RING_BUFFER;
56 typedef struct _RING_BUFFER_INFO {
57 RING_BUFFER *RingBuffer;
58 u32 RingSize; /* Include the shared header */
59 spinlock_t ring_lock;
61 u32 RingDataSize; /* < ringSize */
62 u32 RingDataStartOffset;
64 } RING_BUFFER_INFO;
66 typedef struct _RING_BUFFER_DEBUG_INFO {
67 u32 CurrentInterruptMask;
68 u32 CurrentReadIndex;
69 u32 CurrentWriteIndex;
70 u32 BytesAvailToRead;
71 u32 BytesAvailToWrite;
72 } RING_BUFFER_DEBUG_INFO;
76 /* Interface */
79 int RingBufferInit(RING_BUFFER_INFO *RingInfo, void *Buffer, u32 BufferLen);
81 void RingBufferCleanup(RING_BUFFER_INFO *RingInfo);
83 int RingBufferWrite(RING_BUFFER_INFO *RingInfo,
84 struct scatterlist *sglist,
85 u32 sgcount);
87 int RingBufferPeek(RING_BUFFER_INFO *RingInfo, void *Buffer, u32 BufferLen);
89 int RingBufferRead(RING_BUFFER_INFO *RingInfo,
90 void *Buffer,
91 u32 BufferLen,
92 u32 Offset);
94 u32 GetRingBufferInterruptMask(RING_BUFFER_INFO *RingInfo);
96 void DumpRingInfo(RING_BUFFER_INFO *RingInfo, char *Prefix);
98 void RingBufferGetDebugInfo(RING_BUFFER_INFO *RingInfo,
99 RING_BUFFER_DEBUG_INFO *DebugInfo);
101 #endif /* _RING_BUFFER_H_ */