modified dbg() in several files
This commit is contained in:
@@ -39,7 +39,7 @@
|
|||||||
#error "unknown machine!"
|
#error "unknown machine!"
|
||||||
#endif /* MACHINE_FIREBEE */
|
#endif /* MACHINE_FIREBEE */
|
||||||
|
|
||||||
//#define DBG_DMA
|
#define DBG_DMA
|
||||||
#ifdef DBG_DMA
|
#ifdef DBG_DMA
|
||||||
#define dbg(format, arg...) do { xprintf("DEBUG: " format, ##arg); } while (0)
|
#define dbg(format, arg...) do { xprintf("DEBUG: " format, ##arg); } while (0)
|
||||||
#else
|
#else
|
||||||
@@ -596,11 +596,15 @@ int dma_interrupt_handler(void *arg1, void *arg2)
|
|||||||
void *dma_memcpy(void *dst, void *src, size_t n)
|
void *dma_memcpy(void *dst, void *src, size_t n)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
volatile int32_t time;
|
|
||||||
volatile int32_t start;
|
#ifdef DBG_DMA
|
||||||
volatile int32_t end;
|
int32_t time;
|
||||||
|
int32_t start;
|
||||||
|
int32_t end;
|
||||||
|
|
||||||
start = MCF_SLT0_SCNT;
|
start = MCF_SLT0_SCNT;
|
||||||
|
#endif /* DBG_DMA */
|
||||||
|
|
||||||
ret = MCD_startDma(1, src, 4, dst, 4, n, 4, DMA_ALWAYS, 0, MCD_SINGLE_DMA, 0);
|
ret = MCD_startDma(1, src, 4, dst, 4, n, 4, DMA_ALWAYS, 0, MCD_SINGLE_DMA, 0);
|
||||||
if (ret == MCD_OK)
|
if (ret == MCD_OK)
|
||||||
{
|
{
|
||||||
@@ -644,8 +648,10 @@ void *dma_memcpy(void *dst, void *src, size_t n)
|
|||||||
#endif
|
#endif
|
||||||
} while (ret != MCD_DONE);
|
} while (ret != MCD_DONE);
|
||||||
|
|
||||||
|
#ifdef DBG_DMA
|
||||||
end = MCF_SLT0_SCNT;
|
end = MCF_SLT0_SCNT;
|
||||||
time = (start - end) / (SYSCLK / 1000) / 1000;
|
time = (start - end) / (SYSCLK / 1000) / 1000;
|
||||||
|
#endif /* DBG_DMA */
|
||||||
dbg("%s: took %d ms (%f Mbytes/second)\r\n", __FUNCTION__, time, n / (float) time / 1000.0);
|
dbg("%s: took %d ms (%f Mbytes/second)\r\n", __FUNCTION__, time, n / (float) time / 1000.0);
|
||||||
|
|
||||||
return dst;
|
return dst;
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ extern char *strncat(char *dst, const char *src, size_t max);
|
|||||||
extern int atoi(const char *c);
|
extern int atoi(const char *c);
|
||||||
extern void *memcpy(void *dst, const void *src, size_t n);
|
extern void *memcpy(void *dst, const void *src, size_t n);
|
||||||
extern void *memset(void *s, int c, size_t n);
|
extern void *memset(void *s, int c, size_t n);
|
||||||
extern int memcmp(const char *s1, const char *s2, size_t max);
|
extern int memcmp(const void *s1, const void *s2, size_t max);
|
||||||
extern void bzero(void *s, size_t n);
|
extern void bzero(void *s, size_t n);
|
||||||
|
|
||||||
#define isdigit(c) (((c) >= '0') && ((c) <= '9'))
|
#define isdigit(c) (((c) >= '0') && ((c) <= '9'))
|
||||||
|
|||||||
@@ -9,7 +9,6 @@
|
|||||||
#ifndef _IP_H
|
#ifndef _IP_H
|
||||||
#define _IP_H
|
#define _IP_H
|
||||||
|
|
||||||
/********************************************************************/
|
|
||||||
|
|
||||||
/* 32-bit IP Addresses */
|
/* 32-bit IP Addresses */
|
||||||
typedef uint8_t IP_ADDR[4];
|
typedef uint8_t IP_ADDR[4];
|
||||||
@@ -57,7 +56,6 @@ typedef struct
|
|||||||
#define IP_HDR_OFFSET ETH_HDR_LEN
|
#define IP_HDR_OFFSET ETH_HDR_LEN
|
||||||
#define IP_HDR_SIZE 20 /* no options */
|
#define IP_HDR_SIZE 20 /* no options */
|
||||||
|
|
||||||
/********************************************************************/
|
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
@@ -71,7 +69,6 @@ typedef struct
|
|||||||
unsigned int err;
|
unsigned int err;
|
||||||
} IP_INFO;
|
} IP_INFO;
|
||||||
|
|
||||||
/********************************************************************/
|
|
||||||
|
|
||||||
extern void ip_handler(NIF *nif, NBUF *nbf);
|
extern void ip_handler(NIF *nif, NBUF *nbf);
|
||||||
uint16_t ip_chksum(uint16_t *data, int num);
|
uint16_t ip_chksum(uint16_t *data, int num);
|
||||||
|
|||||||
@@ -145,7 +145,7 @@ __extension__ \
|
|||||||
__extension__ \
|
__extension__ \
|
||||||
({__asm__ volatile ("lea -60(sp),sp\n\t" \
|
({__asm__ volatile ("lea -60(sp),sp\n\t" \
|
||||||
"movem.l d0-d7/a0-a6,(sp)"); \
|
"movem.l d0-d7/a0-a6,(sp)"); \
|
||||||
((void (*)(void))addr)(); \
|
((void (*) (void)) addr)(); \
|
||||||
__asm__ volatile ("movem.l (sp),d0-d7/a0-a6\n\t" \
|
__asm__ volatile ("movem.l (sp),d0-d7/a0-a6\n\t" \
|
||||||
"lea 60(sp),sp"); \
|
"lea 60(sp),sp"); \
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
|
|
||||||
#define DBG_BCM
|
#define DBG_BCM
|
||||||
#ifdef DBG_BCM
|
#ifdef DBG_BCM
|
||||||
#define dbg(format, arg...) do { xprintf("DEBUG: " format, ##arg); } while (0)
|
#define dbg(format, arg...) do { xprintf("DEBUG %s(): " format, __FUNCTION__, ##arg); } while (0)
|
||||||
#else
|
#else
|
||||||
#define dbg(format, arg...) do { ; } while (0)
|
#define dbg(format, arg...) do { ; } while (0)
|
||||||
#endif /* DBG_BCM */
|
#endif /* DBG_BCM */
|
||||||
@@ -55,7 +55,7 @@ int bcm5222_init(uint8_t fec_ch, uint8_t phy_addr, uint8_t speed, uint8_t duplex
|
|||||||
|
|
||||||
/* Initialize the MII interface */
|
/* Initialize the MII interface */
|
||||||
fec_mii_init(fec_ch, SYSCLK / 1000);
|
fec_mii_init(fec_ch, SYSCLK / 1000);
|
||||||
dbg("%s: PHY reset\r\n", __FUNCTION__);
|
dbg("PHY reset\r\n");
|
||||||
|
|
||||||
/* Reset the PHY */
|
/* Reset the PHY */
|
||||||
if (!fec_mii_write(fec_ch, phy_addr, BCM5222_CTRL, BCM5222_CTRL_RESET | BCM5222_CTRL_ANE))
|
if (!fec_mii_write(fec_ch, phy_addr, BCM5222_CTRL, BCM5222_CTRL_RESET | BCM5222_CTRL_ANE))
|
||||||
@@ -71,7 +71,7 @@ int bcm5222_init(uint8_t fec_ch, uint8_t phy_addr, uint8_t speed, uint8_t duplex
|
|||||||
if(timeout >= FEC_MII_TIMEOUT)
|
if(timeout >= FEC_MII_TIMEOUT)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
dbg("%s: PHY reset OK\r\n", __FUNCTION__);
|
dbg("PHY reset OK\r\n");
|
||||||
|
|
||||||
settings = (BCM5222_AN_ADV_NEXT_PAGE | BCM5222_AN_ADV_PAUSE);
|
settings = (BCM5222_AN_ADV_NEXT_PAGE | BCM5222_AN_ADV_PAUSE);
|
||||||
|
|
||||||
@@ -89,13 +89,13 @@ int bcm5222_init(uint8_t fec_ch, uint8_t phy_addr, uint8_t speed, uint8_t duplex
|
|||||||
if (!fec_mii_write(fec_ch, phy_addr, BCM5222_AN_ADV, settings))
|
if (!fec_mii_write(fec_ch, phy_addr, BCM5222_AN_ADV, settings))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
dbg("%s: PHY Enable Auto-Negotiation\r\n", __FUNCTION__);
|
dbg("PHY Enable Auto-Negotiation\r\n");
|
||||||
|
|
||||||
/* Enable Auto-Negotiation */
|
/* Enable Auto-Negotiation */
|
||||||
if (!fec_mii_write(fec_ch, phy_addr, BCM5222_CTRL, (BCM5222_CTRL_ANE | BCM5222_CTRL_RESTART_AN)))
|
if (!fec_mii_write(fec_ch, phy_addr, BCM5222_CTRL, (BCM5222_CTRL_ANE | BCM5222_CTRL_RESTART_AN)))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
dbg("%s: PHY Wait for auto-negotiation to complete\r\n", __FUNCTION__);
|
dbg("PHY Wait for auto-negotiation to complete\r\n");
|
||||||
|
|
||||||
/* Wait for auto-negotiation to complete */
|
/* Wait for auto-negotiation to complete */
|
||||||
for (timeout = 0; timeout < FEC_MII_TIMEOUT; timeout++)
|
for (timeout = 0; timeout < FEC_MII_TIMEOUT; timeout++)
|
||||||
@@ -108,7 +108,7 @@ int bcm5222_init(uint8_t fec_ch, uint8_t phy_addr, uint8_t speed, uint8_t duplex
|
|||||||
|
|
||||||
if (timeout < FEC_MII_TIMEOUT)
|
if (timeout < FEC_MII_TIMEOUT)
|
||||||
{
|
{
|
||||||
dbg("%s: PHY auto-negociation complete\r\n", __FUNCTION__);
|
dbg("PHY auto-negociation complete\r\n");
|
||||||
|
|
||||||
/* Read Auxiliary Control/Status Register */
|
/* Read Auxiliary Control/Status Register */
|
||||||
if (!fec_mii_read(fec_ch, phy_addr, BCM5222_ACSR, &settings))
|
if (!fec_mii_read(fec_ch, phy_addr, BCM5222_ACSR, &settings))
|
||||||
@@ -116,7 +116,7 @@ int bcm5222_init(uint8_t fec_ch, uint8_t phy_addr, uint8_t speed, uint8_t duplex
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dbg("%s: auto negotiation failed, PHY Set the default mode\r\n", __FUNCTION__);
|
dbg("auto negotiation failed, PHY Set the default mode\r\n");
|
||||||
|
|
||||||
/* Set the default mode (Full duplex, 100 Mbps) */
|
/* Set the default mode (Full duplex, 100 Mbps) */
|
||||||
if (!fec_mii_write(fec_ch, phy_addr, BCM5222_ACSR, settings = (BCM5222_ACSR_100BTX | BCM5222_ACSR_FDX)))
|
if (!fec_mii_write(fec_ch, phy_addr, BCM5222_ACSR, settings = (BCM5222_ACSR_100BTX | BCM5222_ACSR_FDX)))
|
||||||
@@ -129,17 +129,17 @@ int bcm5222_init(uint8_t fec_ch, uint8_t phy_addr, uint8_t speed, uint8_t duplex
|
|||||||
else
|
else
|
||||||
fec_duplex(fec_ch, FEC_MII_HALF_DUPLEX);
|
fec_duplex(fec_ch, FEC_MII_HALF_DUPLEX);
|
||||||
|
|
||||||
dbg("%s: PHY Mode: ", __FUNCTION__);
|
dbg("PHY Mode: ");
|
||||||
|
|
||||||
if (settings & BCM5222_ACSR_100BTX)
|
if (settings & BCM5222_ACSR_100BTX)
|
||||||
dbg("%s: 100Mbps\r\n", __FUNCTION__);
|
dbg("100Mbps\r\n");
|
||||||
else
|
else
|
||||||
dbg("%s: 10Mbps\r\n", __FUNCTION__);
|
dbg("10Mbps\r\n");
|
||||||
|
|
||||||
if (settings & BCM5222_ACSR_FDX)
|
if (settings & BCM5222_ACSR_FDX)
|
||||||
dbg("%s: Full-duplex\r\n", __FUNCTION__);
|
dbg("Full-duplex\r\n");
|
||||||
else
|
else
|
||||||
dbg("%s: Half-duplex\r\n", __FUNCTION__);
|
dbg("Half-duplex\r\n");
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,9 +11,9 @@
|
|||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include "bas_printf.h"
|
#include "bas_printf.h"
|
||||||
|
|
||||||
//#define DBG_BOOTP
|
#define DBG_BOOTP
|
||||||
#ifdef DBG_BOOTP
|
#ifdef DBG_BOOTP
|
||||||
#define dbg(format, arg...) do { xprintf("DEBUG: " format, ##arg); } while (0)
|
#define dbg(format, arg...) do { xprintf("DEBUG: %s(): " format, __FUNCTION__, ##arg); } while (0)
|
||||||
#else
|
#else
|
||||||
#define dbg(format, arg...) do { ; } while (0)
|
#define dbg(format, arg...) do { ; } while (0)
|
||||||
#endif /* DBG_BOOTP */
|
#endif /* DBG_BOOTP */
|
||||||
@@ -94,7 +94,7 @@ void bootp_handler(NIF *nif, NBUF *nbuf)
|
|||||||
struct bootp_packet *rx_p;
|
struct bootp_packet *rx_p;
|
||||||
udp_frame_hdr *udpframe;
|
udp_frame_hdr *udpframe;
|
||||||
|
|
||||||
dbg("%s\n", __FUNCTION__);
|
dbg("\r\n");
|
||||||
|
|
||||||
rx_p = (struct bootp_packet *) &nbuf->data[nbuf->offset];
|
rx_p = (struct bootp_packet *) &nbuf->data[nbuf->offset];
|
||||||
udpframe = (udp_frame_hdr *) &nbuf->data[nbuf->offset - UDP_HDR_SIZE];
|
udpframe = (udp_frame_hdr *) &nbuf->data[nbuf->offset - UDP_HDR_SIZE];
|
||||||
|
|||||||
@@ -32,9 +32,9 @@
|
|||||||
#error Unknown machine!
|
#error Unknown machine!
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//#define DBG_FEC
|
#define DBG_FEC
|
||||||
#ifdef DBG_FEC
|
#ifdef DBG_FEC
|
||||||
#define dbg(format, arg...) do { xprintf("DEBUG: " format, ##arg); } while (0)
|
#define dbg(format, arg...) do { xprintf("DEBUG: %s(): " format, __FUNCTION__, ##arg); } while (0)
|
||||||
#else
|
#else
|
||||||
#define dbg(format, arg...) do { ; } while (0)
|
#define dbg(format, arg...) do { ; } while (0)
|
||||||
#endif /* DBG_FEC */
|
#endif /* DBG_FEC */
|
||||||
@@ -237,33 +237,33 @@ void fec_log_init(uint8_t ch)
|
|||||||
*/
|
*/
|
||||||
void fec_log_dump(uint8_t ch)
|
void fec_log_dump(uint8_t ch)
|
||||||
{
|
{
|
||||||
dbg("%s: \r\n FEC%d Log\r\n", __FUNCTION__, ch);
|
dbg("\r\n FEC%d Log\r\n", __FUNCTION__, ch);
|
||||||
dbg("%s: ---------------\r\n", __FUNCTION__);
|
dbg(" ---------------\r\n", __FUNCTION__);
|
||||||
dbg("%s: Total: %4d\r\n", __FUNCTION__, fec_log[ch].total);
|
dbg(" Total: %4d\r\n", fec_log[ch].total);
|
||||||
dbg("%s: hberr: %4d\r\n", __FUNCTION__, fec_log[ch].hberr);
|
dbg(" hberr: %4d\r\n", fec_log[ch].hberr);
|
||||||
dbg("%s: babr: %4d\r\n", __FUNCTION__, fec_log[ch].babr);
|
dbg(" babr: %4d\r\n", fec_log[ch].babr);
|
||||||
dbg("%s: babt: %4d\r\n", __FUNCTION__, fec_log[ch].babt);
|
dbg(" babt: %4d\r\n", fec_log[ch].babt);
|
||||||
dbg("%s: gra: %4d\r\n", __FUNCTION__, fec_log[ch].gra);
|
dbg(" gra: %4d\r\n", fec_log[ch].gra);
|
||||||
dbg("%s: txf: %4d\r\n", __FUNCTION__, fec_log[ch].txf);
|
dbg(" txf: %4d\r\n", fec_log[ch].txf);
|
||||||
dbg("%s: mii: %4d\r\n", __FUNCTION__, fec_log[ch].mii);
|
dbg(" mii: %4d\r\n", fec_log[ch].mii);
|
||||||
dbg("%s: lc: %4d\r\n", __FUNCTION__, fec_log[ch].lc);
|
dbg(" lc: %4d\r\n", fec_log[ch].lc);
|
||||||
dbg("%s: rl: %4d\r\n", __FUNCTION__, fec_log[ch].rl);
|
dbg(" rl: %4d\r\n", fec_log[ch].rl);
|
||||||
dbg("%s: xfun: %4d\r\n", __FUNCTION__, fec_log[ch].xfun);
|
dbg(" xfun: %4d\r\n", fec_log[ch].xfun);
|
||||||
dbg("%s: xferr: %4d\r\n", __FUNCTION__, fec_log[ch].xferr);
|
dbg(" xferr: %4d\r\n", fec_log[ch].xferr);
|
||||||
dbg("%s: rferr: %4d\r\n", __FUNCTION__, fec_log[ch].rferr);
|
dbg(" rferr: %4d\r\n", fec_log[ch].rferr);
|
||||||
dbg("%s: dtxf: %4d\r\n", __FUNCTION__, fec_log[ch].dtxf);
|
dbg(" dtxf: %4d\r\n", fec_log[ch].dtxf);
|
||||||
dbg("%s: drxf: %4d\r\n", __FUNCTION__, fec_log[ch].drxf);
|
dbg(" drxf: %4d\r\n", fec_log[ch].drxf);
|
||||||
dbg("%s: \r\nRFSW:\r\n", __FUNCTION__);
|
dbg(" \r\nRFSW:\r\n");
|
||||||
dbg("%s: inv: %4d\r\n", __FUNCTION__, fec_log[ch].rfsw_inv);
|
dbg(" inv: %4d\r\n", fec_log[ch].rfsw_inv);
|
||||||
dbg("%s: m: %4d\r\n", __FUNCTION__, fec_log[ch].rfsw_m);
|
dbg(" m: %4d\r\n", fec_log[ch].rfsw_m);
|
||||||
dbg("%s: bc: %4d\r\n", __FUNCTION__, fec_log[ch].rfsw_bc);
|
dbg(" bc: %4d\r\n", fec_log[ch].rfsw_bc);
|
||||||
dbg("%s: mc: %4d\r\n", __FUNCTION__, fec_log[ch].rfsw_mc);
|
dbg(" mc: %4d\r\n", fec_log[ch].rfsw_mc);
|
||||||
dbg("%s: lg: %4d\r\n", __FUNCTION__, fec_log[ch].rfsw_lg);
|
dbg(" lg: %4d\r\n", fec_log[ch].rfsw_lg);
|
||||||
dbg("%s: no: %4d\r\n", __FUNCTION__, fec_log[ch].rfsw_no);
|
dbg(" no: %4d\r\n", fec_log[ch].rfsw_no);
|
||||||
dbg("%s: cr: %4d\r\n", __FUNCTION__, fec_log[ch].rfsw_cr);
|
dbg(" cr: %4d\r\n", fec_log[ch].rfsw_cr);
|
||||||
dbg("%s: ov: %4d\r\n", __FUNCTION__, fec_log[ch].rfsw_ov);
|
dbg(" ov: %4d\r\n", fec_log[ch].rfsw_ov);
|
||||||
dbg("%s: tr: %4d\r\n", __FUNCTION__, fec_log[ch].rfsw_tr);
|
dbg(" tr: %4d\r\n", fec_log[ch].rfsw_tr);
|
||||||
dbg("%s: ---------------\r\n\r\n", __FUNCTION__);
|
dbg(" ---------------\r\n\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -544,13 +544,13 @@ void fec_rx_start(uint8_t ch, int8_t *rxbd)
|
|||||||
* Make the initiator assignment
|
* Make the initiator assignment
|
||||||
*/
|
*/
|
||||||
res = dma_set_initiator(DMA_FEC_RX(ch));
|
res = dma_set_initiator(DMA_FEC_RX(ch));
|
||||||
dbg("%s: dma_set_initiator(DMA_FEC_RX(%d)): %d\r\n", __FUNCTION__, ch, res);
|
dbg("dma_set_initiator(DMA_FEC_RX(%d)): %d\r\n", ch, res);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Grab the initiator number
|
* Grab the initiator number
|
||||||
*/
|
*/
|
||||||
initiator = dma_get_initiator(DMA_FEC_RX(ch));
|
initiator = dma_get_initiator(DMA_FEC_RX(ch));
|
||||||
dbg("%s: dma_get_initiator(DMA_FEC_RX(%d)) = %d\r\n", __FUNCTION__, ch, initiator);
|
dbg("dma_get_initiator(DMA_FEC_RX(%d)) = %d\r\n", ch, initiator);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Determine the DMA channel running the task for the
|
* Determine the DMA channel running the task for the
|
||||||
@@ -558,7 +558,7 @@ void fec_rx_start(uint8_t ch, int8_t *rxbd)
|
|||||||
*/
|
*/
|
||||||
channel = dma_set_channel(DMA_FEC_RX(ch),
|
channel = dma_set_channel(DMA_FEC_RX(ch),
|
||||||
(ch == 0) ? fec0_rx_frame : fec1_rx_frame);
|
(ch == 0) ? fec0_rx_frame : fec1_rx_frame);
|
||||||
dbg("%s: DMA channel for FEC%1d: %d\r\n", __FUNCTION__, ch, channel);
|
dbg("DMA channel for FEC%1d: %d\r\n", ch, channel);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Start the Rx DMA task
|
* Start the Rx DMA task
|
||||||
@@ -583,7 +583,7 @@ void fec_rx_start(uint8_t ch, int8_t *rxbd)
|
|||||||
| MCD_NO_CSUM
|
| MCD_NO_CSUM
|
||||||
| MCD_NO_BYTE_SWAP
|
| MCD_NO_BYTE_SWAP
|
||||||
);
|
);
|
||||||
dbg("%s: Rx DMA task for FEC%1d started\r\n", __FUNCTION__, ch);
|
dbg("Rx DMA task for FEC%1d started\r\n", ch);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -607,13 +607,13 @@ void fec_rx_continue(uint8_t ch)
|
|||||||
*/
|
*/
|
||||||
channel = dma_get_channel(DMA_FEC_RX(ch));
|
channel = dma_get_channel(DMA_FEC_RX(ch));
|
||||||
|
|
||||||
dbg("%s: RX DMA channel for FEC%1d is %d\r\n", __FUNCTION__, ch, channel);
|
dbg("RX DMA channel for FEC%1d is %d\r\n", ch, channel);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Continue/restart the DMA task
|
* Continue/restart the DMA task
|
||||||
*/
|
*/
|
||||||
MCD_continDma(channel);
|
MCD_continDma(channel);
|
||||||
dbg("%s: RX dma on channel %d continued\r\n", __FUNCTION__, channel);
|
dbg("RX dma on channel %d continued\r\n", channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -671,7 +671,7 @@ void fec_rx_frame(uint8_t ch, NIF *nif)
|
|||||||
NBUF *cur_nbuf, *new_nbuf;
|
NBUF *cur_nbuf, *new_nbuf;
|
||||||
int keep;
|
int keep;
|
||||||
|
|
||||||
dbg("%s: started\r\n", __FUNCTION__);
|
dbg("started\r\n");
|
||||||
|
|
||||||
while ((pRxBD = fecbd_rx_alloc(ch)) != NULL)
|
while ((pRxBD = fecbd_rx_alloc(ch)) != NULL)
|
||||||
{
|
{
|
||||||
@@ -733,7 +733,7 @@ void fec_rx_frame(uint8_t ch, NIF *nif)
|
|||||||
new_nbuf = nbuf_alloc();
|
new_nbuf = nbuf_alloc();
|
||||||
if (new_nbuf == NULL)
|
if (new_nbuf == NULL)
|
||||||
{
|
{
|
||||||
dbg("%s: nbuf_alloc() failed\n", __FUNCTION__);
|
dbg("nbuf_alloc() failed\n");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Can't allocate a new network buffer, so we
|
* Can't allocate a new network buffer, so we
|
||||||
@@ -789,7 +789,7 @@ void fec_rx_frame(uint8_t ch, NIF *nif)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
nbuf_free(cur_nbuf);
|
nbuf_free(cur_nbuf);
|
||||||
dbg("%s: got unsupported packet %d, trashed it\r\n", __FUNCTION__, eth_hdr->type);
|
dbg("got unsupported packet %d, trashed it\r\n", eth_hdr->type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -853,13 +853,13 @@ void fec_tx_start(uint8_t ch, int8_t *txbd)
|
|||||||
* Make the initiator assignment
|
* Make the initiator assignment
|
||||||
*/
|
*/
|
||||||
res = dma_set_initiator(DMA_FEC_TX(ch));
|
res = dma_set_initiator(DMA_FEC_TX(ch));
|
||||||
dbg("%s: dma_set_initiator(%d) = %d\r\n", __FUNCTION__, ch, res);
|
dbg("dma_set_initiator(%d) = %d\r\n", ch, res);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Grab the initiator number
|
* Grab the initiator number
|
||||||
*/
|
*/
|
||||||
initiator = dma_get_initiator(DMA_FEC_TX(ch));
|
initiator = dma_get_initiator(DMA_FEC_TX(ch));
|
||||||
dbg("%s: dma_get_initiator(%d) = %d\r\n", __FUNCTION__, ch, initiator);
|
dbg("dma_get_initiator(%d) = %d\r\n", ch, initiator);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -868,7 +868,7 @@ void fec_tx_start(uint8_t ch, int8_t *txbd)
|
|||||||
*/
|
*/
|
||||||
channel = dma_set_channel(DMA_FEC_TX(ch),
|
channel = dma_set_channel(DMA_FEC_TX(ch),
|
||||||
(ch == 0) ? fec0_tx_frame : fec1_tx_frame);
|
(ch == 0) ? fec0_tx_frame : fec1_tx_frame);
|
||||||
dbg("%s: dma_set_channel(%d, ...) = %d\r\n", __FUNCTION__, ch, channel);
|
dbg("dma_set_channel(%d, ...) = %d\r\n", ch, channel);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Start the Tx DMA task
|
* Start the Tx DMA task
|
||||||
@@ -893,7 +893,7 @@ void fec_tx_start(uint8_t ch, int8_t *txbd)
|
|||||||
| MCD_NO_CSUM
|
| MCD_NO_CSUM
|
||||||
| MCD_NO_BYTE_SWAP
|
| MCD_NO_BYTE_SWAP
|
||||||
);
|
);
|
||||||
dbg("%s: DMA tx task started\r\n", __FUNCTION__);
|
dbg("DMA tx task started\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -916,14 +916,13 @@ void fec_tx_continue(uint8_t ch)
|
|||||||
* selected FEC
|
* selected FEC
|
||||||
*/
|
*/
|
||||||
channel = dma_get_channel(DMA_FEC_TX(ch));
|
channel = dma_get_channel(DMA_FEC_TX(ch));
|
||||||
dbg("%s: dma_get_channel(DMA_FEC_TX(%d)) = %d\r\n",
|
dbg("dma_get_channel(DMA_FEC_TX(%d)) = %d\r\n", ch, channel);
|
||||||
__FUNCTION__, ch, channel);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Continue/restart the DMA task
|
* Continue/restart the DMA task
|
||||||
*/
|
*/
|
||||||
MCD_continDma(channel);
|
MCD_continDma(channel);
|
||||||
dbg("%s: DMA TX task continue\r\n", __FUNCTION__);
|
dbg("DMA TX task continue\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -997,7 +996,7 @@ void fec_tx_frame(uint8_t ch)
|
|||||||
NBUF *pNbuf;
|
NBUF *pNbuf;
|
||||||
bool is_empty = true;
|
bool is_empty = true;
|
||||||
|
|
||||||
dbg("%s:\r\n", __FUNCTION__);
|
dbg("\r\n");
|
||||||
while ((pTxBD = fecbd_tx_free(ch)) != NULL)
|
while ((pTxBD = fecbd_tx_free(ch)) != NULL)
|
||||||
{
|
{
|
||||||
fec_log[ch].dtxf++;
|
fec_log[ch].dtxf++;
|
||||||
@@ -1011,7 +1010,7 @@ void fec_tx_frame(uint8_t ch)
|
|||||||
* Free up the network buffer that was just transmitted
|
* Free up the network buffer that was just transmitted
|
||||||
*/
|
*/
|
||||||
nbuf_free(pNbuf);
|
nbuf_free(pNbuf);
|
||||||
dbg("%s: free buffer %p from TX ring\r\n", __FUNCTION__, pNbuf);
|
dbg("free buffer %p from TX ring\r\n", pNbuf);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Re-initialize the Tx BD
|
* Re-initialize the Tx BD
|
||||||
@@ -1022,7 +1021,7 @@ void fec_tx_frame(uint8_t ch)
|
|||||||
|
|
||||||
}
|
}
|
||||||
if (is_empty)
|
if (is_empty)
|
||||||
dbg("%s: transmit queue was empty!\r\n", __FUNCTION__);
|
dbg("transmit queue was empty!\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void fec0_tx_frame(void)
|
void fec0_tx_frame(void)
|
||||||
@@ -1060,8 +1059,8 @@ int fec_send(uint8_t ch, NIF *nif, uint8_t *dst, uint8_t *src, uint16_t type, NB
|
|||||||
/* Check the length */
|
/* Check the length */
|
||||||
if ((nbuf->length + ETH_HDR_LEN) > ETH_MTU)
|
if ((nbuf->length + ETH_HDR_LEN) > ETH_MTU)
|
||||||
{
|
{
|
||||||
dbg("%s: nbuf->length (%d) + ETH_HDR_LEN (%d) exceeds ETH_MTU (%d)\r\n",
|
dbg("nbuf->length (%d) + ETH_HDR_LEN (%d) exceeds ETH_MTU (%d)\r\n",
|
||||||
__FUNCTION__, nbuf->length, ETH_HDR_LEN, ETH_MTU);
|
nbuf->length, ETH_HDR_LEN, ETH_MTU);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1193,7 +1192,7 @@ static void fec_irq_handler(uint8_t ch)
|
|||||||
event = eir & MCF_FEC_EIMR(ch);
|
event = eir & MCF_FEC_EIMR(ch);
|
||||||
|
|
||||||
if (event != eir)
|
if (event != eir)
|
||||||
dbg("%s: pending but not enabled: 0x%08x\r\n", __FUNCTION__, (event ^ eir));
|
dbg("pending but not enabled: 0x%08x\r\n", (event ^ eir));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Clear the event(s) in the EIR immediately
|
* Clear the event(s) in the EIR immediately
|
||||||
@@ -1204,8 +1203,8 @@ static void fec_irq_handler(uint8_t ch)
|
|||||||
{
|
{
|
||||||
fec_log[ch].total++;
|
fec_log[ch].total++;
|
||||||
fec_log[ch].rferr++;
|
fec_log[ch].rferr++;
|
||||||
dbg("%s: RFERR\r\n", __FUNCTION__);
|
dbg("RFERR\r\n");
|
||||||
dbg("%s: FECRFSR%d = 0x%08x\r\n", __FUNCTION__, ch, MCF_FEC_FECRFSR(ch));
|
dbg("FECRFSR%d = 0x%08x\r\n", ch, MCF_FEC_FECRFSR(ch));
|
||||||
//fec_eth_stop(ch);
|
//fec_eth_stop(ch);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1213,14 +1212,14 @@ static void fec_irq_handler(uint8_t ch)
|
|||||||
{
|
{
|
||||||
fec_log[ch].total++;
|
fec_log[ch].total++;
|
||||||
fec_log[ch].xferr++;
|
fec_log[ch].xferr++;
|
||||||
dbg("%s: XFERR\r\n", __FUNCTION__);
|
dbg("XFERR\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event & MCF_FEC_EIR_XFUN)
|
if (event & MCF_FEC_EIR_XFUN)
|
||||||
{
|
{
|
||||||
fec_log[ch].total++;
|
fec_log[ch].total++;
|
||||||
fec_log[ch].xfun++;
|
fec_log[ch].xfun++;
|
||||||
dbg("%s: XFUN\r\n", __FUNCTION__);
|
dbg("XFUN\r\n");
|
||||||
//fec_eth_stop(ch);
|
//fec_eth_stop(ch);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1228,54 +1227,54 @@ static void fec_irq_handler(uint8_t ch)
|
|||||||
{
|
{
|
||||||
fec_log[ch].total++;
|
fec_log[ch].total++;
|
||||||
fec_log[ch].rl++;
|
fec_log[ch].rl++;
|
||||||
dbg("%s: RL\r\n", __FUNCTION__);
|
dbg("RL\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event & MCF_FEC_EIR_LC)
|
if (event & MCF_FEC_EIR_LC)
|
||||||
{
|
{
|
||||||
fec_log[ch].total++;
|
fec_log[ch].total++;
|
||||||
fec_log[ch].lc++;
|
fec_log[ch].lc++;
|
||||||
dbg("%s: LC\r\n", __FUNCTION__);
|
dbg("LC\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event & MCF_FEC_EIR_MII)
|
if (event & MCF_FEC_EIR_MII)
|
||||||
{
|
{
|
||||||
fec_log[ch].mii++;
|
fec_log[ch].mii++;
|
||||||
dbg("%s: MII\r\n", __FUNCTION__);
|
dbg("MII\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event & MCF_FEC_EIR_TXF)
|
if (event & MCF_FEC_EIR_TXF)
|
||||||
{
|
{
|
||||||
fec_log[ch].txf++;
|
fec_log[ch].txf++;
|
||||||
dbg("%s: TXF\r\n", __FUNCTION__);
|
dbg("TXF\r\n");
|
||||||
fec_log_dump(0);
|
fec_log_dump(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event & MCF_FEC_EIR_GRA)
|
if (event & MCF_FEC_EIR_GRA)
|
||||||
{
|
{
|
||||||
fec_log[ch].gra++;
|
fec_log[ch].gra++;
|
||||||
dbg("%s: GRA\r\n", __FUNCTION__);
|
dbg("GRA\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event & MCF_FEC_EIR_BABT)
|
if (event & MCF_FEC_EIR_BABT)
|
||||||
{
|
{
|
||||||
fec_log[ch].total++;
|
fec_log[ch].total++;
|
||||||
fec_log[ch].babt++;
|
fec_log[ch].babt++;
|
||||||
dbg("%s: BABT\r\n", __FUNCTION__);
|
dbg("BABT\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event & MCF_FEC_EIR_BABR)
|
if (event & MCF_FEC_EIR_BABR)
|
||||||
{
|
{
|
||||||
fec_log[ch].total++;
|
fec_log[ch].total++;
|
||||||
fec_log[ch].babr++;
|
fec_log[ch].babr++;
|
||||||
dbg("%s: BABR\r\n", __FUNCTION__);
|
dbg("BABR\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event & MCF_FEC_EIR_HBERR)
|
if (event & MCF_FEC_EIR_HBERR)
|
||||||
{
|
{
|
||||||
fec_log[ch].total++;
|
fec_log[ch].total++;
|
||||||
fec_log[ch].hberr++;
|
fec_log[ch].hberr++;
|
||||||
dbg("%s: HBERR\r\n", __FUNCTION__);
|
dbg("HBERR\r\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1345,9 +1344,9 @@ void fec_eth_setup(uint8_t ch, uint8_t trcvr, uint8_t speed, uint8_t duplex, con
|
|||||||
*/
|
*/
|
||||||
#if defined(MACHINE_FIREBEE)
|
#if defined(MACHINE_FIREBEE)
|
||||||
if (am79c874_init(0, 0, speed, duplex))
|
if (am79c874_init(0, 0, speed, duplex))
|
||||||
dbg("%s: PHY init completed\r\n", __FUNCTION__);
|
dbg("PHY init completed\r\n");
|
||||||
else
|
else
|
||||||
dbg("%s: PHY init failed\r\n", __FUNCTION__);
|
dbg("PHY init failed\r\n");
|
||||||
#elif defined(MACHINE_M548X)
|
#elif defined(MACHINE_M548X)
|
||||||
bcm_5222_init(0, 0, speed, duplex);
|
bcm_5222_init(0, 0, speed, duplex);
|
||||||
#else
|
#else
|
||||||
@@ -1400,7 +1399,7 @@ void fec_eth_stop(uint8_t ch)
|
|||||||
*/
|
*/
|
||||||
level = set_ipl(7);
|
level = set_ipl(7);
|
||||||
|
|
||||||
dbg("%s: fec %d stopped\r\n", __FUNCTION__, ch);
|
dbg("fec %d stopped\r\n", ch);
|
||||||
/*
|
/*
|
||||||
* Gracefully disable the receiver and transmitter
|
* Gracefully disable the receiver and transmitter
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
#include "bas_printf.h"
|
#include "bas_printf.h"
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
//#define DBG_FECBD
|
#define DBG_FECBD
|
||||||
#ifdef DBG_FECBD
|
#ifdef DBG_FECBD
|
||||||
#define dbg(format, arg...) do { xprintf("DEBUG: " format, ##arg); } while (0)
|
#define dbg(format, arg...) do { xprintf("DEBUG: " format, ##arg); } while (0)
|
||||||
#else
|
#else
|
||||||
@@ -31,14 +31,14 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
FECBD unaligned_bds[(2 * NRXBD) + (2 * NTXBD) + 1];
|
static FECBD unaligned_bds[(2 * NRXBD) + (2 * NTXBD) + 1];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* These pointers are used to reference into the chunck of data set
|
* These pointers are used to reference into the chunck of data set
|
||||||
* aside for buffer descriptors
|
* aside for buffer descriptors
|
||||||
*/
|
*/
|
||||||
FECBD *RxBD;
|
static FECBD *RxBD;
|
||||||
FECBD *TxBD;
|
static FECBD *TxBD;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Macros to easier access to the BD ring
|
* Macros to easier access to the BD ring
|
||||||
@@ -65,7 +65,7 @@ void fecbd_init(uint8_t ch)
|
|||||||
NBUF *nbuf;
|
NBUF *nbuf;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
dbg("%s:\r\n", __FUNCTION__);
|
dbg("\r\n");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Align Buffer Descriptors to 4-byte boundary
|
* Align Buffer Descriptors to 4-byte boundary
|
||||||
@@ -73,7 +73,7 @@ void fecbd_init(uint8_t ch)
|
|||||||
RxBD = (FECBD *)(((int) unaligned_bds + 3) & 0xFFFFFFFC);
|
RxBD = (FECBD *)(((int) unaligned_bds + 3) & 0xFFFFFFFC);
|
||||||
TxBD = (FECBD *)((int) RxBD + (sizeof(FECBD) * 2 * NRXBD));
|
TxBD = (FECBD *)((int) RxBD + (sizeof(FECBD) * 2 * NRXBD));
|
||||||
|
|
||||||
dbg("%s: initialise RX buffer descriptor ring\r\n", __FUNCTION__);
|
dbg("initialise RX buffer descriptor ring\r\n");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initialize the Rx Buffer Descriptor ring
|
* Initialize the Rx Buffer Descriptor ring
|
||||||
@@ -84,7 +84,7 @@ void fecbd_init(uint8_t ch)
|
|||||||
nbuf = nbuf_alloc();
|
nbuf = nbuf_alloc();
|
||||||
if (nbuf == NULL)
|
if (nbuf == NULL)
|
||||||
{
|
{
|
||||||
dbg("%s: could not allocate network buffer\r\n", __FUNCTION__);
|
dbg("could not allocate network buffer\r\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,7 +102,7 @@ void fecbd_init(uint8_t ch)
|
|||||||
*/
|
*/
|
||||||
RxBD(ch, i - 1).status |= RX_BD_W;
|
RxBD(ch, i - 1).status |= RX_BD_W;
|
||||||
|
|
||||||
dbg("%s: initialise TX buffer descriptor ring\r\n", __FUNCTION__);
|
dbg("initialise TX buffer descriptor ring\r\n");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initialize the Tx Buffer Descriptor ring
|
* Initialize the Tx Buffer Descriptor ring
|
||||||
|
|||||||
@@ -7,13 +7,15 @@
|
|||||||
* Modifications:
|
* Modifications:
|
||||||
*/
|
*/
|
||||||
#include "net.h"
|
#include "net.h"
|
||||||
|
#include "bas_printf.h"
|
||||||
|
#include "bas_string.h"
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
|
|
||||||
//#define IP_DEBUG
|
#define IP_DEBUG
|
||||||
#if defined(IP_DEBUG)
|
#if defined(IP_DEBUG)
|
||||||
#define dbg(format, arg...) do { xprintf("DEBUG: " format, ##arg); } while (0)
|
#define dbg(format, arg...) do { xprintf("DEBUG: %s(): " format, __FUNCTION__, ##arg); } while (0)
|
||||||
#else
|
#else
|
||||||
#define dbg(format, arg...) do { ; } while (0)
|
#define dbg(format, arg...) do { ; } while (0)
|
||||||
#endif
|
#endif
|
||||||
@@ -42,7 +44,7 @@ uint8_t *ip_get_myip(IP_INFO *info)
|
|||||||
{
|
{
|
||||||
return (uint8_t *) &info->myip[0];
|
return (uint8_t *) &info->myip[0];
|
||||||
}
|
}
|
||||||
dbg("%s: info is NULL!\n\t", __FUNCTION__);
|
dbg("info is NULL!\n\t");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,9 +74,9 @@ uint8_t *ip_resolve_route(NIF *nif, IP_ADDR_P destip)
|
|||||||
|
|
||||||
info = nif_get_protocol_info(nif, ETH_FRM_IP);
|
info = nif_get_protocol_info(nif, ETH_FRM_IP);
|
||||||
|
|
||||||
if (memcmp(destip, bc) == 0)
|
if (memcmp(destip, bc, 4) == 0)
|
||||||
{
|
{
|
||||||
dbg("%s: destip is broadcast address, no gateway needed\r\n", __FUNCTION__);
|
dbg("destip is broadcast address, no gateway needed\r\n");
|
||||||
return destip;
|
return destip;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -168,7 +170,7 @@ int ip_send(NIF *nif, uint8_t *dest, uint8_t *src, uint8_t protocol, NBUF *pNbuf
|
|||||||
route = ip_resolve_route(nif, dest);
|
route = ip_resolve_route(nif, dest);
|
||||||
if (route == NULL)
|
if (route == NULL)
|
||||||
{
|
{
|
||||||
dbg("%s: Unable to locate %d.%d.%d.%d\r\n", __FUNCTION__,
|
dbg("Unable to locate %d.%d.%d.%d\r\n",
|
||||||
dest[0], dest[1], dest[2], dest[3]);
|
dest[0], dest[1], dest[2], dest[3]);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -176,9 +178,9 @@ int ip_send(NIF *nif, uint8_t *dest, uint8_t *src, uint8_t protocol, NBUF *pNbuf
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
route = bc;
|
route = bc;
|
||||||
dbg("%s: route = broadcast\r\n", __FUNCTION__);
|
dbg("route = broadcast\r\n");
|
||||||
dbg("%s: nif = %p\r\n", __FUNCTION__, nif);
|
dbg("nif = %p\r\n", nif);
|
||||||
dbg("%s: nif->send = %p\r\n", __FUNCTION__, nif->send);
|
dbg("nif->send = %p\r\n", nif->send);
|
||||||
}
|
}
|
||||||
|
|
||||||
return nif->send(nif, route, &nif->hwa[0], ETH_FRM_IP, pNbuf);
|
return nif->send(nif, route, &nif->hwa[0], ETH_FRM_IP, pNbuf);
|
||||||
@@ -280,7 +282,7 @@ void ip_handler(NIF *nif, NBUF *pNbuf)
|
|||||||
*/
|
*/
|
||||||
ip_frame_hdr *ipframe;
|
ip_frame_hdr *ipframe;
|
||||||
|
|
||||||
dbg("%s: packet received\r\n", __FUNCTION__);
|
dbg("packet received\r\n");
|
||||||
|
|
||||||
ipframe = (ip_frame_hdr *) &pNbuf->data[pNbuf->offset];
|
ipframe = (ip_frame_hdr *) &pNbuf->data[pNbuf->offset];
|
||||||
|
|
||||||
@@ -289,7 +291,7 @@ void ip_handler(NIF *nif, NBUF *pNbuf)
|
|||||||
*/
|
*/
|
||||||
if (!validate_ip_hdr(nif, ipframe))
|
if (!validate_ip_hdr(nif, ipframe))
|
||||||
{
|
{
|
||||||
dbg("%s: not a valid IP packet!\r\n", __FUNCTION__);
|
dbg("not a valid IP packet!\r\n");
|
||||||
|
|
||||||
nbuf_free(pNbuf);
|
nbuf_free(pNbuf);
|
||||||
return;
|
return;
|
||||||
@@ -310,7 +312,7 @@ void ip_handler(NIF *nif, NBUF *pNbuf)
|
|||||||
udp_handler(nif,pNbuf);
|
udp_handler(nif,pNbuf);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
dbg("%s: no protocol handler registered for protocol %d\r\n",
|
dbg("no protocol handler registered for protocol %d\r\n",
|
||||||
__FUNCTION__, IP_PROTOCOL(ipframe));
|
__FUNCTION__, IP_PROTOCOL(ipframe));
|
||||||
nbuf_free(pNbuf);
|
nbuf_free(pNbuf);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -48,6 +48,7 @@
|
|||||||
#include "bootp.h"
|
#include "bootp.h"
|
||||||
#include "interrupts.h"
|
#include "interrupts.h"
|
||||||
#include "exceptions.h"
|
#include "exceptions.h"
|
||||||
|
#include "net_timer.h"
|
||||||
|
|
||||||
//#define BAS_DEBUG
|
//#define BAS_DEBUG
|
||||||
#if defined(BAS_DEBUG)
|
#if defined(BAS_DEBUG)
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ static int usb_mouse_probe(struct usb_device *dev, unsigned int ifnum);
|
|||||||
int usb_mouse_deregister(struct usb_device *dev)
|
int usb_mouse_deregister(struct usb_device *dev)
|
||||||
{
|
{
|
||||||
dev->irq_handle = NULL;
|
dev->irq_handle = NULL;
|
||||||
if(new != NULL)
|
if (new != NULL)
|
||||||
{
|
{
|
||||||
driver_mem_free(new);
|
driver_mem_free(new);
|
||||||
new = NULL;
|
new = NULL;
|
||||||
@@ -61,8 +61,9 @@ int usb_mouse_deregister(struct usb_device *dev)
|
|||||||
/* registering the mouse */
|
/* registering the mouse */
|
||||||
int usb_mouse_register(struct usb_device *dev)
|
int usb_mouse_register(struct usb_device *dev)
|
||||||
{
|
{
|
||||||
if(!mouse_installed && (dev->devnum != -1) && (usb_mouse_probe(dev, 0) == 1))
|
if (!mouse_installed && (dev->devnum != -1) && (usb_mouse_probe(dev, 0) == 1))
|
||||||
{ /* Ok, we found a mouse */
|
{
|
||||||
|
/* Ok, we found a mouse */
|
||||||
mse_printf("USB MOUSE found (USB: %d, devnum: %d)\r\n", dev->usbnum, dev->devnum);
|
mse_printf("USB MOUSE found (USB: %d, devnum: %d)\r\n", dev->usbnum, dev->devnum);
|
||||||
mouse_installed = 1;
|
mouse_installed = 1;
|
||||||
dev->deregister = usb_mouse_deregister;
|
dev->deregister = usb_mouse_deregister;
|
||||||
@@ -76,12 +77,12 @@ int usb_mouse_register(struct usb_device *dev)
|
|||||||
int drv_usb_mouse_init(void)
|
int drv_usb_mouse_init(void)
|
||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
if(mouse_installed)
|
if (mouse_installed)
|
||||||
return -1;
|
return -1;
|
||||||
/* scan all USB Devices */
|
/* scan all USB Devices */
|
||||||
for(j = 0; j < USB_MAX_BUS; j++)
|
for (j = 0; j < USB_MAX_BUS; j++)
|
||||||
{
|
{
|
||||||
for(i = 0; i < USB_MAX_DEVICE; i++)
|
for (i = 0; i < USB_MAX_DEVICE; i++)
|
||||||
{
|
{
|
||||||
struct usb_device *dev = usb_get_dev_index(i, j); /* get device */
|
struct usb_device *dev = usb_get_dev_index(i, j); /* get device */
|
||||||
if (dev == NULL)
|
if (dev == NULL)
|
||||||
@@ -109,27 +110,27 @@ static int usb_mouse_irq(struct usb_device *dev)
|
|||||||
int level;
|
int level;
|
||||||
#endif
|
#endif
|
||||||
int i, change = 0;
|
int i, change = 0;
|
||||||
if((dev->irq_status != 0) || (dev->irq_act_len < 3) || (dev->irq_act_len > 8))
|
if ((dev->irq_status != 0) || (dev->irq_act_len < 3) || (dev->irq_act_len > 8))
|
||||||
{
|
{
|
||||||
mse_printf("USB MOUSE error %lX, len %d\r\n", dev->irq_status, dev->irq_act_len);
|
mse_printf("USB MOUSE error %lX, len %d\r\n", dev->irq_status, dev->irq_act_len);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
for(i = 0; i < dev->irq_act_len; i++)
|
for (i = 0; i < dev->irq_act_len; i++)
|
||||||
{
|
{
|
||||||
if(new[i] != old[i])
|
if (new[i] != old[i])
|
||||||
{
|
{
|
||||||
change = 1;
|
change = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(change)
|
if (change)
|
||||||
{
|
{
|
||||||
char wheel = 0, buttons, old_buttons;
|
char wheel = 0, buttons, old_buttons;
|
||||||
mse_printf("USB MOUSE len:%d %02X %02X %02X %02X %02X %02X\r\n", dev->irq_act_len, new[0], new[1], new[2], new[3], new[4], new[5]);
|
mse_printf("USB MOUSE len:%d %02X %02X %02X %02X %02X %02X\r\n", dev->irq_act_len, new[0], new[1], new[2], new[3], new[4], new[5]);
|
||||||
#ifdef CONFIG_USB_INTERRUPT_POLLING
|
#ifdef CONFIG_USB_INTERRUPT_POLLING
|
||||||
level = set_ipl(7); /* mask interrupts */
|
level = set_ipl(7); /* mask interrupts */
|
||||||
#endif
|
#endif
|
||||||
if((dev->irq_act_len >= 6) && (new[0] == 1)) /* report-ID */
|
if ((dev->irq_act_len >= 6) && (new[0] == 1)) /* report-ID */
|
||||||
{
|
{
|
||||||
buttons = new[1];
|
buttons = new[1];
|
||||||
old_buttons = old[1];
|
old_buttons = old[1];
|
||||||
@@ -143,24 +144,24 @@ static int usb_mouse_irq(struct usb_device *dev)
|
|||||||
buttons = new[0];
|
buttons = new[0];
|
||||||
old_buttons = old[0];
|
old_buttons = old[0];
|
||||||
new[0] = ((new[0] & 1) << 1) + ((new[0] & 2) >> 1) + 0xF8;
|
new[0] = ((new[0] & 1) << 1) + ((new[0] & 2) >> 1) + 0xF8;
|
||||||
if(dev->irq_act_len >= 3)
|
if (dev->irq_act_len >= 3)
|
||||||
wheel = new[3];
|
wheel = new[3];
|
||||||
}
|
}
|
||||||
if((buttons ^ old_buttons) & 4) /* 3rd button */
|
if ((buttons ^ old_buttons) & 4) /* 3rd button */
|
||||||
{
|
{
|
||||||
if(buttons & 4)
|
if (buttons & 4)
|
||||||
{
|
{
|
||||||
usb_kbd_send_code(0x72); /* ENTER */
|
usb_kbd_send_code(0x72); /* ENTER */
|
||||||
usb_kbd_send_code(0xF2);
|
usb_kbd_send_code(0xF2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(wheel != 0) /* actually like Eiffel */
|
if (wheel != 0) /* actually like Eiffel */
|
||||||
{
|
{
|
||||||
#define REPEAT_WHEEL 3
|
#define REPEAT_WHEEL 3
|
||||||
int i;
|
int i;
|
||||||
if(wheel > 0)
|
if (wheel > 0)
|
||||||
{
|
{
|
||||||
for(i = 0; i < REPEAT_WHEEL; i++)
|
for (i = 0; i < REPEAT_WHEEL; i++)
|
||||||
{
|
{
|
||||||
usb_kbd_send_code(0x48); /* UP */
|
usb_kbd_send_code(0x48); /* UP */
|
||||||
usb_kbd_send_code(0xC8);
|
usb_kbd_send_code(0xC8);
|
||||||
@@ -168,7 +169,7 @@ static int usb_mouse_irq(struct usb_device *dev)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for(i = 0; i < REPEAT_WHEEL; i++)
|
for (i = 0; i < REPEAT_WHEEL; i++)
|
||||||
{
|
{
|
||||||
usb_kbd_send_code(0x50); /* DOWN */
|
usb_kbd_send_code(0x50); /* DOWN */
|
||||||
usb_kbd_send_code(0xD0);
|
usb_kbd_send_code(0xD0);
|
||||||
@@ -197,24 +198,24 @@ static int usb_mouse_probe(struct usb_device *dev, unsigned int ifnum)
|
|||||||
struct usb_interface_descriptor *iface;
|
struct usb_interface_descriptor *iface;
|
||||||
struct usb_endpoint_descriptor *ep;
|
struct usb_endpoint_descriptor *ep;
|
||||||
int pipe, maxp;
|
int pipe, maxp;
|
||||||
if(dev->descriptor.bNumConfigurations != 1)
|
if (dev->descriptor.bNumConfigurations != 1)
|
||||||
return 0;
|
return 0;
|
||||||
iface = &dev->config.if_desc[ifnum];
|
iface = &dev->config.if_desc[ifnum];
|
||||||
if(iface->bInterfaceClass != 3)
|
if (iface->bInterfaceClass != 3)
|
||||||
return 0;
|
return 0;
|
||||||
if(iface->bInterfaceSubClass != 1)
|
if (iface->bInterfaceSubClass != 1)
|
||||||
return 0;
|
return 0;
|
||||||
if(iface->bInterfaceProtocol != 2)
|
if (iface->bInterfaceProtocol != 2)
|
||||||
return 0;
|
return 0;
|
||||||
if(iface->bNumEndpoints != 1)
|
if (iface->bNumEndpoints != 1)
|
||||||
return 0;
|
return 0;
|
||||||
ep = &iface->ep_desc[0];
|
ep = &iface->ep_desc[0];
|
||||||
if(!(ep->bEndpointAddress & 0x80))
|
if (!(ep->bEndpointAddress & 0x80))
|
||||||
return 0;
|
return 0;
|
||||||
if((ep->bmAttributes & 3) != 3)
|
if ((ep->bmAttributes & 3) != 3)
|
||||||
return 0;
|
return 0;
|
||||||
new = (unsigned char *)driver_mem_alloc(8);
|
new = (unsigned char *)driver_mem_alloc(8);
|
||||||
if(new == NULL)
|
if (new == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
mse_printf("USB MOUSE found set protocol...\r\n");
|
mse_printf("USB MOUSE found set protocol...\r\n");
|
||||||
/* ok, we found a USB Mouse, install it */
|
/* ok, we found a USB Mouse, install it */
|
||||||
|
|||||||
@@ -55,14 +55,14 @@ void *memset(void *s, int c, size_t n)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int memcmp(const char *s1, const char *s2, size_t max)
|
int memcmp(const void *s1, const void *s2, size_t max)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int cmp;
|
int cmp;
|
||||||
|
|
||||||
for (i = 0; i < max; i++)
|
for (i = 0; i < max; i++)
|
||||||
{
|
{
|
||||||
cmp = (*s1 - *s2);
|
cmp = (* (const char *) s1 - * (const char *) s2);
|
||||||
if (cmp != 0) return cmp;
|
if (cmp != 0) return cmp;
|
||||||
}
|
}
|
||||||
return cmp;
|
return cmp;
|
||||||
|
|||||||
Reference in New Issue
Block a user