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
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.
19 * Haiyang Zhang <haiyangz@microsoft.com>
20 * Hank Janssen <hjanssen@microsoft.com>
25 #ifndef _RING_BUFFER_H_
26 #define _RING_BUFFER_H_
28 #include "include/osd.h"
30 typedef struct _SG_BUFFER_LIST {
35 typedef struct _RING_BUFFER {
36 volatile UINT32 WriteIndex; // Offset in bytes from the start of ring data below
37 volatile UINT32 ReadIndex; // Offset in bytes from the start of ring data below
39 volatile UINT32 InterruptMask;
40 u8 Reserved[4084]; // Pad it to PAGE_SIZE so that data starts on page boundary
41 // NOTE: The InterruptMask field is used only for channels but since our vmbus connection
42 // also uses this data structure and its data starts here, we commented out this field.
43 // volatile UINT32 InterruptMask;
44 // Ring data starts here + RingDataStartOffset !!! DO NOT place any fields below this !!!
46 } STRUCT_PACKED RING_BUFFER;
48 typedef struct _RING_BUFFER_INFO {
49 RING_BUFFER* RingBuffer;
50 UINT32 RingSize; // Include the shared header
53 UINT32 RingDataSize; // < ringSize
54 UINT32 RingDataStartOffset;
59 typedef struct _RING_BUFFER_DEBUG_INFO {
60 UINT32 CurrentInterruptMask;
61 UINT32 CurrentReadIndex;
62 UINT32 CurrentWriteIndex;
63 UINT32 BytesAvailToRead;
64 UINT32 BytesAvailToWrite;
65 }RING_BUFFER_DEBUG_INFO;
74 RING_BUFFER_INFO *RingInfo,
81 RING_BUFFER_INFO *RingInfo
86 RING_BUFFER_INFO *RingInfo,
87 SG_BUFFER_LIST SgBuffers[],
93 RING_BUFFER_INFO *RingInfo,
100 RING_BUFFER_INFO *RingInfo,
107 GetRingBufferInterruptMask(
108 RING_BUFFER_INFO *RingInfo
113 RING_BUFFER_INFO* RingInfo,
118 RingBufferGetDebugInfo(
119 RING_BUFFER_INFO *RingInfo,
120 RING_BUFFER_DEBUG_INFO *DebugInfo
123 #endif // _RING_BUFFER_H_