dd9c8f76c58febcbec5d270703bca7a3c8f019e3
2 * arch/ubicom32/include/asm/ubicom32ring.h
3 * Userspace I/O platform driver for Ubicom32 ring buffers
5 * (C) Copyright 2009, Ubicom, Inc.
7 * This file is part of the Ubicom32 Linux Kernel Port.
9 * The Ubicom32 Linux Kernel Port is free software: you can redistribute
10 * it and/or modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation, either version 2 of the
12 * License, or (at your option) any later version.
14 * The Ubicom32 Linux Kernel Port is distributed in the hope that it
15 * will be useful, but WITHOUT ANY WARRANTY; without even the implied
16 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
17 * the GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with the Ubicom32 Linux Kernel Port. If not,
21 * see <http://www.gnu.org/licenses/>.
24 #ifndef _ASM_UBICOM32_UBICOM32RING_H
25 #define _ASM_UBICOM32_UBICOM32RING_H
27 #define UIO_UBICOM32RING_REG_VERSION 2
29 struct uio_ubicom32ring_desc
{
30 volatile unsigned int head
;
31 volatile unsigned int tail
;
33 volatile unsigned int ring
[0];
36 struct uio_ubicom32ring_regs
{
40 * Magic type used to identify the ring set. Each driver will
41 * have a different magic value.
46 * Registers defined by the driver
48 unsigned int regs_size
;
52 * The locations of the rings
54 * DO NOT ADD ANYTHING BELOW THIS LINE
56 unsigned int num_rings
;
57 struct uio_ubicom32ring_desc
*rings
[0];
63 static inline void ringtio_ring_flush(struct uio_ubicom32ring_desc
*rd
)
65 rd
->head
= rd
->tail
= 0;
71 static inline int ringtio_ring_get(struct uio_ubicom32ring_desc
*rd
, void **val
)
73 if (rd
->head
== rd
->tail
) {
77 *val
= (void *)rd
->ring
[rd
->head
++];
78 if (rd
->head
== rd
->entries
) {
87 static inline int ringtio_ring_put(struct uio_ubicom32ring_desc
*rd
, void *val
)
89 unsigned int newtail
= rd
->tail
+ 1;
90 if (newtail
== rd
->entries
) {
94 if (newtail
== rd
->head
) {
98 rd
->ring
[rd
->tail
] = (unsigned int)val
;
103 #endif /* _ASM_UBICOM32_UBICOM32RING_H */