----------------------------------------------------------------------

Fixed the following bugs:
	2366: For coldfire port: pbuf is freed twice when no room on
	      output ring.
	2368: Coldfire port: buffer cleanup in 5272 driver causes
	      problems.
	2376: Can't have timeouts large enough
Committing in .

Modified Files:
	coldfire/sys_arch.c coldfire/netif/5272fec.c
----------------------------------------------------------------------
This commit is contained in:
davidhaas 2003-02-04 14:45:22 +00:00
parent edd18aad86
commit 51df05f58a
2 changed files with 30 additions and 13 deletions

View File

@ -113,6 +113,7 @@ typedef struct mcf5272if mcf5272if_t;
static mcf5272if_t *mcf5272if;
static const struct eth_addr ethbroadcast = {{0xff,0xff,0xff,0xff,0xff,0xff}};
static sys_sem_t tx_sem;
u32_t phy;
@ -259,6 +260,15 @@ mcf5272_dis_tx_int(void)
/*-----------------------------------------------------------------------------------*
*-----------------------------------------------------------------------------------*/
static void mcf5272fec_tx_hisr(void)
{
/* Just signal task that it can run and cleanup */
sys_sem_signal(tx_sem);
}
/*-----------------------------------------------------------------------------------*
This function must be run as a task, since it ends up calling free() through pbuf_free()
*-----------------------------------------------------------------------------------*/
static void
mcf5272fec_tx_cleanup(void)
{
@ -345,7 +355,6 @@ low_level_output(struct netif *netif, struct pbuf *p)
if (num_desc > mcf5272->tx_free)
{
/* Drop the frame, we have no place to put it */
pbuf_free(p);
#ifdef LINK_STATS
lwip_stats.link.memerr++;
#endif
@ -600,7 +609,7 @@ low_level_init(struct netif *netif)
/* Plug appropriate low level interrupt vectors */
sys_setvect(MCF5272_VECTOR_ERx, mcf5272fec_rx, mcf5272_dis_rx_int);
sys_setvect(MCF5272_VECTOR_ETx, mcf5272fec_tx_cleanup, mcf5272_dis_tx_int);
sys_setvect(MCF5272_VECTOR_ETx, mcf5272fec_tx_hisr, mcf5272_dis_tx_int);
//sys_setvect(MCF5272_VECTOR_ENTC, mcf5272fec_ntc);
/* Set the I_MASK register to enable only rx & tx frame interrupts */
@ -711,18 +720,18 @@ static void
etharp_timer_thread(void *arg)
{
sys_sem_t *psem = (sys_sem_t *) arg;
sys_sem_t sem;
/* Create timeout timer */
sys_timeout(ARP_TMR_INTERVAL, (sys_timeout_handler)arp_timer, NULL);
/* Signal previous task that it can go */
sys_sem_signal(*psem);
sem = sys_sem_new(0);
tx_sem = sys_sem_new(0);
while(1)
{
sys_sem_wait(sem);
sys_sem_wait(tx_sem);
mcf5272fec_tx_cleanup();
}
}

View File

@ -67,8 +67,8 @@ static struct sys_thread *threads = NULL;
static struct sys_hisr *hisrs = NULL;
#define TICKS_PER_SECOND 10000
#define MS_TO_TICKS(MS) (MS * TICKS_PER_SECOND) / 1000
#define TICKS_TO_MS(TICKS) (1000 * TICKS) / TICKS_PER_SECOND
#define MS_TO_TICKS(MS) (MS * (TICKS_PER_SECOND / 1000))
#define TICKS_TO_MS(TICKS) ((unsigned long)((1000ULL * TICKS) / TICKS_PER_SECOND))
#define SYS_MBOX_SIZE 128 // Number of elements in mbox queue
#define SYS_STACK_SIZE 2048 // A minimum Nucleus stack for coldfire
@ -277,8 +277,8 @@ sys_sem_signal(sys_sem_t sem)
}
/*---------------------------------------------------------------------------------*/
u16_t
sys_arch_sem_wait(sys_sem_t sem, u16_t timeout)
u32_t
sys_arch_sem_wait(sys_sem_t sem, u32_t timeout)
{
UNSIGNED timestart, timespent;
STATUS status;
@ -294,7 +294,7 @@ sys_arch_sem_wait(sys_sem_t sem, u16_t timeout)
if (status == NU_TIMEOUT)
return 0;
else
return timespent ? (u16_t) timespent : 1;
return timespent ? timespent : 1;
}
/*---------------------------------------------------------------------------------*/
@ -400,8 +400,8 @@ sys_mbox_post(sys_mbox_t mbox, void *msg)
ASSERT("sys_mbox_post: mbx post failed", status == NU_SUCCESS);
}
/*---------------------------------------------------------------------------------*/
u16_t
sys_arch_mbox_fetch(sys_mbox_t mbox, void **msg, u16_t timeout)
u32_t
sys_arch_mbox_fetch(sys_mbox_t mbox, void **msg, u32_t timeout)
{
UNSIGNED timestart, timespent;
STATUS status;
@ -423,7 +423,15 @@ sys_arch_mbox_fetch(sys_mbox_t mbox, void **msg, u16_t timeout)
if (msg)
*msg = ret_msg;
DEBUGF(SYS_DEBUG, ("sys_mbox_fetch: mbox %p msg %p\n", mbox, ret_msg));
} else {
if (msg)
*msg = 0;
if (status == NU_TIMEOUT)
DEBUGF(SYS_DEBUG, ("sys_mbox_fetch: timeout on mbox %p\n", mbox));
else
DEBUGF(SYS_DEBUG, ("sys_mbox_fetch: Queue Error %i on mbox %p\n", status, mbox));
}
/* This next statement takes wraparound into account. It works. Really! */
timespent = TICKS_TO_MS(((s32_t) ((s32_t) NU_Retrieve_Clock() - (s32_t) timestart)));
@ -431,7 +439,7 @@ sys_arch_mbox_fetch(sys_mbox_t mbox, void **msg, u16_t timeout)
if (status == NU_TIMEOUT)
return 0;
else
return timespent ? (u16_t) timespent : 1;
return timespent ? timespent : 1;
}
/*---------------------------------------------------------------------------------*/