diff options
-rw-r--r-- | pfinet/ethernet.c | 47 |
1 files changed, 15 insertions, 32 deletions
diff --git a/pfinet/ethernet.c b/pfinet/ethernet.c index 241467c8..c43cd37b 100644 --- a/pfinet/ethernet.c +++ b/pfinet/ethernet.c @@ -22,43 +22,26 @@ device_t ether_port; struct device *ether_dev; -void -ethernet_main_loop (void) +error_t +device_read_reply_inband (mach_port_t replypt, + error_t error_code, + vm_address_t data, + u_int datalen) { - error_t err; - vm_address_t packet; - vm_size_t packetlen; - struct sk_buff *skb; - - /* Listen to packets forever. When one arrives, - it's an "interrupt", so drop to interrupt layer, and call - the generic code. */ - for (;;) - { - err = device_read (ether_port, 0, 0, vm_page_size, &packet, - &packetlen); - if (err) - { - perror ("Reading from ethernet"); - continue; - } - - begin_interrupt (); - - skb = alloc_skb (packetlen, GFP_ATOMIC); - skb->len = packetlen; - skb->dev = ether_dev; - bcopy (packet, skb->data); - netif_rx (skb); - } -} - + mutex_lock (&global_lock); + skb = alloc_skb (packetlen, GFP_ATOMIC); + skb->len = packetlen; + skb->dev = ether_dev; + bcopy (packet, skb->data); + netif_rx (skb); + mutex_unlock (&global_lock); - + device_read_request (ether_port, ether_reply, 0, 0, vm_page_size); +} void start_ethernet (void) { - cthread_detach (cthread_fork ((cthread_fn_t) ethernet_main_loop, 0)); + device_read_request (ether_port, ether_reply, 0, 0, vm_page_size); } |