Greetings:
In the RL-ARM User's Guide, the example for interrupt_ethernet() __irq includes a call to function alloc_mem() to receive an ethernet frame. Here is an excerpt from the sample:
/* Flag 0x80000000 to skip sys_error() call when out of memory. */ frame = alloc_mem (RxLen | 0x80000000); /* if 'alloc_mem()' has failed, ignore this packet. */ if (frame != NULL) { dp = (U32 *)&frame->data[0]; sp = (U32 *)Rx_Desc[idx].Packet; for (RxLen = (RxLen + 3) >> 2; RxLen; RxLen--) { *dp++ = *sp++; } put_in_queue (frame); } rel: if (++idx == NUM_RX_FRAG) idx = 0; /* Release frame from EMAC buffer. */ MAC_RXCONSUMEINDEX = idx;
Note that there appears to be no explicit de-allocation of the memory pointed to by OS_FRAME *frame. Shouldn't there be a complimentary call to function free_mem()?
A search for "alloc_mem()" from my IDE finds a similar interrupt_ethernet() __irq, except this one includes the following code. Note the comment about MMU free packet:
/* Flag 0x80000000 to skip sys_error() call when out of memory. */ frame = alloc_mem (RxLen | 0x80000000); /* if 'alloc_mem()' has failed, ignore this packet. */ if (frame != NULL) { /* Make sure that block is 4-byte aligned */ RxLen = (RxLen + 3) >> 2; dp = (U32 *)&frame->data[0]; for ( ; RxLen; RxLen--) { *dp++ = LREG (U32, B2_DATA); } put_in_queue (frame); } /* MMU free packet. */ LREG (U16, B2_MMUCR) = MMU_REMV_REL_RX;
There is still no explicit de-allocation of the memory pointed to by "frame". I wonder if the "LREG (U16,..." somehow does this?
The frightening thing is the first example code (with not even a hint of freeing memory) has been running for quite a while. Is this luck or is something else going on?
Thank you for any comments or recommendations.