diff --git a/BaS_gcc/dma/dma.c b/BaS_gcc/dma/dma.c index 269dc42..96e5c32 100644 --- a/BaS_gcc/dma/dma.c +++ b/BaS_gcc/dma/dma.c @@ -39,7 +39,7 @@ #error "unknown machine!" #endif /* MACHINE_FIREBEE */ -//#define DBG_DMA +#define DBG_DMA #ifdef DBG_DMA #define dbg(format, arg...) do { xprintf("DEBUG: " format, ##arg); } while (0) #else @@ -596,11 +596,15 @@ int dma_interrupt_handler(void *arg1, void *arg2) void *dma_memcpy(void *dst, void *src, size_t n) { int ret; - volatile int32_t time; - volatile int32_t start; - volatile int32_t end; + +#ifdef DBG_DMA + int32_t time; + int32_t start; + int32_t end; start = MCF_SLT0_SCNT; +#endif /* DBG_DMA */ + ret = MCD_startDma(1, src, 4, dst, 4, n, 4, DMA_ALWAYS, 0, MCD_SINGLE_DMA, 0); if (ret == MCD_OK) { @@ -644,8 +648,10 @@ void *dma_memcpy(void *dst, void *src, size_t n) #endif } while (ret != MCD_DONE); +#ifdef DBG_DMA end = MCF_SLT0_SCNT; 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); return dst; diff --git a/BaS_gcc/include/bas_string.h b/BaS_gcc/include/bas_string.h index 7edca59..c743c95 100644 --- a/BaS_gcc/include/bas_string.h +++ b/BaS_gcc/include/bas_string.h @@ -35,7 +35,7 @@ extern char *strncat(char *dst, const char *src, size_t max); extern int atoi(const char *c); extern void *memcpy(void *dst, const void *src, 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); #define isdigit(c) (((c) >= '0') && ((c) <= '9')) diff --git a/BaS_gcc/include/ip.h b/BaS_gcc/include/ip.h index ece30b5..bde1213 100644 --- a/BaS_gcc/include/ip.h +++ b/BaS_gcc/include/ip.h @@ -9,7 +9,6 @@ #ifndef _IP_H #define _IP_H -/********************************************************************/ /* 32-bit IP Addresses */ typedef uint8_t IP_ADDR[4]; @@ -57,7 +56,6 @@ typedef struct #define IP_HDR_OFFSET ETH_HDR_LEN #define IP_HDR_SIZE 20 /* no options */ -/********************************************************************/ typedef struct { @@ -71,7 +69,6 @@ typedef struct unsigned int err; } IP_INFO; -/********************************************************************/ extern void ip_handler(NIF *nif, NBUF *nbf); uint16_t ip_chksum(uint16_t *data, int num); diff --git a/BaS_gcc/include/util.h b/BaS_gcc/include/util.h index 04d5ad5..5fb1a0d 100644 --- a/BaS_gcc/include/util.h +++ b/BaS_gcc/include/util.h @@ -145,7 +145,7 @@ __extension__ \ __extension__ \ ({__asm__ volatile ("lea -60(sp),sp\n\t" \ "movem.l d0-d7/a0-a6,(sp)"); \ - ((void (*)(void))addr)(); \ + ((void (*) (void)) addr)(); \ __asm__ volatile ("movem.l (sp),d0-d7/a0-a6\n\t" \ "lea 60(sp),sp"); \ }) diff --git a/BaS_gcc/net/bcm5222.c b/BaS_gcc/net/bcm5222.c index ce872ef..6f4e77d 100644 --- a/BaS_gcc/net/bcm5222.c +++ b/BaS_gcc/net/bcm5222.c @@ -26,7 +26,7 @@ #define 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 #define dbg(format, arg...) do { ; } while (0) #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 */ fec_mii_init(fec_ch, SYSCLK / 1000); - dbg("%s: PHY reset\r\n", __FUNCTION__); + dbg("PHY reset\r\n"); /* Reset the PHY */ 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) 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); @@ -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)) return 0; - dbg("%s: PHY Enable Auto-Negotiation\r\n", __FUNCTION__); + dbg("PHY Enable Auto-Negotiation\r\n"); /* Enable Auto-Negotiation */ if (!fec_mii_write(fec_ch, phy_addr, BCM5222_CTRL, (BCM5222_CTRL_ANE | BCM5222_CTRL_RESTART_AN))) 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 */ 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) { - dbg("%s: PHY auto-negociation complete\r\n", __FUNCTION__); + dbg("PHY auto-negociation complete\r\n"); /* Read Auxiliary Control/Status Register */ 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 { - 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) */ 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 fec_duplex(fec_ch, FEC_MII_HALF_DUPLEX); - dbg("%s: PHY Mode: ", __FUNCTION__); + dbg("PHY Mode: "); if (settings & BCM5222_ACSR_100BTX) - dbg("%s: 100Mbps\r\n", __FUNCTION__); + dbg("100Mbps\r\n"); else - dbg("%s: 10Mbps\r\n", __FUNCTION__); + dbg("10Mbps\r\n"); if (settings & BCM5222_ACSR_FDX) - dbg("%s: Full-duplex\r\n", __FUNCTION__); + dbg("Full-duplex\r\n"); else - dbg("%s: Half-duplex\r\n", __FUNCTION__); + dbg("Half-duplex\r\n"); return 1; } diff --git a/BaS_gcc/net/bootp.c b/BaS_gcc/net/bootp.c index 6bfebff..3c87fd9 100644 --- a/BaS_gcc/net/bootp.c +++ b/BaS_gcc/net/bootp.c @@ -11,9 +11,9 @@ #include #include "bas_printf.h" -//#define DBG_BOOTP +#define 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 #define dbg(format, arg...) do { ; } while (0) #endif /* DBG_BOOTP */ @@ -94,7 +94,7 @@ void bootp_handler(NIF *nif, NBUF *nbuf) struct bootp_packet *rx_p; udp_frame_hdr *udpframe; - dbg("%s\n", __FUNCTION__); + dbg("\r\n"); rx_p = (struct bootp_packet *) &nbuf->data[nbuf->offset]; udpframe = (udp_frame_hdr *) &nbuf->data[nbuf->offset - UDP_HDR_SIZE]; diff --git a/BaS_gcc/net/fec.c b/BaS_gcc/net/fec.c index 72e6328..08a8d03 100644 --- a/BaS_gcc/net/fec.c +++ b/BaS_gcc/net/fec.c @@ -32,9 +32,9 @@ #error Unknown machine! #endif -//#define DBG_FEC +#define 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 #define dbg(format, arg...) do { ; } while (0) #endif /* DBG_FEC */ @@ -237,33 +237,33 @@ void fec_log_init(uint8_t ch) */ void fec_log_dump(uint8_t ch) { - dbg("%s: \r\n FEC%d Log\r\n", __FUNCTION__, ch); - dbg("%s: ---------------\r\n", __FUNCTION__); - dbg("%s: Total: %4d\r\n", __FUNCTION__, fec_log[ch].total); - dbg("%s: hberr: %4d\r\n", __FUNCTION__, fec_log[ch].hberr); - dbg("%s: babr: %4d\r\n", __FUNCTION__, fec_log[ch].babr); - dbg("%s: babt: %4d\r\n", __FUNCTION__, fec_log[ch].babt); - dbg("%s: gra: %4d\r\n", __FUNCTION__, fec_log[ch].gra); - dbg("%s: txf: %4d\r\n", __FUNCTION__, fec_log[ch].txf); - dbg("%s: mii: %4d\r\n", __FUNCTION__, fec_log[ch].mii); - dbg("%s: lc: %4d\r\n", __FUNCTION__, fec_log[ch].lc); - dbg("%s: rl: %4d\r\n", __FUNCTION__, fec_log[ch].rl); - dbg("%s: xfun: %4d\r\n", __FUNCTION__, fec_log[ch].xfun); - dbg("%s: xferr: %4d\r\n", __FUNCTION__, fec_log[ch].xferr); - dbg("%s: rferr: %4d\r\n", __FUNCTION__, fec_log[ch].rferr); - dbg("%s: dtxf: %4d\r\n", __FUNCTION__, fec_log[ch].dtxf); - dbg("%s: drxf: %4d\r\n", __FUNCTION__, fec_log[ch].drxf); - dbg("%s: \r\nRFSW:\r\n", __FUNCTION__); - dbg("%s: inv: %4d\r\n", __FUNCTION__, fec_log[ch].rfsw_inv); - dbg("%s: m: %4d\r\n", __FUNCTION__, fec_log[ch].rfsw_m); - dbg("%s: bc: %4d\r\n", __FUNCTION__, fec_log[ch].rfsw_bc); - dbg("%s: mc: %4d\r\n", __FUNCTION__, fec_log[ch].rfsw_mc); - dbg("%s: lg: %4d\r\n", __FUNCTION__, fec_log[ch].rfsw_lg); - dbg("%s: no: %4d\r\n", __FUNCTION__, fec_log[ch].rfsw_no); - dbg("%s: cr: %4d\r\n", __FUNCTION__, fec_log[ch].rfsw_cr); - dbg("%s: ov: %4d\r\n", __FUNCTION__, fec_log[ch].rfsw_ov); - dbg("%s: tr: %4d\r\n", __FUNCTION__, fec_log[ch].rfsw_tr); - dbg("%s: ---------------\r\n\r\n", __FUNCTION__); + dbg("\r\n FEC%d Log\r\n", __FUNCTION__, ch); + dbg(" ---------------\r\n", __FUNCTION__); + dbg(" Total: %4d\r\n", fec_log[ch].total); + dbg(" hberr: %4d\r\n", fec_log[ch].hberr); + dbg(" babr: %4d\r\n", fec_log[ch].babr); + dbg(" babt: %4d\r\n", fec_log[ch].babt); + dbg(" gra: %4d\r\n", fec_log[ch].gra); + dbg(" txf: %4d\r\n", fec_log[ch].txf); + dbg(" mii: %4d\r\n", fec_log[ch].mii); + dbg(" lc: %4d\r\n", fec_log[ch].lc); + dbg(" rl: %4d\r\n", fec_log[ch].rl); + dbg(" xfun: %4d\r\n", fec_log[ch].xfun); + dbg(" xferr: %4d\r\n", fec_log[ch].xferr); + dbg(" rferr: %4d\r\n", fec_log[ch].rferr); + dbg(" dtxf: %4d\r\n", fec_log[ch].dtxf); + dbg(" drxf: %4d\r\n", fec_log[ch].drxf); + dbg(" \r\nRFSW:\r\n"); + dbg(" inv: %4d\r\n", fec_log[ch].rfsw_inv); + dbg(" m: %4d\r\n", fec_log[ch].rfsw_m); + dbg(" bc: %4d\r\n", fec_log[ch].rfsw_bc); + dbg(" mc: %4d\r\n", fec_log[ch].rfsw_mc); + dbg(" lg: %4d\r\n", fec_log[ch].rfsw_lg); + dbg(" no: %4d\r\n", fec_log[ch].rfsw_no); + dbg(" cr: %4d\r\n", fec_log[ch].rfsw_cr); + dbg(" ov: %4d\r\n", fec_log[ch].rfsw_ov); + dbg(" tr: %4d\r\n", fec_log[ch].rfsw_tr); + dbg(" ---------------\r\n\r\n"); } /* @@ -544,13 +544,13 @@ void fec_rx_start(uint8_t ch, int8_t *rxbd) * Make the initiator assignment */ 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 */ 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 @@ -558,7 +558,7 @@ void fec_rx_start(uint8_t ch, int8_t *rxbd) */ channel = dma_set_channel(DMA_FEC_RX(ch), (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 @@ -583,7 +583,7 @@ void fec_rx_start(uint8_t ch, int8_t *rxbd) | MCD_NO_CSUM | 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)); - 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 */ 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; int keep; - dbg("%s: started\r\n", __FUNCTION__); + dbg("started\r\n"); while ((pRxBD = fecbd_rx_alloc(ch)) != NULL) { @@ -733,7 +733,7 @@ void fec_rx_frame(uint8_t ch, NIF *nif) new_nbuf = nbuf_alloc(); 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 @@ -789,7 +789,7 @@ void fec_rx_frame(uint8_t ch, NIF *nif) else { 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 @@ -853,13 +853,13 @@ void fec_tx_start(uint8_t ch, int8_t *txbd) * Make the initiator assignment */ 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 */ 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), (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 @@ -893,7 +893,7 @@ void fec_tx_start(uint8_t ch, int8_t *txbd) | MCD_NO_CSUM | 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 */ channel = dma_get_channel(DMA_FEC_TX(ch)); - dbg("%s: dma_get_channel(DMA_FEC_TX(%d)) = %d\r\n", - __FUNCTION__, ch, channel); + dbg("dma_get_channel(DMA_FEC_TX(%d)) = %d\r\n", ch, channel); /* * Continue/restart the DMA task */ 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; bool is_empty = true; - dbg("%s:\r\n", __FUNCTION__); + dbg("\r\n"); while ((pTxBD = fecbd_tx_free(ch)) != NULL) { fec_log[ch].dtxf++; @@ -1011,7 +1010,7 @@ void fec_tx_frame(uint8_t ch) * Free up the network buffer that was just transmitted */ 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 @@ -1022,7 +1021,7 @@ void fec_tx_frame(uint8_t ch) } if (is_empty) - dbg("%s: transmit queue was empty!\r\n", __FUNCTION__); + dbg("transmit queue was empty!\r\n"); } 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 */ if ((nbuf->length + ETH_HDR_LEN) > ETH_MTU) { - dbg("%s: nbuf->length (%d) + ETH_HDR_LEN (%d) exceeds ETH_MTU (%d)\r\n", - __FUNCTION__, nbuf->length, ETH_HDR_LEN, ETH_MTU); + dbg("nbuf->length (%d) + ETH_HDR_LEN (%d) exceeds ETH_MTU (%d)\r\n", + nbuf->length, ETH_HDR_LEN, ETH_MTU); return 0; } @@ -1193,7 +1192,7 @@ static void fec_irq_handler(uint8_t ch) event = eir & MCF_FEC_EIMR(ch); 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 @@ -1204,8 +1203,8 @@ static void fec_irq_handler(uint8_t ch) { fec_log[ch].total++; fec_log[ch].rferr++; - dbg("%s: RFERR\r\n", __FUNCTION__); - dbg("%s: FECRFSR%d = 0x%08x\r\n", __FUNCTION__, ch, MCF_FEC_FECRFSR(ch)); + dbg("RFERR\r\n"); + dbg("FECRFSR%d = 0x%08x\r\n", ch, MCF_FEC_FECRFSR(ch)); //fec_eth_stop(ch); } @@ -1213,14 +1212,14 @@ static void fec_irq_handler(uint8_t ch) { fec_log[ch].total++; fec_log[ch].xferr++; - dbg("%s: XFERR\r\n", __FUNCTION__); + dbg("XFERR\r\n"); } if (event & MCF_FEC_EIR_XFUN) { fec_log[ch].total++; fec_log[ch].xfun++; - dbg("%s: XFUN\r\n", __FUNCTION__); + dbg("XFUN\r\n"); //fec_eth_stop(ch); } @@ -1228,54 +1227,54 @@ static void fec_irq_handler(uint8_t ch) { fec_log[ch].total++; fec_log[ch].rl++; - dbg("%s: RL\r\n", __FUNCTION__); + dbg("RL\r\n"); } if (event & MCF_FEC_EIR_LC) { fec_log[ch].total++; fec_log[ch].lc++; - dbg("%s: LC\r\n", __FUNCTION__); + dbg("LC\r\n"); } if (event & MCF_FEC_EIR_MII) { fec_log[ch].mii++; - dbg("%s: MII\r\n", __FUNCTION__); + dbg("MII\r\n"); } if (event & MCF_FEC_EIR_TXF) { fec_log[ch].txf++; - dbg("%s: TXF\r\n", __FUNCTION__); + dbg("TXF\r\n"); fec_log_dump(0); } if (event & MCF_FEC_EIR_GRA) { fec_log[ch].gra++; - dbg("%s: GRA\r\n", __FUNCTION__); + dbg("GRA\r\n"); } if (event & MCF_FEC_EIR_BABT) { fec_log[ch].total++; fec_log[ch].babt++; - dbg("%s: BABT\r\n", __FUNCTION__); + dbg("BABT\r\n"); } if (event & MCF_FEC_EIR_BABR) { fec_log[ch].total++; fec_log[ch].babr++; - dbg("%s: BABR\r\n", __FUNCTION__); + dbg("BABR\r\n"); } if (event & MCF_FEC_EIR_HBERR) { fec_log[ch].total++; 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 (am79c874_init(0, 0, speed, duplex)) - dbg("%s: PHY init completed\r\n", __FUNCTION__); + dbg("PHY init completed\r\n"); else - dbg("%s: PHY init failed\r\n", __FUNCTION__); + dbg("PHY init failed\r\n"); #elif defined(MACHINE_M548X) bcm_5222_init(0, 0, speed, duplex); #else @@ -1400,7 +1399,7 @@ void fec_eth_stop(uint8_t ch) */ 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 */ diff --git a/BaS_gcc/net/fecbd.c b/BaS_gcc/net/fecbd.c index af24966..49b1d0c 100644 --- a/BaS_gcc/net/fecbd.c +++ b/BaS_gcc/net/fecbd.c @@ -11,7 +11,7 @@ #include "bas_printf.h" #include -//#define DBG_FECBD +#define DBG_FECBD #ifdef DBG_FECBD #define dbg(format, arg...) do { xprintf("DEBUG: " format, ##arg); } while (0) #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 * aside for buffer descriptors */ -FECBD *RxBD; -FECBD *TxBD; +static FECBD *RxBD; +static FECBD *TxBD; /* * Macros to easier access to the BD ring @@ -65,7 +65,7 @@ void fecbd_init(uint8_t ch) NBUF *nbuf; int i; - dbg("%s:\r\n", __FUNCTION__); + dbg("\r\n"); /* * Align Buffer Descriptors to 4-byte boundary @@ -73,7 +73,7 @@ void fecbd_init(uint8_t ch) RxBD = (FECBD *)(((int) unaligned_bds + 3) & 0xFFFFFFFC); 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 @@ -84,7 +84,7 @@ void fecbd_init(uint8_t ch) nbuf = nbuf_alloc(); if (nbuf == NULL) { - dbg("%s: could not allocate network buffer\r\n", __FUNCTION__); + dbg("could not allocate network buffer\r\n"); return; } @@ -102,7 +102,7 @@ void fecbd_init(uint8_t ch) */ 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 diff --git a/BaS_gcc/net/ip.c b/BaS_gcc/net/ip.c index c6279e4..c536908 100644 --- a/BaS_gcc/net/ip.c +++ b/BaS_gcc/net/ip.c @@ -7,13 +7,15 @@ * Modifications: */ #include "net.h" +#include "bas_printf.h" +#include "bas_string.h" #include #include -//#define IP_DEBUG +#define 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 #define dbg(format, arg...) do { ; } while (0) #endif @@ -42,7 +44,7 @@ uint8_t *ip_get_myip(IP_INFO *info) { return (uint8_t *) &info->myip[0]; } - dbg("%s: info is NULL!\n\t", __FUNCTION__); + dbg("info is NULL!\n\t"); 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); - 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; } @@ -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); 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]); return 0; } @@ -176,9 +178,9 @@ int ip_send(NIF *nif, uint8_t *dest, uint8_t *src, uint8_t protocol, NBUF *pNbuf else { route = bc; - dbg("%s: route = broadcast\r\n", __FUNCTION__); - dbg("%s: nif = %p\r\n", __FUNCTION__, nif); - dbg("%s: nif->send = %p\r\n", __FUNCTION__, nif->send); + dbg("route = broadcast\r\n"); + dbg("nif = %p\r\n", nif); + dbg("nif->send = %p\r\n", nif->send); } 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; - dbg("%s: packet received\r\n", __FUNCTION__); + dbg("packet received\r\n"); 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)) { - dbg("%s: not a valid IP packet!\r\n", __FUNCTION__); + dbg("not a valid IP packet!\r\n"); nbuf_free(pNbuf); return; @@ -310,7 +312,7 @@ void ip_handler(NIF *nif, NBUF *pNbuf) udp_handler(nif,pNbuf); break; 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)); nbuf_free(pNbuf); break; diff --git a/BaS_gcc/sys/BaS.c b/BaS_gcc/sys/BaS.c index 73db9cf..6d84bf4 100644 --- a/BaS_gcc/sys/BaS.c +++ b/BaS_gcc/sys/BaS.c @@ -48,6 +48,7 @@ #include "bootp.h" #include "interrupts.h" #include "exceptions.h" +#include "net_timer.h" //#define BAS_DEBUG #if defined(BAS_DEBUG) diff --git a/BaS_gcc/usb/usb_mouse.c b/BaS_gcc/usb/usb_mouse.c index 1016ce4..72fc4ce 100644 --- a/BaS_gcc/usb/usb_mouse.c +++ b/BaS_gcc/usb/usb_mouse.c @@ -48,7 +48,7 @@ static int usb_mouse_probe(struct usb_device *dev, unsigned int ifnum); int usb_mouse_deregister(struct usb_device *dev) { dev->irq_handle = NULL; - if(new != NULL) + if (new != NULL) { driver_mem_free(new); new = NULL; @@ -61,8 +61,9 @@ int usb_mouse_deregister(struct usb_device *dev) /* registering the mouse */ int usb_mouse_register(struct usb_device *dev) { - if(!mouse_installed && (dev->devnum != -1) && (usb_mouse_probe(dev, 0) == 1)) - { /* Ok, we found a mouse */ + if (!mouse_installed && (dev->devnum != -1) && (usb_mouse_probe(dev, 0) == 1)) + { + /* Ok, we found a mouse */ mse_printf("USB MOUSE found (USB: %d, devnum: %d)\r\n", dev->usbnum, dev->devnum); mouse_installed = 1; dev->deregister = usb_mouse_deregister; @@ -76,12 +77,12 @@ int usb_mouse_register(struct usb_device *dev) int drv_usb_mouse_init(void) { int i, j; - if(mouse_installed) + if (mouse_installed) return -1; /* 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 */ if (dev == NULL) @@ -109,27 +110,27 @@ static int usb_mouse_irq(struct usb_device *dev) int level; #endif 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); 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; break; } } - if(change) + if (change) { 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]); #ifdef CONFIG_USB_INTERRUPT_POLLING level = set_ipl(7); /* mask interrupts */ #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]; old_buttons = old[1]; @@ -143,24 +144,24 @@ static int usb_mouse_irq(struct usb_device *dev) buttons = new[0]; old_buttons = old[0]; 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]; } - 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(0xF2); } } - if(wheel != 0) /* actually like Eiffel */ + if (wheel != 0) /* actually like Eiffel */ { #define REPEAT_WHEEL 3 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(0xC8); @@ -168,7 +169,7 @@ static int usb_mouse_irq(struct usb_device *dev) } 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(0xD0); @@ -197,24 +198,24 @@ static int usb_mouse_probe(struct usb_device *dev, unsigned int ifnum) struct usb_interface_descriptor *iface; struct usb_endpoint_descriptor *ep; int pipe, maxp; - if(dev->descriptor.bNumConfigurations != 1) + if (dev->descriptor.bNumConfigurations != 1) return 0; iface = &dev->config.if_desc[ifnum]; - if(iface->bInterfaceClass != 3) + if (iface->bInterfaceClass != 3) return 0; - if(iface->bInterfaceSubClass != 1) + if (iface->bInterfaceSubClass != 1) return 0; - if(iface->bInterfaceProtocol != 2) + if (iface->bInterfaceProtocol != 2) return 0; - if(iface->bNumEndpoints != 1) + if (iface->bNumEndpoints != 1) return 0; ep = &iface->ep_desc[0]; - if(!(ep->bEndpointAddress & 0x80)) + if (!(ep->bEndpointAddress & 0x80)) return 0; - if((ep->bmAttributes & 3) != 3) + if ((ep->bmAttributes & 3) != 3) return 0; new = (unsigned char *)driver_mem_alloc(8); - if(new == NULL) + if (new == NULL) return 0; mse_printf("USB MOUSE found set protocol...\r\n"); /* ok, we found a USB Mouse, install it */ diff --git a/BaS_gcc/util/bas_string.c b/BaS_gcc/util/bas_string.c index 01b9aff..3960638 100644 --- a/BaS_gcc/util/bas_string.c +++ b/BaS_gcc/util/bas_string.c @@ -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 cmp; for (i = 0; i < max; i++) { - cmp = (*s1 - *s2); + cmp = (* (const char *) s1 - * (const char *) s2); if (cmp != 0) return cmp; } return cmp;