Added banking for the apple2enh target.

The machines targeted by apple2enh mostly do have 128kB of RAM. But it's not that easy to make use of banking in an event driver system like Contiki. Anyway I discovered one scenario feasable: The machines in question allow to bank in just 8kB of the second 64kB into the address space (at a fixed location).

The Contiki Kernel consists of three major parts: The Event Kernel (EK) which is the base system for everything else, the Contiki Tool Kit (CTK) which manages the GUI and the network stack (UIP) which does the TCP/IP handling. Both CTK and UIP make use of EK, but CTK never calls into UIP and vice versa.

The CTK code is a little larger than 8kB while the UIP code (without DNS) is a little smaller than 8kB, resulting in this setup: The UIP code is moved into the additional 8kB while making sure that the CTK code "covers" the whole memory area used for banking.

This setup allows most calls out of UIP to go without any banking simply because all callees are always visible. The only exception to this is ek_post_synch() because UIP uses it for the "Application Upcall" mechanism and I didn't want to make assumptions on the application code called.

Ordinary calls into UIP are routed through banking functions by conditional name mapping via macros. Calls into UIP via function pointers only occur for the event and poll handler. And there are fortunately already macros in place which could be (ob)used.

This is a (working) prototype with these TODOs:
- Make sure /RAM is empty on startup
- Cleanup /RAM on exit
- Support command line parameters
- ...
diff --git a/contiki-apple2/conf/uip-conf.h b/contiki-apple2/conf/uip-conf.h
index 971e684..b4e379b 100644
--- a/contiki-apple2/conf/uip-conf.h
+++ b/contiki-apple2/conf/uip-conf.h
@@ -32,7 +32,7 @@
  *
  * This file is part of the Contiki Destop OS
  *
- * $Id: uip-conf.h,v 1.3 2005/03/16 22:37:01 oliverschmidt Exp $
+ * $Id: uip-conf.h,v 1.4 2006/05/17 15:55:29 oliverschmidt Exp $
  *
  */
 #ifndef __UIP_CONF_H__
@@ -41,8 +41,49 @@
 #define UIP_CONF_MAX_LISTENPORTS 10
 #define UIP_CONF_BUFFER_SIZE     1024 - 2
 #define UIP_CONF_RECEIVE_WINDOW  UIP_TCP_MSS
+#define UIP_CONF_BYTE_ORDER      LITTLE_ENDIAN
 #define UIP_CONF_EXTERNAL_BUFFER
 
-#define UIP_CONF_BYTE_ORDER      LITTLE_ENDIAN
+#ifdef UIP_CODE
+
+#pragma codeseg("UIP");
+
+#include "ek-conf.h"
+
+#undef  EK_PROCESS_INIT
+#define EK_PROCESS_INIT(name, arg)					\
+  void _tcpip_init(void *arg)
+
+#undef  EK_EVENTHANDLER
+#define EK_EVENTHANDLER(name, ev, data)					\
+  void _tcpip_eventhandler(ek_event_t ev, ek_data_t data)
+
+#undef  EK_POLLHANDLER
+#define EK_POLLHANDLER(name)						\
+  void _tcpip_pollhandler(void)
+
+#undef  EK_PROCESS
+#define EK_PROCESS(name, strname, prio, eventh, pollh, stateptr)	\
+  void tcpip_eventhandler(ek_event_t ev, ek_data_t data);		\
+  void tcpip_pollhandler(void);						\
+  static struct ek_proc name = {NULL, EK_ID_NONE, strname, prio, tcpip_eventhandler, tcpip_pollhandler, stateptr}
+
+#define htons                _htons
+#define uiplib_ipaddrconv    _uiplib_ipaddrconv
+#define tcp_markconn         _tcp_markconn
+#define tcp_listen           _tcp_listen
+#define tcp_unlisten         _tcp_unlisten
+#define tcp_connect          _tcp_connect
+#define udp_new              _udp_new
+#define tcpip_set_forwarding _tcpip_set_forwarding
+#define tcpip_input          _tcpip_input
+#define tcpip_output         _tcpip_output
+#define tcpip_poll_tcp       _tcpip_poll_tcp
+#define tcpip_poll_udp       _tcpip_poll_udp
+
+#define ek_post_synch        _ek_post_synch
+void _ek_post_synch(ek_id_t id, ek_event_t ev, ek_data_t data);
+
+#endif /* UIP_CODE */
 
 #endif /* __UIP_CONF_H__ */