Fixed various memory leaks caused by protection issues (and some other

issues).

Also some minor cosmetic changes.
This commit is contained in:
davidhaas 2003-04-09 20:34:51 +00:00
parent 9713f45a02
commit 0a76b0f5ee
3 changed files with 19 additions and 8 deletions

View File

@ -30,7 +30,7 @@
*
* Author: Adam Dunkels <adam@sics.se>
*
* $Id: cc.h,v 1.5 2003/02/18 19:27:08 davidhaas Exp $
* $Id: cc.h,v 1.6 2003/04/09 20:34:51 davidhaas Exp $
*/
#ifndef __CC_H__
#define __CC_H__
@ -107,5 +107,11 @@ typedef struct _types_fd_set {
x, __LINE__, __FILE__); fflush(NULL); abort();} while(0)
#endif
asm u32_t GET_CALLER_PC (void)
{
! "d0"
move.l 4(a6),d0
}
#endif /* __CC_H__ */

View File

@ -284,7 +284,9 @@ mcf5272fec_tx_cleanup(void)
tx_remove_sof = tx_remove_eof = mcf5272->tx_remove;
/* We must protect reading the flags and then reading the buffer pointer. They must
both be read together. */
old_level = sys_arch_protect();
/* Loop, looking for completed buffers at eof */
while ((((flags = mcf5272->txbd_a[tx_remove_eof].flags) & MCF5272_FEC_TX_BD_R) == 0) &&
(mcf5272->tx_pbuf_a[tx_remove_eof] != 0))
@ -306,7 +308,9 @@ mcf5272fec_tx_cleanup(void)
break;
} while (1);
sys_arch_unprotect(old_level);
pbuf_free(p); // Will be head of chain
old_level = sys_arch_protect();
/* Look at next descriptor */
INC_TX_BD_INDEX(tx_remove_eof);
tx_remove_sof = tx_remove_eof;
@ -314,10 +318,9 @@ mcf5272fec_tx_cleanup(void)
else
INC_TX_BD_INDEX(tx_remove_eof);
}
mcf5272->tx_remove = tx_remove_eof;
mcf5272->tx_remove = tx_remove_sof;
/* clear interrupt status for tx interrupt */
old_level = sys_arch_protect();
MCF5272_WR_FEC_EIR(imm, MCF5272_FEC_EIR_TXF);
value = MCF5272_RD_FEC_IMR(imm);
/* Set tx interrupt bit again */
@ -525,9 +528,11 @@ mcf5272fec_rx(void)
{
p = mcf5272->rx_pbuf_a[rx_remove_sof]; // First in chain
p->tot_len = p->len; // Important since len might have changed
}
else
} else {
pbuf_chain(p, mcf5272->rx_pbuf_a[rx_remove_sof]);
pbuf_free(mcf5272->rx_pbuf_a[rx_remove_sof]);
}
/* Clear pointer to mark descriptor as free */
mcf5272->rx_pbuf_a[rx_remove_sof] = 0;
mcf5272->rxbd_a[rx_remove_sof].p_buf = 0;

View File

@ -282,7 +282,7 @@ sys_arch_sem_wait(sys_sem_t sem, u32_t timeout)
timespent = TICKS_TO_HUNDMICROSEC(((s32_t) ((s32_t) NU_Retrieve_Clock() - (s32_t) timestart)));
if (status == NU_TIMEOUT)
return 0xffffffff;
return SYS_ARCH_TIMEOUT;
else
/* Round off to milliseconds */
return (timespent+5)/10;
@ -428,7 +428,7 @@ sys_arch_mbox_fetch(sys_mbox_t mbox, void **msg, u32_t timeout)
timespent = TICKS_TO_HUNDMICROSEC(((s32_t) ((s32_t) NU_Retrieve_Clock() - (s32_t) timestart)));
if (status == NU_TIMEOUT)
return 0xffffffff;
return SYS_ARCH_TIMEOUT;
else
/* Round off to milliseconds */
return (timespent+5)/10;