From 00101cc177da463dfa7a2bed659cf17225a477c6 Mon Sep 17 00:00:00 2001 From: oliverschmidt Date: Wed, 3 Jan 2007 10:29:17 +0000 Subject: [PATCH] Added support for the cc65 target 'apple2enh' (Enhanced Apple //e). --- platform/apple2enh/Makefile.apple2enh | 2 + platform/apple2enh/contiki-conf.h | 125 ++++++++++++++++++++++++++ platform/apple2enh/contiki-main.c | 119 ++++++++++++++++++++++++ 3 files changed, 246 insertions(+) create mode 100644 platform/apple2enh/Makefile.apple2enh create mode 100644 platform/apple2enh/contiki-conf.h create mode 100644 platform/apple2enh/contiki-main.c diff --git a/platform/apple2enh/Makefile.apple2enh b/platform/apple2enh/Makefile.apple2enh new file mode 100644 index 000000000..d3c819f67 --- /dev/null +++ b/platform/apple2enh/Makefile.apple2enh @@ -0,0 +1,2 @@ +CONTIKI_CPU = $(CONTIKI)/cpu/6502 +include $(CONTIKI_CPU)/Makefile.6502 diff --git a/platform/apple2enh/contiki-conf.h b/platform/apple2enh/contiki-conf.h new file mode 100644 index 000000000..a1b2742c2 --- /dev/null +++ b/platform/apple2enh/contiki-conf.h @@ -0,0 +1,125 @@ +#ifndef __CONTIKI_CONF_H__ +#define __CONTIKI_CONF_H__ + +#define CC_CONF_REGISTER_ARGS 1 +#define CC_CONF_FASTCALL __fastcall__ + + + +#define CCIF +#define CLIF + + + +#define LOG_CONF_ENABLED 1 +#include "sys/log.h" +void debug_printf(char *format, ...); +void error_exit(char *message); + + + +#define CLOCK_CONF_SECOND 2 +typedef unsigned short clock_time_t; + + + +#include +#define ctk_arch_isprint isprint + +typedef char ctk_arch_key_t; + +#define CH_ULCORNER 0xDA +#define CH_URCORNER 0xBF +#define CH_LLCORNER 0xC0 +#define CH_LRCORNER 0xD9 +#define CH_ENTER '\r' +#define CH_DEL '\b' +#define CH_CURS_UP -1 +#define CH_CURS_LEFT -2 +#define CH_CURS_RIGHT -3 +#define CH_CURS_DOWN -4 + +#define CTK_CONF_MENU_KEY CH_ESC +#define CTK_CONF_WINDOWSWITCH_KEY 0x17 /* Ctrl-W */ +#define CTK_CONF_WIDGETDOWN_KEY '\t' /* Tab or Ctrl-I */ +#define CTK_CONF_WIDGETUP_KEY 0x01 /* Ctrl-A */ +#define CTK_CONF_MOUSE_SUPPORT 0 +#define CTK_CONF_ICONS 1 +#define CTK_CONF_ICON_BITMAPS 0 +#define CTK_CONF_ICON_TEXTMAPS 1 +#define CTK_CONF_WINDOWMOVE 1 +#define CTK_CONF_WINDOWCLOSE 1 +#define CTK_CONF_MENUS 1 +#define CTK_CONF_MENUWIDTH 16 +#define CTK_CONF_MAXMENUITEMS 10 +#define CTK_CONF_WIDGET_FLAGS 0 +#define CTK_CONF_SCREENSAVER 0 + +#define BORDERCOLOR COLOR_BLACK +#define SCREENCOLOR COLOR_BLACK +#define BACKGROUNDCOLOR COLOR_BLACK +#define WINDOWCOLOR_FOCUS COLOR_WHITE +#define WINDOWCOLOR COLOR_WHITE +#define DIALOGCOLOR COLOR_WHITE +#define WIDGETCOLOR_HLINK COLOR_WHITE +#define WIDGETCOLOR_FWIN COLOR_WHITE +#define WIDGETCOLOR COLOR_WHITE +#define WIDGETCOLOR_DIALOG COLOR_WHITE +#define WIDGETCOLOR_FOCUS COLOR_WHITE +#define MENUCOLOR COLOR_WHITE +#define OPENMENUCOLOR COLOR_WHITE +#define ACTIVEMENUITEMCOLOR COLOR_WHITE + + + +#define EMAIL_CONF_WIDTH 48 +#define EMAIL_CONF_HEIGHT 16 + + + +#define IRC_CONF_WIDTH 78 +#define IRC_CONF_HEIGHT 20 +#define IRC_CONF_SYSTEM_STRING "Apple2" + + + +//#define LOADER_CONF_ARCH "loader/dll-loader.h" + +#define PROGRAM_HANDLER_CONF_MAX_NUMDSCS 6 +#define PROGRAM_HANDLER_CONF_QUIT_MENU 1 + + + +#define SHELL_GUI_CONF_XSIZE 38 +#define SHELL_GUI_CONF_YSIZE 12 + + + +typedef unsigned char u8_t; +typedef unsigned short u16_t; +typedef unsigned long u32_t; +typedef unsigned short uip_stats_t; + +#define UIP_CONF_MAX_CONNECTIONS 10 +#define UIP_CONF_MAX_LISTENPORTS 10 +#define UIP_CONF_BUFFER_SIZE (1024 - 2) +#define UIP_CONF_BYTE_ORDER LITTLE_ENDIAN +#define UIP_CONF_TCP_SPLIT 1 +#define UIP_CONF_LOGGING 1 +#define UIP_CONF_UDP_CHECKSUMS 1 + + + +#define WWW_CONF_WEBPAGE_WIDTH 78 +#define WWW_CONF_WEBPAGE_HEIGHT 16 +#define WWW_CONF_HISTORY_SIZE 4 +#define WWW_CONF_MAX_URLLEN 78 +#define WWW_CONF_MAX_NUMPAGEWIDGETS 26 +#define WWW_CONF_RENDERSTATE 1 +#define WWW_CONF_FORMS 1 +#define WWW_CONF_MAX_FORMACTIONLEN 30 +#define WWW_CONF_MAX_FORMNAMELEN 20 +#define WWW_CONF_MAX_INPUTNAMELEN 20 +#define WWW_CONF_MAX_INPUTVALUELEN (WWW_CONF_WEBPAGE_WIDTH - 1) + +#endif /* __CONTIKI_CONF_H__ */ diff --git a/platform/apple2enh/contiki-main.c b/platform/apple2enh/contiki-main.c new file mode 100644 index 000000000..5c5a025e4 --- /dev/null +++ b/platform/apple2enh/contiki-main.c @@ -0,0 +1,119 @@ +/* + * Copyright (c) 2006, Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 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. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * This file is part of the Contiki operating system. + * + * Author: Oliver Schmidt + * + * $Id: contiki-main.c,v 1.1 2007/01/03 10:29:17 oliverschmidt Exp $ + */ + +#include + +#include "contiki.h" +#include "contiki-net.h" + +#include "sys/clock.h" +#include "sys/etimer.h" + +PROCINIT(&etimer_process, + &tcpip_process, + &resolv_process); + +#if CTK_CONF_MOUSE_SUPPORT +#define TICK_COUNT 2800 +#else +#define TICK_COUNT 4200 +#endif + +/*-----------------------------------------------------------------------------------*/ +void +uip_log(char *message) +{ + fprintf(stderr, "%s\n", message); +} +/*-----------------------------------------------------------------------------------*/ +void +log_message(const char *part1, const char *part2) +{ + fprintf(stderr, "%s%s\n", part1, part2); +} +/*-----------------------------------------------------------------------------------*/ +clock_time_t +clock_time(void) +{ + static clock_time_t count, clock; + +// count += tick; + count += 1; + + if(count == TICK_COUNT) { + count = 0; + ++clock; + } + + return clock; +} +/*-----------------------------------------------------------------------------------*/ +void +main(void) +{ + process_init(); + + procinit_init(); + + autostart_start((struct process **)autostart_processes); + +#if 1 + { + uip_ipaddr_t addr; + uip_ipaddr(&addr, 192,168,0,222); + uip_sethostaddr(&addr); + + uip_ipaddr(&addr, 255,255,255,0); + uip_setnetmask(&addr); + + uip_ipaddr(&addr, 192,168,0,1); + uip_setdraddr(&addr); + + uip_ipaddr(&addr, 192,168,0,1); + resolv_conf(&addr); + } +#endif + + printf("Contiki initiated, now starting process scheduling\n"); + + while(1) { + + if(process_run() < 2) { + + etimer_request_poll(); + } + } +} +/*-----------------------------------------------------------------------------------*/