Updated for the new kernel API
diff --git a/contiki-avr/uip/rtl8019-drv.c b/contiki-avr/uip/rtl8019-drv.c
index 6aa6214..217a595 100644
--- a/contiki-avr/uip/rtl8019-drv.c
+++ b/contiki-avr/uip/rtl8019-drv.c
@@ -1,5 +1,6 @@
+/*-----------------------------------------------------------------------------------*/
/*
- * Copyright (c) 2001, Adam Dunkels.
+ * Copyright (c) 2001-2004, Adam Dunkels.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -10,10 +11,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by Adam Dunkels.
- * 4. The name of the author may not be used to endorse or promote
+ * 3. The name of the author may not be used to endorse or promote
* products derived from this software without specific prior
* written permission.
*
@@ -31,131 +29,84 @@
*
* This file is part of the uIP TCP/IP stack.
*
- * $Id: rtl8019-drv.c,v 1.2 2003/08/25 12:42:41 adamdunkels Exp $
+ * $Id: rtl8019-drv.c,v 1.3 2004/07/04 20:17:38 adamdunkels Exp $
*
*/
+#include "packet-service.h"
-/* uip_main.c: initialization code and main event loop. */
-
-#define NULL (void *)0
-
-
-
-#include "uip.h"
-#include "uip_arp.h"
-#include "uip-signal.h"
-#include "loader.h"
#include "rtl8019dev.h"
-#include "dispatcher.h"
-#include "ek.h"
+#include "uip_arp.h"
-#include "debug.h"
+static void output(u8_t *hdr, u16_t hdrlen, u8_t *data, u16_t datalen);
-#define BUF ((struct uip_eth_hdr *)&uip_buf[0])
+static const struct packet_service_state state =
+ {
+ PACKET_SERVICE_VERSION,
+ output
+ };
-static u8_t i, arptimer;
-static u16_t start, current;
+EK_EVENTHANDLER(eventhandler, ev, data);
+EK_POLLHANDLER(pollhandler);
+EK_PROCESS(proc, PACKET_SERVICE_NAME, EK_PRIO_NORMAL,
+ eventhandler, pollhandler, (void *)&state);
-static void rtl8019_drv_idle(void);
-static DISPATCHER_SIGHANDLER(rtl8019_drv_sighandler, s, data);
-static struct dispatcher_proc p =
- {DISPATCHER_PROC("TCP/IP/RTL8019 driver", rtl8019_drv_idle,
- rtl8019_drv_sighandler, NULL)};
-ek_id_t id = EK_ID_NONE;
-
-
-/*-----------------------------------------------------------------------------------*/
-static void
-timer(void)
+/*---------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(rtl8019_drv_init, arg)
{
- for(i = 0; i < UIP_CONNS; ++i) {
- uip_periodic(i);
- if(uip_len > 0) {
- uip_arp_out();
- RTL8019dev_send();
- }
- }
-
- for(i = 0; i < UIP_UDP_CONNS; i++) {
- uip_udp_periodic(i);
- /* If the above function invocation resulted in data that
- should be sent out on the network, the global variable
- uip_len is set to a value > 0. */
- if(uip_len > 0) {
- uip_arp_out();
- RTL8019dev_send();
- }
- }
+ arg_free(arg);
+ ek_service_start(PACKET_SERVICE_NAME, &proc);
}
-/*-----------------------------------------------------------------------------------*/
+/*---------------------------------------------------------------------------*/
static void
-rtl8019_drv_idle(void)
+output(u8_t *hdr, u16_t hdrlen, u8_t *data, u16_t datalen)
{
+ RTL8019dev_send();
+}
+/*---------------------------------------------------------------------------*/
+EK_EVENTHANDLER(eventhandler, ev, data)
+{
+ switch(ev) {
+ case EK_EVENT_INIT:
+ RTL8019dev_init();
+ break;
+ case EK_EVENT_REQUEST_REPLACE:
+ ek_replace((struct ek_proc *)data, NULL);
+ LOADER_UNLOAD();
+ break;
+ case EK_EVENT_REQUEST_EXIT:
+ ek_exit();
+ LOADER_UNLOAD();
+ break;
+ default:
+ break;
+ }
+}
+/*---------------------------------------------------------------------------*/
+EK_POLLHANDLER(pollhandler)
+{
+#define BUF ((struct uip_eth_hdr *)&uip_buf[0])
+
/* Poll Ethernet device to see if there is a frame avaliable. */
uip_len = RTL8019dev_poll();
if(uip_len > 0) {
/* A frame was avaliable (and is now read into the uip_buf), so
- we process it. */
- if(BUF->type == htons(UIP_ETHTYPE_IP)) {
- /* debug_print16(uip_len);*/
+ we process it. */
+ if(BUF->type == HTONS(UIP_ETHTYPE_IP)) {
uip_arp_ipin();
uip_len -= sizeof(struct uip_eth_hdr);
- uip_input();
- /* If the above function invocation resulted in data that
- should be sent out on the network, the global variable
- uip_len is set to a value > 0. */
- if(uip_len > 0) {
- /* debug_print(PSTR("Sending packet\n"));*/
- uip_arp_out();
- RTL8019dev_send();
- }
- } else if(BUF->type == htons(UIP_ETHTYPE_ARP)) {
+ tcpip_input();
+ } else if(BUF->type == HTONS(UIP_ETHTYPE_ARP)) {
uip_arp_arpin();
/* If the above function invocation resulted in data that
- should be sent out on the network, the global variable
- uip_len is set to a value > 0. */
+ should be sent out on the network, the global variable
+ uip_len is set to a value > 0. */
if(uip_len > 0) {
RTL8019dev_send();
}
}
}
- /* Check the clock so see if we should call the periodic uIP
- processing. */
- current = ek_clock();
- if((current - start) >= CLK_TCK/2 ||
- (current - start) < 0) {
- timer();
- start = current;
- }
}
-/*-----------------------------------------------------------------------------------*/
-LOADER_INIT_FUNC(rtl8019_drv_init, arg)
-{
- arg_free(arg);
- if(id == EK_ID_NONE) {
- id = dispatcher_start(&p);
-
- arptimer = 0;
- start = ek_clock();
-
- RTL8019dev_init();
-
- dispatcher_listen(uip_signal_uninstall);
- }
-}
-/*-----------------------------------------------------------------------------------*/
-static
-DISPATCHER_SIGHANDLER(rtl8019_drv_sighandler, s, data)
-{
- DISPATCHER_SIGHANDLER_ARGS(s, data);
-
- if(s == uip_signal_uninstall) {
- dispatcher_exit(&p);
- id = EK_ID_NONE;
- LOADER_UNLOAD();
- }
-}
-/*-----------------------------------------------------------------------------------*/
+/*---------------------------------------------------------------------------*/