Commit 12645560 authored by Lucas Russo's avatar Lucas Russo

Merge branch 'emb-sw-devel' into ebone-hw-support

parents 93a05e95 889d4157
......@@ -92,7 +92,7 @@ include/board.h:
ln -sf ../boards/$(BOARD)/board.h include/board.h
clean:
rm -f $(OBJS) $(OUTPUT).elf $(OUTPUT).bin $(OUTPUT).ram $(OUTPUT)_disasm.S include/board.h
rm -f $(OBJS) $(OUTPUT).elf $(OUTPUT).bin $(OUTPUT).ram $(OUTPUT)_disasm.S $(OUTPUT).vhd include/board.h
make clean -C tools
%.o: %.c
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -11,16 +11,18 @@
#include <stdarg.h>
#include "pp-printf.h"
//void debug_print(const char *fmt, ...);
void debug_print(const char *fmt, ...);
//__attribute__((format(printf,1,2)));
void debug_print2(const char *fmt, const char *data, int len);
#ifdef DEBUG_PRINT
#define dbg_print(fmt, ...) \
pp_printf(fmt, ...)
pp_printf("%s (%d): "fmt, __FILE__, __LINE__, ##__VA_ARGS__)
#define dbg_print2(fmt, data, len) \
debug_print2(fmt, data, len)
debug_print2(fmt, data, len)
#else
#define dbg_print(const char *fmt, ...)
#define dbg_print(...)
#define dbg_print2(fmt, data, len)
#endif
......
#include "debug_print.h"
#include "pp-printf.h"
//void debug_print(const char *fmt, ...)
//{
// va_list l;
//
// va_start(l, fmt);
// pp_printf(fmt, l);
// va_end(l);
//}
void debug_print(const char *fmt, ...)
{
va_list l;
va_start(l, fmt);
pp_printf(fmt, l);
va_end(l);
}
void debug_print2(const char *fmt, const char *data, int len)
{
int i;
int i;
for (i = 0; i < len; ++i)
pp_printf(fmt, data[i]);
for (i = 0; i < len; ++i)
pp_printf(fmt, data[i]);
pp_printf("\n");
pp_printf("\n");
}
......@@ -5,100 +5,100 @@
static void oeth_rx(void)
{
volatile oeth_regs *regs;
regs = (oeth_regs *)(OETH_REG_BASE);
volatile oeth_bd *rx_bdp;
int pkt_len, i;
int bad = 0;
pp_printf("oeth_rx:\n");
rx_bdp = ((oeth_bd *)OETH_BD_BASE) + OETH_TXBD_NUM;
/* Find RX buffers marked as having received data */
for(i = 0; i < OETH_RXBD_NUM; i++)
{
pp_printf("> rxbd_num: %d\n", i);
bad=0;
/* Looking for buffer descriptors marked not empty */
if(!(rx_bdp[i].len_status & OETH_RX_BD_EMPTY)){
/* Check status for errors.
*/
pp_printf("> len_status: 0X%8X\n", rx_bdp[i].len_status);
if (rx_bdp[i].len_status & (OETH_RX_BD_TOOLONG | OETH_RX_BD_SHORT)) {
bad = 1;
pp_printf("> short!\n");
}
if (rx_bdp[i].len_status & OETH_RX_BD_DRIBBLE) {
bad = 1;
pp_printf("> dribble!\n");
}
if (rx_bdp[i].len_status & OETH_RX_BD_CRCERR) {
bad = 1;
pp_printf("> CRC error!\n");
}
if (rx_bdp[i].len_status & OETH_RX_BD_OVERRUN) {
bad = 1;
pp_printf("> overrun!\n");
}
if (rx_bdp[i].len_status & OETH_RX_BD_MISS) {
bad = 1;
pp_printf("> missed!\n");
}
if (rx_bdp[i].len_status & OETH_RX_BD_LATECOL) {
bad = 1;
pp_printf("> late collision!\n");
}
if (bad) {
rx_bdp[i].len_status &= ~OETH_RX_BD_STATS;
rx_bdp[i].len_status |= OETH_RX_BD_EMPTY;
}
else {
/*
* Process the incoming frame.
*/
unsigned char* buf = (unsigned char*)rx_bdp[i].addr;
pp_printf("> processing incoming packet\n");
pkt_len = rx_bdp[i].len_status >> 16;
pp_printf("> len_status: 0X%8X\n", rx_bdp[i].len_status);
pp_printf("> pkt_len_d: %d, pkt_len_h: 0X%08X\n", pkt_len, pkt_len);
user_recv(buf, pkt_len);
/* finish up */
rx_bdp[i].len_status &= ~OETH_RX_BD_STATS; /* Clear stats */
rx_bdp[i].len_status |= OETH_RX_BD_EMPTY; /* Mark RX BD as empty */
}
} else {
pp_printf("> empty!\n");
}
}
volatile oeth_regs *regs;
regs = (oeth_regs *)(OETH_REG_BASE);
volatile oeth_bd *rx_bdp;
int pkt_len, i;
int bad = 0;
dbg_print("oeth_rx:\n");
rx_bdp = ((oeth_bd *)OETH_BD_BASE) + OETH_TXBD_NUM;
/* Find RX buffers marked as having received data */
for(i = 0; i < OETH_RXBD_NUM; i++)
{
dbg_print("> rxbd_num: %d\n", i);
bad=0;
/* Looking for buffer descriptors marked not empty */
if(!(rx_bdp[i].len_status & OETH_RX_BD_EMPTY)){
/* Check status for errors.
*/
dbg_print("> len_status: 0X%8X\n", rx_bdp[i].len_status);
if (rx_bdp[i].len_status & (OETH_RX_BD_TOOLONG | OETH_RX_BD_SHORT)) {
bad = 1;
dbg_print("> short!\n");
}
if (rx_bdp[i].len_status & OETH_RX_BD_DRIBBLE) {
bad = 1;
dbg_print("> dribble!\n");
}
if (rx_bdp[i].len_status & OETH_RX_BD_CRCERR) {
bad = 1;
dbg_print("> CRC error!\n");
}
if (rx_bdp[i].len_status & OETH_RX_BD_OVERRUN) {
bad = 1;
dbg_print("> overrun!\n");
}
if (rx_bdp[i].len_status & OETH_RX_BD_MISS) {
bad = 1;
dbg_print("> missed!\n");
}
if (rx_bdp[i].len_status & OETH_RX_BD_LATECOL) {
bad = 1;
dbg_print("> late collision!\n");
}
if (bad) {
rx_bdp[i].len_status &= ~OETH_RX_BD_STATS;
rx_bdp[i].len_status |= OETH_RX_BD_EMPTY;
}
else {
/*
* Process the incoming frame.
*/
unsigned char* buf = (unsigned char*)rx_bdp[i].addr;
dbg_print("> processing incoming packet\n");
pkt_len = rx_bdp[i].len_status >> 16;
dbg_print("> len_status: 0X%8X\n", rx_bdp[i].len_status);
dbg_print("> pkt_len_d: %d, pkt_len_h: 0X%08X\n", pkt_len, pkt_len);
user_recv(buf, pkt_len);
/* finish up */
rx_bdp[i].len_status &= ~OETH_RX_BD_STATS; /* Clear stats */
rx_bdp[i].len_status |= OETH_RX_BD_EMPTY; /* Mark RX BD as empty */
}
} else {
dbg_print("> empty!\n");
}
}
}
static void oeth_tx(void)
{
volatile oeth_bd *tx_bd;
int i;
pp_printf("oeth_tx:\n");
tx_bd = (volatile oeth_bd *)OETH_BD_BASE; /* Search from beginning*/
/* Go through the TX buffs, search for one that was just sent */
for(i = 0; i < OETH_TXBD_NUM; i++)
{
/* Looking for buffer NOT ready for transmit. and IRQ enabled */
if( (!(tx_bd[i].len_status & (OETH_TX_BD_READY))) && (tx_bd[i].len_status & (OETH_TX_BD_IRQ)) )
{
/* Single threaded so no chance we have detected a buffer that has had its IRQ bit set but not its BD_READ flag. Maybe this won't work in linux */
tx_bd[i].len_status &= ~OETH_TX_BD_IRQ;
/* Probably good to check for TX errors here */
}
}
return;
volatile oeth_bd *tx_bd;
int i;
dbg_print("oeth_tx:\n");
tx_bd = (volatile oeth_bd *)OETH_BD_BASE; /* Search from beginning*/
/* Go through the TX buffs, search for one that was just sent */
for(i = 0; i < OETH_TXBD_NUM; i++)
{
/* Looking for buffer NOT ready for transmit. and IRQ enabled */
if( (!(tx_bd[i].len_status & (OETH_TX_BD_READY))) && (tx_bd[i].len_status & (OETH_TX_BD_IRQ)) )
{
/* Single threaded so no chance we have detected a buffer that has had its IRQ bit set but not its BD_READ flag. Maybe this won't work in linux */
tx_bd[i].len_status &= ~OETH_TX_BD_IRQ;
/* Probably good to check for TX errors here */
}
}
return;
}
/* The interrupt handler.
......@@ -106,52 +106,52 @@ static void oeth_tx(void)
void oeth_interrupt(void* arg)
{
volatile oeth_regs *regs;
regs = (oeth_regs *)(OETH_REG_BASE);
pp_printf("oeth_interrupt:\n");
uint int_events;
int serviced;
serviced = 0;
/* Get the interrupt events that caused us to be here.
*/
int_events = regs->int_src;
regs->int_src = int_events;
pp_printf("> int_events = 0x%8X\n", int_events);
/* Handle receive event in its own function.
*/
if (int_events & (OETH_INT_RXF | OETH_INT_RXE)) {
serviced |= 0x1;
pp_printf("> interrupt on rx line\n");
oeth_rx();
}
/* Handle transmit event in its own function.
*/
if (int_events & (OETH_INT_TXB | OETH_INT_TXE)) {
serviced |= 0x2;
pp_printf("> interrupt on tx line\n");
oeth_tx();
serviced |= 0x2;
}
/* Check for receive busy, i.e. packets coming but no place to
* put them.
*/
if (int_events & OETH_INT_BUSY) {
serviced |= 0x4;
pp_printf("> receive busy\n");
if (!(int_events & (OETH_INT_RXF | OETH_INT_RXE))) {
oeth_rx();
}
}
pp_printf("> nothing\n");
return;
volatile oeth_regs *regs;
regs = (oeth_regs *)(OETH_REG_BASE);
dbg_print("oeth_interrupt:\n");
uint int_events;
int serviced;
serviced = 0;
/* Get the interrupt events that caused us to be here.
*/
int_events = regs->int_src;
regs->int_src = int_events;
dbg_print("> int_events = 0x%8X\n", int_events);
/* Handle receive event in its own function.
*/
if (int_events & (OETH_INT_RXF | OETH_INT_RXE)) {
serviced |= 0x1;
dbg_print("> interrupt on rx line\n");
oeth_rx();
}
/* Handle transmit event in its own function.
*/
if (int_events & (OETH_INT_TXB | OETH_INT_TXE)) {
serviced |= 0x2;
dbg_print("> interrupt on tx line\n");
oeth_tx();
serviced |= 0x2;
}
/* Check for receive busy, i.e. packets coming but no place to
* put them.
*/
if (int_events & OETH_INT_BUSY) {
serviced |= 0x4;
dbg_print("> receive busy\n");
if (!(int_events & (OETH_INT_RXF | OETH_INT_RXE))) {
oeth_rx();
}
}
dbg_print("> nothing\n");
return;
}
This diff is collapsed.
......@@ -5,17 +5,17 @@
#endif
extern int pp_printf(const char *fmt, ...)
__attribute__((format(printf,1,2)));
__attribute__((format(printf,1,2)));
extern int pp_sprintf(char *s, const char *fmt, ...)
__attribute__((format(printf,2,3)));
__attribute__((format(printf,2,3)));
extern int pp_vprintf(const char *fmt, va_list args);
extern int pp_vprintf(const char *fmt, va_list args);
extern int pp_vsprintf(char *buf, const char *, va_list)
__attribute__ ((format (printf, 2, 0)));
__attribute__ ((format (printf, 2, 0)));
/* This is what we rely on for output */
extern int puts(const char *s);
/* This is what we rely on for output */
extern int puts(const char *s);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment