mirror of
https://github.com/ep00ch/lwip-contrib-mac.git
synced 2024-08-28 18:29:08 +00:00
Fixed various memory leaks caused by protection issues (and some other
issues). Also some minor cosmetic changes.
This commit is contained in:
parent
9713f45a02
commit
0a76b0f5ee
@ -30,7 +30,7 @@
|
|||||||
*
|
*
|
||||||
* Author: Adam Dunkels <adam@sics.se>
|
* 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__
|
#ifndef __CC_H__
|
||||||
#define __CC_H__
|
#define __CC_H__
|
||||||
@ -107,5 +107,11 @@ typedef struct _types_fd_set {
|
|||||||
x, __LINE__, __FILE__); fflush(NULL); abort();} while(0)
|
x, __LINE__, __FILE__); fflush(NULL); abort();} while(0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
asm u32_t GET_CALLER_PC (void)
|
||||||
|
{
|
||||||
|
! "d0"
|
||||||
|
move.l 4(a6),d0
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif /* __CC_H__ */
|
#endif /* __CC_H__ */
|
||||||
|
@ -284,7 +284,9 @@ mcf5272fec_tx_cleanup(void)
|
|||||||
|
|
||||||
|
|
||||||
tx_remove_sof = tx_remove_eof = mcf5272->tx_remove;
|
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 */
|
/* Loop, looking for completed buffers at eof */
|
||||||
while ((((flags = mcf5272->txbd_a[tx_remove_eof].flags) & MCF5272_FEC_TX_BD_R) == 0) &&
|
while ((((flags = mcf5272->txbd_a[tx_remove_eof].flags) & MCF5272_FEC_TX_BD_R) == 0) &&
|
||||||
(mcf5272->tx_pbuf_a[tx_remove_eof] != 0))
|
(mcf5272->tx_pbuf_a[tx_remove_eof] != 0))
|
||||||
@ -306,7 +308,9 @@ mcf5272fec_tx_cleanup(void)
|
|||||||
break;
|
break;
|
||||||
} while (1);
|
} while (1);
|
||||||
|
|
||||||
|
sys_arch_unprotect(old_level);
|
||||||
pbuf_free(p); // Will be head of chain
|
pbuf_free(p); // Will be head of chain
|
||||||
|
old_level = sys_arch_protect();
|
||||||
/* Look at next descriptor */
|
/* Look at next descriptor */
|
||||||
INC_TX_BD_INDEX(tx_remove_eof);
|
INC_TX_BD_INDEX(tx_remove_eof);
|
||||||
tx_remove_sof = tx_remove_eof;
|
tx_remove_sof = tx_remove_eof;
|
||||||
@ -314,10 +318,9 @@ mcf5272fec_tx_cleanup(void)
|
|||||||
else
|
else
|
||||||
INC_TX_BD_INDEX(tx_remove_eof);
|
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 */
|
/* clear interrupt status for tx interrupt */
|
||||||
old_level = sys_arch_protect();
|
|
||||||
MCF5272_WR_FEC_EIR(imm, MCF5272_FEC_EIR_TXF);
|
MCF5272_WR_FEC_EIR(imm, MCF5272_FEC_EIR_TXF);
|
||||||
value = MCF5272_RD_FEC_IMR(imm);
|
value = MCF5272_RD_FEC_IMR(imm);
|
||||||
/* Set tx interrupt bit again */
|
/* Set tx interrupt bit again */
|
||||||
@ -525,9 +528,11 @@ mcf5272fec_rx(void)
|
|||||||
{
|
{
|
||||||
p = mcf5272->rx_pbuf_a[rx_remove_sof]; // First in chain
|
p = mcf5272->rx_pbuf_a[rx_remove_sof]; // First in chain
|
||||||
p->tot_len = p->len; // Important since len might have changed
|
p->tot_len = p->len; // Important since len might have changed
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
pbuf_chain(p, mcf5272->rx_pbuf_a[rx_remove_sof]);
|
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 */
|
/* Clear pointer to mark descriptor as free */
|
||||||
mcf5272->rx_pbuf_a[rx_remove_sof] = 0;
|
mcf5272->rx_pbuf_a[rx_remove_sof] = 0;
|
||||||
mcf5272->rxbd_a[rx_remove_sof].p_buf = 0;
|
mcf5272->rxbd_a[rx_remove_sof].p_buf = 0;
|
||||||
|
@ -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)));
|
timespent = TICKS_TO_HUNDMICROSEC(((s32_t) ((s32_t) NU_Retrieve_Clock() - (s32_t) timestart)));
|
||||||
|
|
||||||
if (status == NU_TIMEOUT)
|
if (status == NU_TIMEOUT)
|
||||||
return 0xffffffff;
|
return SYS_ARCH_TIMEOUT;
|
||||||
else
|
else
|
||||||
/* Round off to milliseconds */
|
/* Round off to milliseconds */
|
||||||
return (timespent+5)/10;
|
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)));
|
timespent = TICKS_TO_HUNDMICROSEC(((s32_t) ((s32_t) NU_Retrieve_Clock() - (s32_t) timestart)));
|
||||||
|
|
||||||
if (status == NU_TIMEOUT)
|
if (status == NU_TIMEOUT)
|
||||||
return 0xffffffff;
|
return SYS_ARCH_TIMEOUT;
|
||||||
else
|
else
|
||||||
/* Round off to milliseconds */
|
/* Round off to milliseconds */
|
||||||
return (timespent+5)/10;
|
return (timespent+5)/10;
|
||||||
|
Loading…
Reference in New Issue
Block a user