* [ECOS] function pointer in a thread
@ 2007-07-23 13:26 Michele Paselli
2007-07-24 11:25 ` Andrew Lunn
0 siblings, 1 reply; 2+ messages in thread
From: Michele Paselli @ 2007-07-23 13:26 UTC (permalink / raw)
To: ecos-discuss
Hi all,
I'm trying to build a small and simple network stack for raw
networking. After investigating a bit the existing stacks (in
particular lwip, which is more simple than the bsd implementation) I
found that in the init phase a new thread is started ("Network
Delivery Thread"). In particular the thread always waits for a
semaphore, which is posted by the dsr every time a packet is received,
and then calls the deliver function. The thread is the same as the
lwip implementatiom, I just added few printf:
//Input thread signalled by DSR calls deliver() on low level drivers
static void raweth_thread(void *arg)
{
cyg_netdevtab_entry_t *t;
for (;;) {
cyg_semaphore_wait(&delivery);
for (t = &__RAWDEVTAB__[0]; t != &__RAWDEVTAB_END__; t++) {
struct eth_drv_sc *sc = (struct eth_drv_sc *)t->device_instance;
if (sc->state & ETH_DRV_NEEDS_DELIVERY) {
#if defined(CYGDBG_HAL_DEBUG_GDB_CTRLC_SUPPORT)
cyg_bool was_ctrlc_int;
#endif
sc->state &= ~ETH_DRV_NEEDS_DELIVERY;
#if defined(CYGDBG_HAL_DEBUG_GDB_CTRLC_SUPPORT)
diag_printf("int_vector function @ 0x%x, sc @
0x%x\n",sc->funs->int_vector,sc);
was_ctrlc_int = HAL_CTRLC_CHECK((*sc->funs->int_vector)(sc), (int)sc);
diag_printf("deliver fucntion @ 0x%x\n",sc->funs->deliver);
if (!was_ctrlc_int) // Fall through and run normal code
#endif
(sc->funs->deliver) (sc);
}
}
}
}
When I start the application for the first ethernet packet received I got this:
int_vector function @ 0x43210, sc @ 0x5a2dc
deliver fucntion @ 0x431cc
but when a second packet is received this is what I get:
int_vector function @ 0x1fff20e5, sc @ 0x5a2dc
and the program hangs. Who is changing the sc structure? I looked in
the lwip implementation and when the thread is created (in the
function sys_thread_new() ) also some memory is allocated, I tried to
do the same but the result does not change. What am I doing wrong?
Thanks.
Michele
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [ECOS] function pointer in a thread
2007-07-23 13:26 [ECOS] function pointer in a thread Michele Paselli
@ 2007-07-24 11:25 ` Andrew Lunn
0 siblings, 0 replies; 2+ messages in thread
From: Andrew Lunn @ 2007-07-24 11:25 UTC (permalink / raw)
To: Michele Paselli; +Cc: ecos-discuss
On Mon, Jul 23, 2007 at 03:26:41PM +0200, Michele Paselli wrote:
> Hi all,
>
> I'm trying to build a small and simple network stack for raw
> networking. After investigating a bit the existing stacks (in
> particular lwip, which is more simple than the bsd implementation) I
> found that in the init phase a new thread is started ("Network
> Delivery Thread"). In particular the thread always waits for a
> semaphore, which is posted by the dsr every time a packet is received,
> and then calls the deliver function. The thread is the same as the
> lwip implementatiom, I just added few printf:
>
> //Input thread signalled by DSR calls deliver() on low level drivers
> static void raweth_thread(void *arg)
> {
> cyg_netdevtab_entry_t *t;
>
> for (;;) {
> cyg_semaphore_wait(&delivery);
> for (t = &__RAWDEVTAB__[0]; t != &__RAWDEVTAB_END__; t++) {
> struct eth_drv_sc *sc = (struct eth_drv_sc *)t->device_instance;
> if (sc->state & ETH_DRV_NEEDS_DELIVERY) {
> #if defined(CYGDBG_HAL_DEBUG_GDB_CTRLC_SUPPORT)
> cyg_bool was_ctrlc_int;
> #endif
> sc->state &= ~ETH_DRV_NEEDS_DELIVERY;
> #if defined(CYGDBG_HAL_DEBUG_GDB_CTRLC_SUPPORT)
> diag_printf("int_vector function @ 0x%x, sc @
> 0x%x\n",sc->funs->int_vector,sc);
> was_ctrlc_int = HAL_CTRLC_CHECK((*sc->funs->int_vector)(sc), (int)sc);
> diag_printf("deliver fucntion @ 0x%x\n",sc->funs->deliver);
> if (!was_ctrlc_int) // Fall through and run normal code
> #endif
> (sc->funs->deliver) (sc);
> }
> }
> }
> }
>
> When I start the application for the first ethernet packet received I got
> this:
>
> int_vector function @ 0x43210, sc @ 0x5a2dc
> deliver fucntion @ 0x431cc
>
> but when a second packet is received this is what I get:
>
> int_vector function @ 0x1fff20e5, sc @ 0x5a2dc
Check to see if HAL_CTRLC_CHECK() changes SC. Is 0x1fff20e5 somewhere
in ROM? Is it inside Redboot?
Andrew
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2007-07-24 11:25 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-07-23 13:26 [ECOS] function pointer in a thread Michele Paselli
2007-07-24 11:25 ` Andrew Lunn
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).