Imported Upstream version 3.2.2
[debian/gnuradio] / usrp2 / firmware / lib / buffer_pool.c
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 #include "memory_map.h"
19 #include "buffer_pool.h"
20 #include "hal_io.h" 
21
22 void
23 bp_init(void)
24 {
25   int i;
26   bp_disable_port(PORT_SERDES);
27   bp_disable_port(PORT_DSP);
28   bp_disable_port(PORT_ETH);
29   bp_disable_port(PORT_RAM);
30
31   for (i = 0; i < NBUFFERS; i++)
32     bp_clear_buf(i);
33 }
34
35 #ifndef INLINE_BUFFER_POOL
36
37 void
38 bp_clear_buf(int bufnum)
39 {
40   buffer_pool_ctrl->ctrl = BPC_BUFFER(bufnum) | BPC_PORT_NIL | BPC_CLR;
41 }
42
43 void
44 bp_disable_port(int portnum) 
45 {
46   // disable buffer connections to this port
47   buffer_pool_ctrl->ctrl = BPC_BUFFER_NIL | BPC_PORT(portnum);
48 }
49
50 void
51 bp_receive_to_buf(int bufnum, int port, int step, int fl, int ll)
52 {
53   buffer_pool_ctrl->ctrl = (BPC_READ
54                             | BPC_BUFFER(bufnum)
55                             | BPC_PORT(port)
56                             | BPC_STEP(step)
57                             | BPC_FIRST_LINE(fl)
58                             | BPC_LAST_LINE(ll));
59 }
60
61 void
62 bp_send_from_buf(int bufnum, int port, int step, int fl, int ll)
63 {
64   buffer_pool_ctrl->ctrl = (BPC_WRITE
65                             | BPC_BUFFER(bufnum)
66                             | BPC_PORT(port)
67                             | BPC_STEP(step)
68                             | BPC_FIRST_LINE(fl)
69                             | BPC_LAST_LINE(ll));
70 }
71
72 #endif