Imported Upstream version 3.2.2
[debian/gnuradio] / usrp2 / firmware / lib / buffer_pool.h
1 /*
2  * Copyright 2007 Free Software Foundation, Inc.
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16  */
17
18 #ifndef INCLUDED_BUFFER_POOL_H
19 #define INCLUDED_BUFFER_POOL_H
20
21 #include "memory_map.h"
22
23 // Buffer Pool Management
24
25
26 // define to have common buffer operations inlined
27 #define INLINE_BUFFER_POOL 1
28
29 void bp_init(void);
30
31 #ifndef INLINE_BUFFER_POOL
32
33 void bp_clear_buf(int bufnum);
34 void bp_disable_port(int portnum);
35 void bp_receive_to_buf(int bufnum, int port, int step, int fl, int ll);
36 void bp_send_from_buf(int bufnum, int port, int step, int fl, int ll);
37
38 #else
39
40 static inline void
41 bp_clear_buf(int bufnum)
42 {
43   buffer_pool_ctrl->ctrl = BPC_BUFFER(bufnum) | BPC_PORT_NIL | BPC_CLR;
44 }
45
46 static inline void
47 bp_disable_port(int portnum) 
48 {
49   // disable buffer connections to this port
50   buffer_pool_ctrl->ctrl = BPC_BUFFER_NIL | BPC_PORT(portnum);
51 }
52
53 static inline void
54 bp_receive_to_buf(int bufnum, int port, int step, int fl, int ll)
55 {
56   buffer_pool_ctrl->ctrl = (BPC_READ
57                             | BPC_BUFFER(bufnum)
58                             | BPC_PORT(port)
59                             | BPC_STEP(step)
60                             | BPC_FIRST_LINE(fl)
61                             | BPC_LAST_LINE(ll));
62 }
63
64 static inline void
65 bp_send_from_buf(int bufnum, int port, int step, int fl, int ll)
66 {
67   buffer_pool_ctrl->ctrl = (BPC_WRITE
68                             | BPC_BUFFER(bufnum)
69                             | BPC_PORT(port)
70                             | BPC_STEP(step)
71                             | BPC_FIRST_LINE(fl)
72                             | BPC_LAST_LINE(ll));
73 }
74 #endif
75 #endif