aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--firmware/microblaze/apps/txrx_uhd.c111
-rw-r--r--firmware/microblaze/lib/Makefile.inc5
-rw-r--r--firmware/microblaze/lib/banal.h5
-rw-r--r--firmware/microblaze/lib/bsm12.c319
-rw-r--r--firmware/microblaze/lib/bsm12.h83
-rw-r--r--firmware/microblaze/lib/buffer_pool.c72
-rw-r--r--firmware/microblaze/lib/buffer_pool.h75
-rw-r--r--firmware/microblaze/lib/compiler.h3
-rw-r--r--firmware/microblaze/lib/dbsm.c299
-rw-r--r--firmware/microblaze/lib/dbsm.h90
-rw-r--r--firmware/microblaze/lib/net_common.c36
-rw-r--r--firmware/microblaze/lib/net_common.h10
-rw-r--r--firmware/microblaze/lib/nonstdio.h2
-rw-r--r--firmware/microblaze/lib/print_addrs.c (renamed from firmware/microblaze/lib/print_mac_addr.c)4
-rw-r--r--firmware/microblaze/lib/u2_init.c5
-rw-r--r--firmware/microblaze/lib/usrp2_bytesex.h66
-rw-r--r--firmware/microblaze/lib/wb16550.h98
17 files changed, 38 insertions, 1245 deletions
diff --git a/firmware/microblaze/apps/txrx_uhd.c b/firmware/microblaze/apps/txrx_uhd.c
index 9c1873e1c..2d001cfa8 100644
--- a/firmware/microblaze/apps/txrx_uhd.c
+++ b/firmware/microblaze/apps/txrx_uhd.c
@@ -28,12 +28,10 @@
#include "memory_map.h"
#include "spi.h"
#include "hal_io.h"
-#include "buffer_pool.h"
#include "pic.h"
#include <stdbool.h>
#include "ethernet.h"
#include "nonstdio.h"
-#include "dbsm.h"
#include <net/padded_eth_hdr.h>
#include <net_common.h>
#include "memcpy_wa.h"
@@ -48,82 +46,6 @@
#include <arp_cache.h>
#include "udp_fw_update.h"
-/*
- * Full duplex Tx and Rx between ethernet and DSP pipelines
- *
- * Buffer 1 is used by the cpu to send frames to the host.
- * Buffers 2 and 3 are used to double-buffer the DSP Rx to eth flow
- * Buffers 4 and 5 are used to double-buffer the eth to DSP Tx eth flow
- */
-//#define CPU_RX_BUF 0 // eth -> cpu
-
-#define DSP_RX_BUF_0 2 // dsp rx -> eth (double buffer)
-#define DSP_RX_BUF_1 3 // dsp rx -> eth
-#define DSP_TX_BUF_0 4 // eth -> dsp tx (double buffer)
-#define DSP_TX_BUF_1 5 // eth -> dsp tx
-
-/*
- * ================================================================
- * configure DSP TX double buffering state machine (eth -> dsp)
- * ================================================================
- */
-
-// DSP Tx reads ethernet header words
-#define DSP_TX_FIRST_LINE ((sizeof(padded_eth_hdr_t) + sizeof(struct ip_hdr) + sizeof(struct udp_hdr))/sizeof(uint32_t))
-
-// Receive from ethernet
-buf_cmd_args_t dsp_tx_recv_args = {
- PORT_ETH,
- 0,
- BP_LAST_LINE
-};
-
-// send to DSP Tx
-buf_cmd_args_t dsp_tx_send_args = {
- PORT_DSP,
- DSP_TX_FIRST_LINE, // starts just past transport header
- 0 // filled in from last_line register
-};
-
-dbsm_t dsp_tx_sm; // the state machine
-
-/*
- * ================================================================
- * configure DSP RX double buffering state machine (dsp -> eth)
- * ================================================================
- */
-
-static const uint32_t rx_ctrl_word = 1 << 16;
-
-// DSP Rx writes ethernet header words
-#define DSP_RX_FIRST_LINE sizeof(rx_ctrl_word)/sizeof(uint32_t)
-
-static bool dbsm_rx_inspector(dbsm_t *sm, int buf_this){
- size_t num_lines = buffer_pool_status->last_line[buf_this]-DSP_RX_FIRST_LINE;
- ((uint32_t*)buffer_ram(buf_this))[0] = (num_lines*sizeof(uint32_t)) | (1 << 16);
- return false;
-}
-
-// receive from DSP
-buf_cmd_args_t dsp_rx_recv_args = {
- PORT_DSP,
- DSP_RX_FIRST_LINE,
- BP_LAST_LINE
-};
-
-// send to ETH
-buf_cmd_args_t dsp_rx_send_args = {
- PORT_ETH,
- 0, // starts with ethernet header in line 0
- 0, // filled in from list_line register
-};
-
-dbsm_t dsp_rx_sm; // the state machine
-
-
-// The mac address of the host we're sending to.
-eth_mac_addr_t host_mac_addr;
-
static void setup_network(void);
// ----------------------------------------------------------------
@@ -136,11 +58,6 @@ static struct socket_address fp_socket_src, fp_socket_dst;
void start_rx_streaming_cmd(void);
void stop_rx_cmd(void);
-static void print_ip_addr(const void *t){
- uint8_t *p = (uint8_t *)t;
- printf("%d.%d.%d.%d", p[0], p[1], p[2], p[3]);
-}
-
void handle_udp_data_packet(
struct socket_address src, struct socket_address dst,
unsigned char *payload, int payload_len
@@ -167,7 +84,7 @@ void handle_udp_data_packet(
setup_network();
// kick off the state machine
- dbsm_start(&dsp_rx_sm);
+ //FIME dbsm_start(&dsp_rx_sm);
}
@@ -382,6 +299,7 @@ void handle_udp_ctrl_packet(
* Return true if we handled it here, otherwise
* it'll be passed on to the DSP Tx pipe
*/
+/*
static bool
eth_pkt_inspector(dbsm_t *sm, int bufno)
{
@@ -419,6 +337,7 @@ eth_pkt_inspector(dbsm_t *sm, int bufno)
handle_eth_packet(buff, len);
return true;
}
+*/
//------------------------------------------------------------------
@@ -486,10 +405,10 @@ static void setup_network(void){
inline static void
buffer_irq_handler(unsigned irq)
{
- uint32_t status = buffer_pool_status->status;
+ //FIXME uint32_t status = buffer_pool_status->status;
- dbsm_process_status(&dsp_tx_sm, status);
- dbsm_process_status(&dsp_rx_sm, status);
+ //FIXME dbsm_process_status(&dsp_tx_sm, status);
+ //FIXME dbsm_process_status(&dsp_rx_sm, status);
}
int
@@ -529,23 +448,23 @@ main(void)
// initialize double buffering state machine for ethernet -> DSP Tx
- dbsm_init(&dsp_tx_sm, DSP_TX_BUF_0,
- &dsp_tx_recv_args, &dsp_tx_send_args,
- eth_pkt_inspector);
+ //FIXME dbsm_init(&dsp_tx_sm, DSP_TX_BUF_0,
+//FIXME &dsp_tx_recv_args, &dsp_tx_send_args,
+//FIXME eth_pkt_inspector);
// initialize double buffering state machine for DSP RX -> Ethernet
- dbsm_init(&dsp_rx_sm, DSP_RX_BUF_0,
- &dsp_rx_recv_args, &dsp_rx_send_args,
- dbsm_rx_inspector);
+//FIXME dbsm_init(&dsp_rx_sm, DSP_RX_BUF_0,
+//FIXME &dsp_rx_recv_args, &dsp_rx_send_args,
+//FIXME dbsm_rx_inspector);
sr_tx_ctrl->clear_state = 1;
- bp_clear_buf(DSP_TX_BUF_0);
- bp_clear_buf(DSP_TX_BUF_1);
+//FIXME bp_clear_buf(DSP_TX_BUF_0);
+//FIXME bp_clear_buf(DSP_TX_BUF_1);
// kick off the state machine
- dbsm_start(&dsp_tx_sm);
+//FIXME dbsm_start(&dsp_tx_sm);
//int which = 0;
diff --git a/firmware/microblaze/lib/Makefile.inc b/firmware/microblaze/lib/Makefile.inc
index 38c630df4..1ca375861 100644
--- a/firmware/microblaze/lib/Makefile.inc
+++ b/firmware/microblaze/lib/Makefile.inc
@@ -21,10 +21,7 @@ COMMON_SRCS = \
$(top_srcdir)/lib/u2_init.c \
$(top_srcdir)/lib/abort.c \
$(top_srcdir)/lib/ad9510.c \
- $(top_srcdir)/lib/bsm12.c \
- $(top_srcdir)/lib/buffer_pool.c \
$(top_srcdir)/lib/clocks.c \
- $(top_srcdir)/lib/dbsm.c \
$(top_srcdir)/lib/eeprom.c \
$(top_srcdir)/lib/eth_addrs.c \
$(top_srcdir)/lib/eth_mac.c \
@@ -39,7 +36,7 @@ COMMON_SRCS = \
$(top_srcdir)/lib/memset_wa.c \
$(top_srcdir)/lib/nonstdio.c \
$(top_srcdir)/lib/pic.c \
- $(top_srcdir)/lib/print_mac_addr.c \
+ $(top_srcdir)/lib/print_addrs.c \
$(top_srcdir)/lib/print_rmon_regs.c \
$(top_srcdir)/lib/print_buffer.c \
$(top_srcdir)/lib/printf.c \
diff --git a/firmware/microblaze/lib/banal.h b/firmware/microblaze/lib/banal.h
index 7b3c71a20..634234350 100644
--- a/firmware/microblaze/lib/banal.h
+++ b/firmware/microblaze/lib/banal.h
@@ -21,6 +21,8 @@
#include <stdint.h>
#include <lwip/ip_addr.h>
+#define dimof(x) (sizeof(x)/sizeof(x[0]))
+
/*
* 1's complement sum for IP and UDP headers
*
@@ -84,7 +86,4 @@ get_int64(const unsigned char *s)
return get_uint64(s);
}
-void
-print_ip(struct ip_addr ip);
-
#endif /* INCLUDED_BANAL_H */
diff --git a/firmware/microblaze/lib/bsm12.c b/firmware/microblaze/lib/bsm12.c
deleted file mode 100644
index 3f17fe42d..000000000
--- a/firmware/microblaze/lib/bsm12.c
+++ /dev/null
@@ -1,319 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2009 Free Software Foundation, Inc.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-/*
- * buffer state machine: 1 input to two outputs
- *
- * Typically used to read packets from the ethernet and then after inspecting,
- * handle the packet in firmware or pass it on to 1 of the 2 buffer destinations.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "bsm12.h"
-#include "memory_map.h"
-#include "buffer_pool.h"
-#include <stdbool.h>
-#include "nonstdio.h"
-#include <stdlib.h>
-
-typedef enum {
- BS_EMPTY,
- BS_FILLING,
- BS_FULL,
- BS_EMPTYING,
-} buffer_state_t;
-
-static buffer_state_t buffer_state[NBUFFERS];
-static uint32_t last_send_ctrl[NBUFFERS];
-static int8_t buffer_target[NBUFFERS]; // -1, 0 or 1.
-static uint8_t buffer_dst[NBUFFERS]; // 0 or 1. Valid only when BF_EMPTYING
-
-#define ST_IDLE (-1)
-
-void
-bsm12_init(bsm12_t *sm, int buf0,
- const buf_cmd_args_t *recv,
- const buf_cmd_args_t *send0,
- const buf_cmd_args_t *send1,
- bsm12_inspector_t inspect)
-{
- if (buf0 & 0x3) // precondition: buf0 % 4 == 0
- abort();
-
- sm->buf0 = buf0;
- sm->running = false;
- sm->recv_args = *recv;
- sm->send_args[0] = *send0;
- sm->send_args[1] = *send1;
-
- sm->rx_state = ST_IDLE;
- sm->tx_state[0] = ST_IDLE;
- sm->tx_state[1] = ST_IDLE;
-
- sm->inspect = inspect;
-
- sm->bps_error = BPS_ERROR(buf0 + 0) | BPS_ERROR(buf0 + 1) | BPS_ERROR(buf0 + 2);
- sm->bps_done = BPS_DONE(buf0 + 0) | BPS_DONE(buf0 + 1) | BPS_DONE(buf0 + 2);
- sm->bps_error_or_done = sm->bps_error | sm->bps_done;
-
- // How much to adjust the last_line register.
- // It's 1 for everything but the ethernet.
- sm->last_line_adj = recv->port == PORT_ETH ? 3 : 1;
-
- buffer_state[sm->buf0 + 0] = BS_EMPTY;
- buffer_state[sm->buf0 + 1] = BS_EMPTY;
- buffer_state[sm->buf0 + 2] = BS_EMPTY;
-
- buffer_target[sm->buf0 + 0] = -1;
- buffer_target[sm->buf0 + 1] = -1;
- buffer_target[sm->buf0 + 2] = -1;
-
- for (int i = 0; i < NBUFFERS; i++)
- sm->next_buf[i] = buf0;
-
- sm->next_buf[buf0 + 0] = buf0 + 1;
- sm->next_buf[buf0 + 1] = buf0 + 2;
- sm->next_buf[buf0 + 2] = buf0 + 0;
-
- for (int i = 0; i < 3; i++){
- sm->precomputed_receive_to_buf_ctrl_word[i] =
- (BPC_READ
- | BPC_BUFFER(sm->buf0 + i)
- | BPC_PORT(sm->recv_args.port)
- | BPC_STEP(1)
- | BPC_FIRST_LINE(sm->recv_args.first_line)
- | BPC_LAST_LINE(sm->recv_args.last_line));
-
- for (int j = 0; j < 2; j++){
- sm->precomputed_send_from_buf_ctrl_word[i][j] =
- (BPC_WRITE
- | BPC_BUFFER(sm->buf0 + i)
- | BPC_PORT(sm->send_args[j].port)
- | BPC_STEP(1)
- | BPC_FIRST_LINE(sm->send_args[j].first_line)
- | BPC_LAST_LINE(0)); // last line filled in at runtime
- }
- }
-}
-
-static inline void
-bsm12_receive_to_buf(bsm12_t *sm, int bufno)
-{
- buffer_pool_ctrl->ctrl = sm->precomputed_receive_to_buf_ctrl_word[bufno & 0x3];
-}
-
-static inline void
-bsm12_send_from_buf(bsm12_t *sm, int bufno, int dst_idx)
-{
- dst_idx &= 0x1;
-
- uint32_t t =
- (sm->precomputed_send_from_buf_ctrl_word[bufno & 0x3][dst_idx]
- | BPC_LAST_LINE(buffer_pool_status->last_line[bufno] - sm->last_line_adj));
-
- buffer_pool_ctrl->ctrl = t;
- last_send_ctrl[bufno] = t;
- buffer_dst[bufno] = dst_idx;
-}
-
-static inline void
-bsm12_resend_from_buf(bsm12_t *sm, int bufno)
-{
- buffer_pool_ctrl->ctrl = last_send_ctrl[bufno];
-}
-
-void
-bsm12_start(bsm12_t *sm)
-{
- sm->running = true;
-
- buffer_state[sm->buf0 + 0] = BS_EMPTY;
- buffer_state[sm->buf0 + 1] = BS_EMPTY;
- buffer_state[sm->buf0 + 2] = BS_EMPTY;
-
- buffer_target[sm->buf0 + 0] = -1;
- buffer_target[sm->buf0 + 1] = -1;
- buffer_target[sm->buf0 + 2] = -1;
-
- bp_clear_buf(sm->buf0 + 0);
- bp_clear_buf(sm->buf0 + 1);
- bp_clear_buf(sm->buf0 + 2);
-
- sm->rx_state = 0;
- sm->tx_state[0] = ST_IDLE;
- sm->tx_state[1] = ST_IDLE;
- bsm12_receive_to_buf(sm, sm->buf0);
- buffer_state[sm->buf0] = BS_FILLING;
-}
-
-void
-bsm12_stop(bsm12_t *sm)
-{
- sm->running = false;
- bp_clear_buf(sm->buf0 + 0);
- bp_clear_buf(sm->buf0 + 1);
- bp_clear_buf(sm->buf0 + 2);
- buffer_state[sm->buf0 + 0] = BS_EMPTY;
- buffer_state[sm->buf0 + 1] = BS_EMPTY;
- buffer_state[sm->buf0 + 2] = BS_EMPTY;
-}
-
-static void bsm12_process_helper(bsm12_t *sm, int buf_this);
-static void bsm12_error_helper(bsm12_t *sm, int buf_this);
-
-void
-bsm12_process_status(bsm12_t *sm, uint32_t status)
-{
- // anything for us?
- if ((status & sm->bps_error_or_done) == 0 || !sm->running)
- return;
-
- if (status & sm->bps_error){
- // Most likely an ethernet Rx error. We just restart the transfer.
- if (status & (BPS_ERROR(sm->buf0 + 0)))
- bsm12_error_helper(sm, sm->buf0 + 0);
-
- if (status & (BPS_ERROR(sm->buf0 + 1)))
- bsm12_error_helper(sm, sm->buf0 + 1);
-
- if (status & (BPS_ERROR(sm->buf0 + 2)))
- bsm12_error_helper(sm, sm->buf0 + 2);
- }
-
- if (status & BPS_DONE(sm->buf0 + 0))
- bsm12_process_helper(sm, sm->buf0 + 0);
-
- if (status & BPS_DONE(sm->buf0 + 1))
- bsm12_process_helper(sm, sm->buf0 + 1);
-
- if (status & BPS_DONE(sm->buf0 + 2))
- bsm12_process_helper(sm, sm->buf0 + 2);
-}
-
- static void
-bsm12_process_helper(bsm12_t *sm, int buf_this)
-{
- bp_clear_buf(buf_this);
-
- if (buffer_state[buf_this] == BS_FILLING){
-
- buffer_state[buf_this] = BS_FULL;
- buffer_target[buf_this] = -1;
-
- //
- // where does this packet go?
- //
- int dst = sm->inspect(sm, buf_this);
- if (dst == -1){
- //
- // f/w handled the packet; refill the buffer
- //
- bsm12_receive_to_buf(sm, buf_this);
- buffer_state[buf_this] = BS_FILLING;
- buffer_target[buf_this] = -1;
- sm->rx_state = buf_this & 0x3;
- }
- else { // goes to dst 0 or 1
- //
- // If the next buffer is empty, start a receive on it
- //
- int t = sm->next_buf[buf_this];
- if (buffer_state[t] == BS_EMPTY){
- bsm12_receive_to_buf(sm, t);
- buffer_state[t] = BS_FILLING;
- buffer_target[t] = -1;
- sm->rx_state = t & 0x3;
- }
- else
- sm->rx_state = ST_IDLE;
-
- //
- // If the destination is idle, start the xfer, othewise remember it
- //
- if (sm->tx_state[dst] == ST_IDLE){
- bsm12_send_from_buf(sm, buf_this, dst);
- sm->tx_state[dst] = buf_this & 0x3;
- buffer_state[buf_this] = BS_EMPTYING;
- buffer_target[buf_this] = -1;
- }
- else {
- buffer_target[buf_this] = dst;
- }
- }
- }
-
- else { // BS_EMPTYING
-
- buffer_state[buf_this] = BS_EMPTY;
- buffer_target[buf_this] = -1;
-
- if (sm->rx_state == ST_IDLE){ // fire off another receive
- sm->rx_state = buf_this & 0x3;
- bsm12_receive_to_buf(sm, buf_this);
- buffer_state[buf_this] = BS_FILLING;
- buffer_target[buf_this] = -1;
- }
-
- int dst = buffer_dst[buf_this]; // the dst we were emptying into
- // is the next buffer full and for us?
- int t = sm->next_buf[buf_this];
- if (buffer_target[t] == dst){ // yes,
- bsm12_send_from_buf(sm, t, dst); // send it
- buffer_state[t] = BS_EMPTYING;
- buffer_target[t] = -1;
- sm->tx_state[dst] = t & 0x3;
- }
- // how about the one after that?
- else if (buffer_target[t=sm->next_buf[t]] == dst){ // yes,
- bsm12_send_from_buf(sm, t, dst); // send it
- buffer_state[t] = BS_EMPTYING;
- buffer_target[t] = -1;
- sm->tx_state[dst] = t & 0x3;
- }
- else {
- sm->tx_state[dst] = ST_IDLE;
- }
- }
-}
-
-static void
-bsm12_error_helper(bsm12_t *sm, int buf_this)
-{
- bp_clear_buf(buf_this); // clears ERROR flag
-
- if (buffer_state[buf_this] == BS_FILLING){
- bsm12_receive_to_buf(sm, buf_this); // restart the xfer
- }
- else { // buffer was emptying
- bsm12_resend_from_buf(sm, buf_this); // restart the xfer
- }
-}
-
-
-void
-bsm12_handle_tx_underrun(bsm12_t *sm)
-{
-}
-
-void
-bsm12_handle_rx_overrun(bsm12_t *sm)
-{
-}
diff --git a/firmware/microblaze/lib/bsm12.h b/firmware/microblaze/lib/bsm12.h
deleted file mode 100644
index b8e576b79..000000000
--- a/firmware/microblaze/lib/bsm12.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2009 Free Software Foundation, Inc.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef INCLUDED_BSM12_H
-#define INCLUDED_BSM12_H
-
-#include "dbsm.h"
-#include "memory_map.h"
-
-/*!
- * buffer state machine: 1 input to two outputs
- *
- * Typically used to read packets from the ethernet and then after inspecting,
- * handle the packet in firmware or pass it on to 1 of the 2 buffer destinations.
- */
-
-struct _bsm12;
-typedef struct _bsm12 bsm12_t;
-
-/*!
- * Pointer to function that does packet inspection.
- *
- * \param sm the state machine
- * \param buf_this the index of the buffer to inspect and/or pass on
- *
- * Returns -1, 0 or 1. If it returns -1, it means that the s/w
- * handled that packet, and that it should NOT be passed on to one of
- * the buffer endpoints. 0 indicates the first endpoint, 1 the second endpoint.
- */
-typedef int (*bsm12_inspector_t)(bsm12_t *sm, int buf_this);
-
-
-/*!
- * buffer state machine: 1 input to two outputs
- */
-struct _bsm12
-{
- uint8_t buf0; // This machine uses buf0, buf0+1 and buf0+2. buf0 % 4 == 0.
- uint8_t running;
- int8_t rx_state; // -1, 0, 1, 2 which buffer we're receiving into
- int8_t tx_state[2]; // -1, 0, 1, 2 which buffer we're sending from
- buf_cmd_args_t recv_args;
- buf_cmd_args_t send_args[2];
- bsm12_inspector_t inspect;
- int last_line_adj;
- uint32_t bps_error;
- uint32_t bps_done;
- uint32_t bps_error_or_done;
- uint8_t next_buf[NBUFFERS];
- uint32_t precomputed_receive_to_buf_ctrl_word[3];
- uint32_t precomputed_send_from_buf_ctrl_word[4][2]; // really only 3, not 4
- // (easier addr comp)
-};
-
-void bsm12_init(bsm12_t *sm, int buf0,
- const buf_cmd_args_t *recv,
- const buf_cmd_args_t *send0,
- const buf_cmd_args_t *send1,
- bsm12_inspector_t inspect);
-
-void bsm12_start(bsm12_t *sm);
-void bsm12_stop(bsm12_t *sm);
-void bsm12_process_status(bsm12_t *sm, uint32_t status);
-void bsm12_handle_tx_underrun(bsm12_t *sm);
-void bsm12_handle_rx_overrun(bsm12_t *sm);
-
-
-#endif /* INCLUDED_BSM12_H */
diff --git a/firmware/microblaze/lib/buffer_pool.c b/firmware/microblaze/lib/buffer_pool.c
deleted file mode 100644
index 77e7c5213..000000000
--- a/firmware/microblaze/lib/buffer_pool.c
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright 2007 Free Software Foundation, Inc.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "memory_map.h"
-#include "buffer_pool.h"
-#include "hal_io.h"
-
-void
-bp_init(void)
-{
- int i;
- bp_disable_port(PORT_SERDES);
- bp_disable_port(PORT_DSP);
- bp_disable_port(PORT_ETH);
- bp_disable_port(PORT_RAM);
-
- for (i = 0; i < NBUFFERS; i++)
- bp_clear_buf(i);
-}
-
-#ifndef INLINE_BUFFER_POOL
-
-void
-bp_clear_buf(int bufnum)
-{
- buffer_pool_ctrl->ctrl = BPC_BUFFER(bufnum) | BPC_PORT_NIL | BPC_CLR;
-}
-
-void
-bp_disable_port(int portnum)
-{
- // disable buffer connections to this port
- buffer_pool_ctrl->ctrl = BPC_BUFFER_NIL | BPC_PORT(portnum);
-}
-
-void
-bp_receive_to_buf(int bufnum, int port, int step, int fl, int ll)
-{
- buffer_pool_ctrl->ctrl = (BPC_READ
- | BPC_BUFFER(bufnum)
- | BPC_PORT(port)
- | BPC_STEP(step)
- | BPC_FIRST_LINE(fl)
- | BPC_LAST_LINE(ll));
-}
-
-void
-bp_send_from_buf(int bufnum, int port, int step, int fl, int ll)
-{
- buffer_pool_ctrl->ctrl = (BPC_WRITE
- | BPC_BUFFER(bufnum)
- | BPC_PORT(port)
- | BPC_STEP(step)
- | BPC_FIRST_LINE(fl)
- | BPC_LAST_LINE(ll));
-}
-
-#endif
diff --git a/firmware/microblaze/lib/buffer_pool.h b/firmware/microblaze/lib/buffer_pool.h
deleted file mode 100644
index 145b20f8d..000000000
--- a/firmware/microblaze/lib/buffer_pool.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright 2007 Free Software Foundation, Inc.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef INCLUDED_BUFFER_POOL_H
-#define INCLUDED_BUFFER_POOL_H
-
-#include "memory_map.h"
-
-// Buffer Pool Management
-
-
-// define to have common buffer operations inlined
-#define INLINE_BUFFER_POOL 1
-
-void bp_init(void);
-
-#ifndef INLINE_BUFFER_POOL
-
-void bp_clear_buf(int bufnum);
-void bp_disable_port(int portnum);
-void bp_receive_to_buf(int bufnum, int port, int step, int fl, int ll);
-void bp_send_from_buf(int bufnum, int port, int step, int fl, int ll);
-
-#else
-
-static inline void
-bp_clear_buf(int bufnum)
-{
- buffer_pool_ctrl->ctrl = BPC_BUFFER(bufnum) | BPC_PORT_NIL | BPC_CLR;
-}
-
-static inline void
-bp_disable_port(int portnum)
-{
- // disable buffer connections to this port
- buffer_pool_ctrl->ctrl = BPC_BUFFER_NIL | BPC_PORT(portnum);
-}
-
-static inline void
-bp_receive_to_buf(int bufnum, int port, int step, int fl, int ll)
-{
- buffer_pool_ctrl->ctrl = (BPC_READ
- | BPC_BUFFER(bufnum)
- | BPC_PORT(port)
- | BPC_STEP(step)
- | BPC_FIRST_LINE(fl)
- | BPC_LAST_LINE(ll));
-}
-
-static inline void
-bp_send_from_buf(int bufnum, int port, int step, int fl, int ll)
-{
- buffer_pool_ctrl->ctrl = (BPC_WRITE
- | BPC_BUFFER(bufnum)
- | BPC_PORT(port)
- | BPC_STEP(step)
- | BPC_FIRST_LINE(fl)
- | BPC_LAST_LINE(ll));
-}
-#endif
-#endif
diff --git a/firmware/microblaze/lib/compiler.h b/firmware/microblaze/lib/compiler.h
index 4fa9b49f8..f677bdc3b 100644
--- a/firmware/microblaze/lib/compiler.h
+++ b/firmware/microblaze/lib/compiler.h
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2009 Ettus Research LLC
+ * Copyright 2009, 2010 Ettus Research LLC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -21,5 +21,6 @@
// FIXME gcc specific.
#define _AL4 __attribute__((aligned (4)))
+#define FORCE_INLINE inline __attribute__((always_inline))
#endif /* INCLUDED_COMPILER_H */
diff --git a/firmware/microblaze/lib/dbsm.c b/firmware/microblaze/lib/dbsm.c
deleted file mode 100644
index cee343eaa..000000000
--- a/firmware/microblaze/lib/dbsm.c
+++ /dev/null
@@ -1,299 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2007,2008 Free Software Foundation, Inc.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-/*
- * Double Buffering State Machine
- */
-
-#include "dbsm.h"
-#include "memory_map.h"
-#include "buffer_pool.h"
-#include <stdbool.h>
-#include "nonstdio.h"
-#include <stdlib.h>
-
-typedef enum {
- BS_EMPTY,
- BS_FILLING,
- BS_FULL,
- BS_EMPTYING,
-} buffer_state_t;
-
-static buffer_state_t buffer_state[NBUFFERS];
-
-bool
-dbsm_nop_inspector(dbsm_t *sm, int buf_this)
-{
- return false;
-}
-
-void
-dbsm_init(dbsm_t *sm, int buf0,
- const buf_cmd_args_t *recv, const buf_cmd_args_t *send,
- inspector_t inspect)
-{
- if (buf0 & 0x1) // must be even
- abort();
-
- sm->buf0 = buf0;
- sm->running = false;
- sm->recv_args = *recv;
- sm->send_args = *send;
-
- sm->rx_idle = true;
- sm->tx_idle = true;
-
- sm->inspect = inspect;
-
- // How much to adjust the last_line register.
- // It's 1 for everything but the ethernet.
- //sm->last_line_adj = recv->port == PORT_ETH ? 3 : 1;
- sm->last_line_adj = 1;
-
- buffer_state[sm->buf0] = BS_EMPTY;
- buffer_state[sm->buf0 ^ 1] = BS_EMPTY;
-
- sm->precomputed_receive_to_buf_ctrl_word[0] =
- (BPC_READ
- | BPC_BUFFER(sm->buf0)
- | BPC_PORT(sm->recv_args.port)
- | BPC_STEP(1)
- | BPC_FIRST_LINE(sm->recv_args.first_line)
- | BPC_LAST_LINE(sm->recv_args.last_line));
-
- sm->precomputed_receive_to_buf_ctrl_word[1] =
- (BPC_READ
- | BPC_BUFFER(sm->buf0 ^ 1)
- | BPC_PORT(sm->recv_args.port)
- | BPC_STEP(1)
- | BPC_FIRST_LINE(sm->recv_args.first_line)
- | BPC_LAST_LINE(sm->recv_args.last_line));
-
- sm->precomputed_send_from_buf_ctrl_word[0] =
- (BPC_WRITE
- | BPC_BUFFER(sm->buf0)
- | BPC_PORT(sm->send_args.port)
- | BPC_STEP(1)
- | BPC_FIRST_LINE(sm->send_args.first_line)
- | BPC_LAST_LINE(0)); // last line filled in at runtime
-
- sm->precomputed_send_from_buf_ctrl_word[1] =
- (BPC_WRITE
- | BPC_BUFFER(sm->buf0 ^ 1)
- | BPC_PORT(sm->send_args.port)
- | BPC_STEP(1)
- | BPC_FIRST_LINE(sm->send_args.first_line)
- | BPC_LAST_LINE(0)); // last line filled in at runtime
-
-}
-
-static inline void
-dbsm_receive_to_buf(dbsm_t *sm, int bufno)
-{
- buffer_pool_ctrl->ctrl = sm->precomputed_receive_to_buf_ctrl_word[bufno & 1];
-}
-
-static inline void
-dbsm_send_from_buf(dbsm_t *sm, int bufno)
-{
- buffer_pool_ctrl->ctrl =
- (sm->precomputed_send_from_buf_ctrl_word[bufno & 1]
- | BPC_LAST_LINE(buffer_pool_status->last_line[bufno] - sm->last_line_adj));
-}
-
-void
-dbsm_start(dbsm_t *sm)
-{
- // printf("dbsm_start: buf0 = %d, recv_port = %d\n", sm->buf0, sm->recv_args.port);
-
- sm->running = true;
-
- buffer_state[sm->buf0] = BS_EMPTY;
- buffer_state[sm->buf0 ^ 1] = BS_EMPTY;
-
- bp_clear_buf(sm->buf0);
- bp_clear_buf(sm->buf0 ^ 1);
-
- sm->tx_idle = true;
- sm->rx_idle = false;
- dbsm_receive_to_buf(sm, sm->buf0);
- buffer_state[sm->buf0] = BS_FILLING;
-
-}
-
-
-void
-dbsm_stop(dbsm_t *sm)
-{
- sm->running = false;
- bp_clear_buf(sm->buf0);
- bp_clear_buf(sm->buf0 ^ 1);
- buffer_state[sm->buf0] = BS_EMPTY;
- buffer_state[sm->buf0 ^ 1] = BS_EMPTY;
-}
-
-static void dbsm_process_helper(dbsm_t *sm, int buf_this);
-static void dbsm_error_helper(dbsm_t *sm, int buf_this);
-
-void
-dbsm_process_status(dbsm_t *sm, uint32_t status)
-{
- if (!sm->running)
- return;
-
- if (status & (BPS_ERROR(sm->buf0) | BPS_ERROR(sm->buf0 ^ 1))){
- putchar('E');
- // Most likely an ethernet Rx error. We just restart the transfer.
- if (status & (BPS_ERROR(sm->buf0)))
- dbsm_error_helper(sm, sm->buf0);
- //dbsm_process_helper(sm, sm->buf0); //forward errors
-
- if (status & (BPS_ERROR(sm->buf0 ^ 1)))
- dbsm_error_helper(sm, sm->buf0 ^ 1);
- //dbsm_process_helper(sm, sm->buf0 ^ 1); //forward errors
- }
-
- if (status & BPS_DONE(sm->buf0))
- dbsm_process_helper(sm, sm->buf0);
-
- if (status & BPS_DONE(sm->buf0 ^ 1))
- dbsm_process_helper(sm, sm->buf0 ^ 1);
-}
-
-static void
-dbsm_process_helper(dbsm_t *sm, int buf_this)
-{
- int buf_other = buf_this ^ 1;
-
- bp_clear_buf(buf_this);
-
- if (buffer_state[buf_this] == BS_FILLING){
- buffer_state[buf_this] = BS_FULL;
- //
- // does s/w handle this packet?
- //
- if (sm->inspect(sm, buf_this)){
- // s/w handled the packet; refill the buffer
- dbsm_receive_to_buf(sm, buf_this);
- buffer_state[buf_this] = BS_FILLING;
- }
-
- else { // s/w didn't handle this; pass it on
-
- if(buffer_state[buf_other] == BS_EMPTY){
- dbsm_receive_to_buf(sm, buf_other);
- buffer_state[buf_other] = BS_FILLING;
- }
- else
- sm->rx_idle = true;
-
- if (sm->tx_idle){
- sm->tx_idle = false;
- dbsm_send_from_buf(sm, buf_this);
- buffer_state[buf_this] = BS_EMPTYING;
- }
- }
- }
- else { // buffer was emptying
- buffer_state[buf_this] = BS_EMPTY;
- if (sm->rx_idle){
- sm->rx_idle = false;
- dbsm_receive_to_buf(sm, buf_this);
- buffer_state[buf_this] = BS_FILLING;
- }
- if (buffer_state[buf_other] == BS_FULL){
- dbsm_send_from_buf(sm, buf_other);
- buffer_state[buf_other] = BS_EMPTYING;
- }
- else
- sm->tx_idle = true;
- }
-}
-
-static void
-dbsm_error_helper(dbsm_t *sm, int buf_this)
-{
- bp_clear_buf(buf_this); // clears ERROR flag
-
- if (buffer_state[buf_this] == BS_FILLING){
- dbsm_receive_to_buf(sm, buf_this); // restart the xfer
- }
- else { // buffer was emptying
- dbsm_send_from_buf(sm, buf_this); // restart the xfer
- }
-}
-
-/*
- * Handle DSP Tx underrun
- */
-void
-dbsm_handle_tx_underrun(dbsm_t *sm)
-{
- // clear the DSP Tx state machine
- sr_tx_ctrl->clear_state = 1;
-
- // If there's a buffer that's empyting, clear it & flush xfer
-
- if (buffer_state[sm->buf0] == BS_EMPTYING){
- bp_clear_buf(sm->buf0);
- sr_tx_ctrl->clear_state = 1; // flush partial packet
- // drop frame in progress on ground. Pretend it finished
- dbsm_process_helper(sm, sm->buf0);
- }
- else if (buffer_state[sm->buf0 ^ 1] == BS_EMPTYING){
- bp_clear_buf(sm->buf0 ^ 1);
- sr_tx_ctrl->clear_state = 1; // flush partial packet
- // drop frame in progress on ground. Pretend it finished
- dbsm_process_helper(sm, sm->buf0 ^ 1);
- }
-}
-
-/*
- * Handle DSP Rx overrun
- */
-void
-dbsm_handle_rx_overrun(dbsm_t *sm)
-{
- sr_rx_ctrl->clear_overrun = 1;
-
- // If there's a buffer that's filling, clear it.
- // Any restart will be the job of the caller.
-
- if (buffer_state[sm->buf0] == BS_FILLING)
- bp_clear_buf(sm->buf0);
-
- if (buffer_state[sm->buf0 ^1] == BS_FILLING)
- bp_clear_buf(sm->buf0 ^ 1);
-}
-
-void
-dbsm_wait_for_opening(dbsm_t *sm)
-{
- if (buffer_state[sm->buf0] == BS_EMPTYING){
- // wait for xfer to complete
- int mask = BPS_DONE(sm->buf0) | BPS_ERROR(sm->buf0) | BPS_IDLE(sm->buf0);
- while ((buffer_pool_status->status & mask) == 0)
- ;
- }
- else if (buffer_state[sm->buf0 ^ 1] == BS_EMPTYING){
- // wait for xfer to complete
- int mask = BPS_DONE(sm->buf0 ^ 1) | BPS_ERROR(sm->buf0 ^ 1) | BPS_IDLE(sm->buf0 ^ 1);
- while ((buffer_pool_status->status & mask) == 0)
- ;
- }
-}
diff --git a/firmware/microblaze/lib/dbsm.h b/firmware/microblaze/lib/dbsm.h
deleted file mode 100644
index cb7e12fc3..000000000
--- a/firmware/microblaze/lib/dbsm.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2007 Free Software Foundation, Inc.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-#ifndef INCLUDED_DBSM_H
-#define INCLUDED_DBSM_H
-
-/*
- * Double Buffering State Machine
- */
-
-#include <stdint.h>
-#include <stdbool.h>
-
-struct _dbsm;
-typedef struct _dbsm dbsm_t;
-
-/*
- * pointer to function that does packet inspection.
- *
- * If one of these returns true, it means that the s/w
- * handled that packet, and that it should NOT be passed
- * on to the normal destination port.
- */
-typedef bool (*inspector_t)(dbsm_t *sm, int buf_this);
-
-bool dbsm_nop_inspector(dbsm_t *sm, int buf_this); // returns false
-
-
-typedef struct
-{
- uint16_t port;
- uint16_t first_line;
- uint16_t last_line;
-} buf_cmd_args_t;
-
-/*!
- * double buffer state machine
- */
-struct _dbsm
-{
- uint8_t buf0; // Must be even. This machine uses buf0 and buf0+1
- uint8_t running;
- uint8_t rx_idle;
- uint8_t tx_idle;
- buf_cmd_args_t recv_args;
- buf_cmd_args_t send_args;
- inspector_t inspect;
- uint32_t precomputed_receive_to_buf_ctrl_word[2];
- uint32_t precomputed_send_from_buf_ctrl_word[2];
- int last_line_adj;
-};
-
-void dbsm_init(dbsm_t *sm, int buf0,
- const buf_cmd_args_t *recv, const buf_cmd_args_t *send,
- inspector_t inspect);
-
-void dbsm_start(dbsm_t *sm);
-void dbsm_stop(dbsm_t *sm);
-void dbsm_process_status(dbsm_t *sm, uint32_t status);
-void dbsm_handle_tx_underrun(dbsm_t *sm);
-void dbsm_handle_rx_overrun(dbsm_t *sm);
-
-/*
- * The cpu calls this when it want to ensure that it can send a buffer
- * to the same destination being used by this state machine.
- *
- * If neither buffer is EMPTYING it returns immediately. If a buffer
- * is EMPYTING, it waits for the h/w to transition to the DONE or
- * ERROR state.
- *
- * When this function returns, the caller queues it's buffer and busy
- * waits for it to complete.
- */
-void dbsm_wait_for_opening(dbsm_t *sm);
-
-#endif /* INCLUDED_DBSM_H */
diff --git a/firmware/microblaze/lib/net_common.c b/firmware/microblaze/lib/net_common.c
index 6305408d6..1ff7ebde7 100644
--- a/firmware/microblaze/lib/net_common.c
+++ b/firmware/microblaze/lib/net_common.c
@@ -22,7 +22,6 @@
#include "net_common.h"
#include "banal.h"
#include <hal_io.h>
-#include <buffer_pool.h>
#include <memory_map.h>
#include <memcpy_wa.h>
#include <ethernet.h>
@@ -37,12 +36,6 @@
#include <ethertype.h>
#include <string.h>
-
-int cpu_tx_buf_dest_port = PORT_ETH;
-
-// If this is non-zero, this dbsm could be writing to the ethernet
-dbsm_t *ac_could_be_sending_to_eth;
-
static inline bool
ip_addr_eq(const struct ip_addr a, const struct ip_addr b)
{
@@ -130,8 +123,8 @@ send_pkt(eth_mac_addr_t dst, int ethertype,
// FIXME can this ever not be ready?
//hal_set_leds(LED_BUF_BUSY, LED_BUF_BUSY);
- while((buffer_pool_status->status & BPS_IDLE(CPU_TX_BUF)) == 0)
- ;
+ //FIXME while((buffer_pool_status->status & BPS_IDLE(CPU_TX_BUF)) == 0)
+ //FIXME ;
//hal_set_leds(0, LED_BUF_BUSY);
// Assemble the header
@@ -141,7 +134,7 @@ send_pkt(eth_mac_addr_t dst, int ethertype,
ehdr.src = _local_mac_addr;
ehdr.ethertype = ethertype;
- uint32_t *p = buffer_ram(CPU_TX_BUF);
+ uint32_t *p = 0;//FIXME buffer_ram(CPU_TX_BUF);
// Copy the pieces into the buffer
*p++ = 0x0; // slow path
@@ -173,31 +166,26 @@ send_pkt(eth_mac_addr_t dst, int ethertype,
p += len2/sizeof(uint32_t);
}
- size_t total_len = (p - buffer_ram(CPU_TX_BUF)) * sizeof(uint32_t);
+ size_t total_len = 0;//FIXME (p - buffer_ram(CPU_TX_BUF)) * sizeof(uint32_t);
if (total_len < 60) // ensure that we don't try to send a short packet
total_len = 60;
// wait until nobody else is sending to the ethernet
- if (ac_could_be_sending_to_eth){
+ //FIXME if (ac_could_be_sending_to_eth){
//hal_set_leds(LED_ETH_BUSY, LED_ETH_BUSY);
- dbsm_wait_for_opening(ac_could_be_sending_to_eth);
+ //FIXME dbsm_wait_for_opening(ac_could_be_sending_to_eth);
//hal_set_leds(0x0, LED_ETH_BUSY);
- }
+ //FIXME }
- if (0){
- printf("send_pkt to port %d, len = %d\n",
- cpu_tx_buf_dest_port, (int) total_len);
- print_buffer(buffer_ram(CPU_TX_BUF), total_len/4);
- }
// fire it off
- bp_send_from_buf(CPU_TX_BUF, cpu_tx_buf_dest_port, 1, 0, total_len/4);
+ //FIXME bp_send_from_buf(CPU_TX_BUF, cpu_tx_buf_dest_port, 1, 0, total_len/4);
// wait for it to complete (not long, it's a small pkt)
- while((buffer_pool_status->status & (BPS_DONE(CPU_TX_BUF) | BPS_ERROR(CPU_TX_BUF))) == 0)
- ;
+ //FIXME while((buffer_pool_status->status & (BPS_DONE(CPU_TX_BUF) | BPS_ERROR(CPU_TX_BUF))) == 0)
+ //FIXME ;
- bp_clear_buf(CPU_TX_BUF);
+ //FIXME bp_clear_buf(CPU_TX_BUF);
}
unsigned int
@@ -235,7 +223,7 @@ send_ip_pkt(struct ip_addr dst, int protocol,
bool found = arp_cache_lookup_mac(&ip.dest, &dst_mac);
if (!found){
printf("net_common: failed to hit cache looking for ");
- print_ip(ip.dest);
+ print_ip_addr(&ip.dest);
newline();
return;
}
diff --git a/firmware/microblaze/lib/net_common.h b/firmware/microblaze/lib/net_common.h
index 3040e5ef3..9d6a3e345 100644
--- a/firmware/microblaze/lib/net_common.h
+++ b/firmware/microblaze/lib/net_common.h
@@ -20,19 +20,9 @@
#include <stdint.h>
#include <stddef.h>
-#include <dbsm.h>
#include <net/socket_address.h>
#include <net/eth_mac_addr.h>
-#define CPU_TX_BUF 7 // cpu -> eth
-
-extern int cpu_tx_buf_dest_port;
-
-// If this is non-zero, this dbsm could be writing to the ethernet
-extern dbsm_t *ac_could_be_sending_to_eth;
-
-void stop_streaming(void);
-
typedef void (*udp_receiver_t)(struct socket_address src, struct socket_address dst,
unsigned char *payload, int payload_len);
diff --git a/firmware/microblaze/lib/nonstdio.h b/firmware/microblaze/lib/nonstdio.h
index 62ebfa46d..6aca7ed9a 100644
--- a/firmware/microblaze/lib/nonstdio.h
+++ b/firmware/microblaze/lib/nonstdio.h
@@ -45,4 +45,6 @@ void print_buffer(uint32_t *buf, size_t n);
//char *itoa(signed long value, char *result, int base);
//void reverse(char s[]);
+void print_ip_addr(const void *t);
+
#endif /* INCLUDED_NONSTDIO_H */
diff --git a/firmware/microblaze/lib/print_mac_addr.c b/firmware/microblaze/lib/print_addrs.c
index 475082325..29601c47c 100644
--- a/firmware/microblaze/lib/print_mac_addr.c
+++ b/firmware/microblaze/lib/print_addrs.c
@@ -26,3 +26,7 @@ print_mac_addr(const unsigned char addr[6])
}
}
+void print_ip_addr(const void *t){
+ uint8_t *p = (uint8_t *)t;
+ printf("%d.%d.%d.%d", p[0], p[1], p[2], p[3]);
+}
diff --git a/firmware/microblaze/lib/u2_init.c b/firmware/microblaze/lib/u2_init.c
index 4a553a713..2a6ae5a60 100644
--- a/firmware/microblaze/lib/u2_init.c
+++ b/firmware/microblaze/lib/u2_init.c
@@ -20,7 +20,6 @@
#include "spi.h"
#include "pic.h"
#include "hal_io.h"
-#include "buffer_pool.h"
#include "hal_uart.h"
#include "i2c.h"
#include "i2c_async.h"
@@ -63,10 +62,6 @@ u2_init(void)
i2c_register_handler(); //for using async I2C
hal_enable_ints();
- bp_init(); // buffer pool
-
-
-
// flash all leds to let us know board is alive
hal_set_leds(0x0, 0x1f);
mdelay(100);
diff --git a/firmware/microblaze/lib/usrp2_bytesex.h b/firmware/microblaze/lib/usrp2_bytesex.h
deleted file mode 100644
index 2b74f2a0b..000000000
--- a/firmware/microblaze/lib/usrp2_bytesex.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2007 Free Software Foundation, Inc.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-#ifndef INCLUDED_USRP2_BYTESEX_H
-#define INCLUDED_USRP2_BYTESEX_H
-
-// The USRP2 speaks big-endian...
-// Use the standard include files or provide substitutions for
-// htons and friends
-
-#if defined(HAVE_ARPA_INET_H)
-#include <arpa/inet.h>
-#elif defined(HAVE_NETINET_IN_H)
-#include <netinet/in.h>
-#else
-#include <stdint.h>
-
-#ifdef WORDS_BIGENDIAN // nothing to do...
-
-static inline uint32_t htonl(uint32_t x){ return x; }
-static inline uint16_t htons(uint16_t x){ return x; }
-static inline uint32_t ntohl(uint32_t x){ return x; }
-static inline uint16_t ntohs(uint16_t x){ return x; }
-
-#else
-
-#ifdef HAVE_BYTESWAP_H
-#include <byteswap.h>
-#else
-
-static inline uint16_t
-bswap_16 (uint16_t x)
-{
- return ((((x) >> 8) & 0xff) | (((x) & 0xff) << 8));
-}
-
-static inline uint32_t
-bswap_32 (uint32_t x)
-{
- return ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) \
- | (((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24));
-}
-#endif
-
-static inline uint32_t htonl(uint32_t x){ return bswap_32(x); }
-static inline uint16_t htons(uint16_t x){ return bswap_16(x); }
-static inline uint32_t ntohl(uint32_t x){ return bswap_32(x); }
-static inline uint16_t ntohs(uint16_t x){ return bswap_16(x); }
-
-#endif
-#endif
-#endif /* INCLUDED_USRP2_BYTESEX_H */
diff --git a/firmware/microblaze/lib/wb16550.h b/firmware/microblaze/lib/wb16550.h
deleted file mode 100644
index 7522f4438..000000000
--- a/firmware/microblaze/lib/wb16550.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/* -*- c -*- */
-/*
- * Copyright 2007 Free Software Foundation, Inc.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-
-// Wishbone National Semiconductor 16550A compatible UART
-
-#ifndef INCLUDED_WB16550_H
-#define INCLUDED_WB16550_H
-
-#include <stdint.h>
-
-typedef struct {
- volatile uint8_t data; // 0 r/w: r: rx fifo, w: tx fifo (if DLAB: LSB of divisor)
- volatile uint8_t ier; // 1 r/w: Interrupt Enable Register (if DLAB: MSB of divisor)
- volatile uint8_t iir_fcr; // 2 r/w: r: Interrupt ID Register,
- // w: Fifo Control Register
- volatile uint8_t lcr; // 3 r/w: Line Control Register
- volatile uint8_t mcr; // 4 w: Modem Control Register
- volatile uint8_t lsr; // 5 r: Line Status Register
- volatile uint8_t msr; // 6 r: Modem Status Register
-
-} wb16550_reg_t;
-
-#define UART_IER_RDI 0x01 // Enable received data interrupt
-#define UART_IER_THRI 0x02 // Enable transmitter holding reg empty int.
-#define UART_IER_RLSI 0x04 // Enable receiver line status interrupt
-#define UART_IER_MSI 0x08 // Enable modem status interrupt
-
-#define UART_IIR_NO_INT 0x01 // No interrupts pending
-#define UART_IIR_ID_MASK 0x06 // Mask for interrupt ID
-#define UART_IIR_MSI 0x00 // Modem status interrupt
-#define UART_IIR_THRI 0x02 // Tx holding register empty int
-#define UART_IIR_RDI 0x04 // Rx data available int
-#define UART_IIR_RLSI 0x06 // Receiver line status int
-
-#define UART_FCR_ENABLE_FIFO 0x01 // ignore, always enabled
-#define UART_FCR_CLEAR_RCVR 0x02 // Clear the RCVR FIFO
-#define UART_FCR_CLEAR_XMIT 0x04 // Clear the XMIT FIFO
-#define UART_FCR_TRIGGER_MASK 0xC0 // Mask for FIFO trigger range
-#define UART_FCR_TRIGGER_1 0x00 // Rx fifo trigger level: 1 byte
-#define UART_FCR_TRIGGER_4 0x40 // Rx fifo trigger level: 4 bytes
-#define UART_FCR_TRIGGER_8 0x80 // Rx fifo trigger level: 8 bytes
-#define UART_FCR_TRIGGER_14 0xC0 // Rx fifo trigger level: 14 bytes
-
-#define UART_LCR_DLAB 0x80 // Divisor latch access bit
-#define UART_LCR_SBC 0x40 // Set break control
-#define UART_LCR_SPAR 0x20 // Stick parity
-#define UART_LCR_EPAR 0x10 // Even parity select
-#define UART_LCR_PARITY 0x08 // Parity Enable
-#define UART_LCR_STOP 0x04 // Stop bits: 0=1 bit, 1=2 bits
-#define UART_LCR_WLEN5 0x00 // Wordlength: 5 bits
-#define UART_LCR_WLEN6 0x01 // Wordlength: 6 bits
-#define UART_LCR_WLEN7 0x02 // Wordlength: 7 bits
-#define UART_LCR_WLEN8 0x03 // Wordlength: 8 bits
-
-#define UART_MCR_LOOP 0x10 // Enable loopback test mode
-#define UART_MCR_OUT2n 0x08 // Out2 complement (loopback mode)
-#define UART_MCR_OUT1n 0x04 // Out1 complement (loopback mode)
-#define UART_MCR_RTSn 0x02 // RTS complement
-#define UART_MCR_DTRn 0x01 // DTR complement
-
-#define UART_LSR_TEMT 0x40 // Transmitter empty
-#define UART_LSR_THRE 0x20 // Transmit-hold-register empty
-#define UART_LSR_BI 0x10 // Break interrupt indicator
-#define UART_LSR_FE 0x08 // Frame error indicator
-#define UART_LSR_PE 0x04 // Parity error indicator
-#define UART_LSR_OE 0x02 // Overrun error indicator
-#define UART_LSR_DR 0x01 // Receiver data ready
-#define UART_LSR_BRK_ERROR_BITS 0x1E // BI, FE, PE, OE bits
-#define UART_LSR_ERROR 0x80 // At least 1 PE, FE or BI are in the fifo
-
-#define UART_MSR_DCD 0x80 // Data Carrier Detect
-#define UART_MSR_RI 0x40 // Ring Indicator
-#define UART_MSR_DSR 0x20 // Data Set Ready
-#define UART_MSR_CTS 0x10 // Clear to Send
-#define UART_MSR_DDCD 0x08 // Delta DCD
-#define UART_MSR_TERI 0x04 // Trailing edge ring indicator
-#define UART_MSR_DDSR 0x02 // Delta DSR
-#define UART_MSR_DCTS 0x01 // Delta CTS
-#define UART_MSR_ANY_DELTA 0x0F // Any of the delta bits!
-
-
-#endif // INCLUDED_WB16550_H