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
- ...
6 files changed
tree: 8eb5a70a5e56fcdf8c5e5929f5c966bc63334ee1
  1. contiki-apple2/