Removed pc-6001 platform
This commit is contained in:
parent
44370be06f
commit
13117203e0
|
@ -1,87 +0,0 @@
|
||||||
#
|
|
||||||
# Makefile for PC-6001 using z80/SDCC
|
|
||||||
# @author Takahide Matsutsuka <markn@markn.org>
|
|
||||||
#
|
|
||||||
# $Id: Makefile,v 1.7 2009/12/16 06:47:18 matsutsuka Exp $
|
|
||||||
#
|
|
||||||
|
|
||||||
CONTIKI = ../..
|
|
||||||
TARGET=pc-6001
|
|
||||||
APPS_DESKTOP = program-handler calc process-list shell about
|
|
||||||
APPS_NETWORK_CLIENT = $(APPS_DESKTOP) netconf webbrowser email telnet ftp irc
|
|
||||||
APPS_NETWORK_SERVER = program-handler cmdd telnetd shell
|
|
||||||
# editor netconf dhcp webbrowser ftp irc email telnet telnetd
|
|
||||||
# cmdd codeprop webserver vnc
|
|
||||||
# directory
|
|
||||||
|
|
||||||
PLATFORM_APPS_DESKTOP = multithread tinysample
|
|
||||||
PLATFORM_APPS_NETWORK = webserver-mini
|
|
||||||
PLATFORM_APPS=$(PLATFORM_APPS_DESKTOP)
|
|
||||||
|
|
||||||
ifeq ($(MAKECMDGOALS),client)
|
|
||||||
APPS = $(APPS_NETWORK_CLIENT)
|
|
||||||
else ifeq ($(MAKECMDGOALS),server)
|
|
||||||
APPS = $(APPS_NETWORK_SERVER)
|
|
||||||
else
|
|
||||||
APPS = $(APPS_DESKTOP)
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Default values
|
|
||||||
MEMORY=32K
|
|
||||||
PLATFORM_APPS=$(PLATFORM_APPS_DESKTOP)
|
|
||||||
CONTIKI_TARGET_MAIN = contiki-desktop-main.c
|
|
||||||
CTKCONF = NORMAL
|
|
||||||
LOADER = 0
|
|
||||||
|
|
||||||
# Target dependent options
|
|
||||||
ifeq ($(MAKECMDGOALS),p62)
|
|
||||||
ARCH=PC6001MK2
|
|
||||||
else ifeq ($(MAKECMDGOALS),p6A)
|
|
||||||
ARCH=PC6001A
|
|
||||||
else ifeq ($(MAKECMDGOALS),minimal)
|
|
||||||
MEMORY=16K
|
|
||||||
CONTIKI_TARGET_MAIN=contiki-minimal-main.c
|
|
||||||
else ifeq ($(MAKECMDGOALS),serial)
|
|
||||||
CONTIKI_TARGET_MAIN=contiki-serial-main.c
|
|
||||||
else ifeq ($(MAKECMDGOALS),rom)
|
|
||||||
CTKCONF=NOICON
|
|
||||||
MEMORY=ROM
|
|
||||||
LOADER = 1
|
|
||||||
CONTIKI_TARGET_MAIN=contiki-loader-main.c
|
|
||||||
else ifeq ($(MAKECMDGOALS),load)
|
|
||||||
CTKCONF=NOICON
|
|
||||||
LOADER = 1
|
|
||||||
CONTIKI_TARGET_MAIN=contiki-loader-main.c
|
|
||||||
else ifeq ($(MAKECMDGOALS),server)
|
|
||||||
CTKCONF=SERVER
|
|
||||||
PLATFORM_APPS = $(PLATFORM_APPS_NETWORK)
|
|
||||||
CONTIKI_TARGET_MAIN=contiki-server-main.c
|
|
||||||
else ifeq ($(MAKECMDGOALS),client)
|
|
||||||
CTKCONF=CLIENT
|
|
||||||
PLATFORM_APPS = $(PLATFORM_APPS_NETWORK)
|
|
||||||
CONTIKI_TARGET_MAIN=contiki-client-main.c
|
|
||||||
endif
|
|
||||||
|
|
||||||
all : p6
|
|
||||||
|
|
||||||
p6 : contiki
|
|
||||||
p62 : contiki
|
|
||||||
p6A : contiki
|
|
||||||
minimal : contiki
|
|
||||||
serial : contiki
|
|
||||||
rom : contiki.rom
|
|
||||||
load : contiki
|
|
||||||
server : contiki
|
|
||||||
client : contiki
|
|
||||||
|
|
||||||
remove-ctk:
|
|
||||||
rm -f obj_$(TARGET)/ctk*;
|
|
||||||
rm -f contiki.ihex
|
|
||||||
remove-net:
|
|
||||||
rm -f ${addprefix obj_$(TARGET)/,uip*.o hc.o psock.o rawpacket-udp.o resolv.o slip*.o tcp*.o uaod*.o rime*.o http*.o web*.o};
|
|
||||||
rm -f contiki.ihex
|
|
||||||
remove-mt:
|
|
||||||
rm -f obj_$(TARGET)/mt*.o
|
|
||||||
rm -f contiki.ihex
|
|
||||||
|
|
||||||
include $(CONTIKI)/Makefile.include
|
|
|
@ -1,103 +0,0 @@
|
||||||
#
|
|
||||||
# Makefile for PC-6001 using z80/SDCC
|
|
||||||
# @author Takahide Matsutsuka <markn@markn.org>
|
|
||||||
#
|
|
||||||
# $Id: Makefile.pc-6001,v 1.13 2009/12/16 06:47:18 matsutsuka Exp $
|
|
||||||
#
|
|
||||||
|
|
||||||
ifndef CONTIKI
|
|
||||||
$(error CONTIKI not defined! You must specify where CONTIKI resides!)
|
|
||||||
endif
|
|
||||||
|
|
||||||
### setup default values
|
|
||||||
ifndef ARCH
|
|
||||||
ARCH=PC6001
|
|
||||||
endif
|
|
||||||
ifndef MEMORY
|
|
||||||
MEMORY=32K
|
|
||||||
endif
|
|
||||||
ifndef CONTIKI_TARGET_MAIN
|
|
||||||
CONTIKI_TARGET_MAIN = contiki-main.c
|
|
||||||
endif
|
|
||||||
ifndef CTKCONF
|
|
||||||
CTKCONF=NORMAL
|
|
||||||
endif
|
|
||||||
ifndef LOADER
|
|
||||||
LOADER=0
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifndef HEX2BIN
|
|
||||||
HEX2BINDIR = ../../tools/z80/hex2bin/
|
|
||||||
HEX2BIN = $(HEX2BINDIR)/hexameter
|
|
||||||
endif
|
|
||||||
|
|
||||||
### setup flags to be used in compiler, assembler, and HEX2BIN
|
|
||||||
PLATFORM = $(CONTIKI)/platform/$(TARGET)
|
|
||||||
CONTIKI_TARGET_DIRS = . ctk dev loader
|
|
||||||
CFLAGS += -DMEMORY_$(MEMORY) -DARCH_$(ARCH) -DCTK_$(CTKCONF)
|
|
||||||
|
|
||||||
ifeq ($(MEMORY),16K)
|
|
||||||
LDFLAGS += --code-loc 0xc40f --data-loc 0
|
|
||||||
HEX2BINFLAGS = -d TAPE=contki $(HEX2BINDIR)/ihx/mode1.ihx -o contiki.p6
|
|
||||||
else ifeq ($(MEMORY),ROM)
|
|
||||||
LDFLAGS += --code-loc 0x4004 --data-loc 0xf000
|
|
||||||
HEX2BINFLAGS = -d ROMEXEC=4004 $(HEX2BINDIR)/ihx/rom60.ihx -b 4000 -o contiki.rom
|
|
||||||
else ifeq ($(ARCH),PC6001MK2)
|
|
||||||
LDFLAGS += --code-loc 0x800f --data-loc 0
|
|
||||||
HEX2BINFLAGS = -d TAPE=contki $(HEX2BINDIR)/ihx/mode5.ihx -o contiki2.p6
|
|
||||||
else
|
|
||||||
LDFLAGS += --code-loc 0x840f --data-loc 0
|
|
||||||
HEX2BINFLAGS = -d TAPE=contki $(HEX2BINDIR)/ihx/mode2.ihx -o contiki.p6
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(LOADER),1)
|
|
||||||
CFLAGS += -DWITH_LOADER_ARCH=1
|
|
||||||
endif
|
|
||||||
|
|
||||||
### Include platform-depend application makefiles
|
|
||||||
|
|
||||||
ifdef PLATFORM_APPS
|
|
||||||
PLATFORM_APPDIRS += ${addprefix $(PLATFORM)/apps/, $(PLATFORM_APPS)}
|
|
||||||
PLATFORM_APPINCLUDES = ${foreach APP, $(PLATFORM_APPS), $(PLATFORM)/apps/$(APP)/Makefile.$(APP)}
|
|
||||||
-include $(PLATFORM_APPINCLUDES)
|
|
||||||
PLATFORM_APP_SOURCES = ${foreach APP, $(PLATFORM_APPS), $($(APP)_src)}
|
|
||||||
PLATFORM_DSC_SOURCES = ${foreach APP, $(PLATFORM_APPS), $($(APP)_dsc)}
|
|
||||||
CONTIKI_SOURCEFILES += $(PLATFORM_APP_SOURCES) $(PLATFORM_DSC_SOURCES)
|
|
||||||
endif
|
|
||||||
|
|
||||||
CONTIKI_TARGET_SOURCEFILES = \
|
|
||||||
$(CTK) cfs-ram.c serial-line.c slip.c \
|
|
||||||
resolv.c loader_arch.c \
|
|
||||||
ctk-conio_arch.c $(CONTIKI_TARGET_MAIN)
|
|
||||||
|
|
||||||
#you can use the below instead of ctk-conio_arch.c, ctk-conio_arch-asm.cS,
|
|
||||||
# and libconio_arch-asm.cS
|
|
||||||
#ctk-conio_arch-source.c
|
|
||||||
|
|
||||||
CONTIKI_ASMFILES += getkey.S isprint_arch.S clock.S rs232-asm.S
|
|
||||||
CONTIKI_CASMFILES += ctk-conio_arch-asm.cS libconio_arch-asm.cS\
|
|
||||||
libconio_arch-small.cS
|
|
||||||
|
|
||||||
CONTIKI_SOURCEFILES += $(CONTIKI_TARGET_SOURCEFILES)
|
|
||||||
|
|
||||||
CLEAN += *.rom *.p6
|
|
||||||
|
|
||||||
contiki: $(HEX2BIN) contiki.p6
|
|
||||||
|
|
||||||
.SUFFIXES:
|
|
||||||
|
|
||||||
%.p6: %.ihx
|
|
||||||
$(HEX2BIN) $(HEX2BINFLAGS) $< $(HEX2BINDIR)/ihx/suffix.ihx
|
|
||||||
%.rom: %.ihx
|
|
||||||
$(HEX2BIN) $(HEX2BINFLAGS) $<
|
|
||||||
|
|
||||||
$(HEX2BIN):
|
|
||||||
cd $(HEX2BINDIR); make
|
|
||||||
|
|
||||||
### Define the CPU directory
|
|
||||||
CONTIKI_CPU=$(CONTIKI)/cpu/z80
|
|
||||||
include $(CONTIKI_CPU)/Makefile.z80
|
|
||||||
|
|
||||||
### Setup directory search path for source files
|
|
||||||
PROJECTDIRS += $(PLATFORM_APPDIRS)
|
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
multithread_src = mt-test.c
|
|
||||||
multithread_dsc = mt-test-dsc.c
|
|
|
@ -1,38 +0,0 @@
|
||||||
#include "sys/dsc.h"
|
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------------------*/
|
|
||||||
#if CTK_CONF_ICON_BITMAPS
|
|
||||||
static unsigned char mttesticon_bitmap[3*3*8] = {
|
|
||||||
0x00, 0x7f, 0x43, 0x4c, 0x58, 0x53, 0x60, 0x6f,
|
|
||||||
0x00, 0xff, 0x00, 0x7e, 0x00, 0xff, 0x00, 0xff,
|
|
||||||
0x00, 0xfe, 0xc2, 0x32, 0x1a, 0xca, 0x06, 0xf6,
|
|
||||||
|
|
||||||
0x40, 0x5f, 0x40, 0x5f, 0x40, 0x5f, 0x40, 0x4f,
|
|
||||||
0x00, 0xff, 0x00, 0xff, 0x00, 0xfc, 0x01, 0xf3,
|
|
||||||
0x02, 0xfa, 0x02, 0x82, 0x3e, 0xfe, 0xfe, 0xfe,
|
|
||||||
|
|
||||||
0x60, 0x67, 0x50, 0x59, 0x4c, 0x43, 0x7f, 0x00,
|
|
||||||
0x07, 0xe7, 0x0f, 0xef, 0x0f, 0x0f, 0xff, 0x00,
|
|
||||||
0x8e, 0x06, 0x06, 0x06, 0x8e, 0xfe, 0xfe, 0x00
|
|
||||||
};
|
|
||||||
#endif /* CTK_CONF_ICON_BITMAPS */
|
|
||||||
|
|
||||||
#if CTK_CONF_ICON_TEXTMAPS
|
|
||||||
static char mttesticon_textmap[9] = {
|
|
||||||
'T', 'h', 'r',
|
|
||||||
'e', 'a', 'd',
|
|
||||||
'=', '=', '>'
|
|
||||||
};
|
|
||||||
#endif /* CTK_CONF_ICON_TEXTMAPS */
|
|
||||||
|
|
||||||
#if CTK_CONF_ICONS
|
|
||||||
static struct ctk_icon mttest_icon =
|
|
||||||
{CTK_ICON("Multithread test", mttesticon_bitmap, mttesticon_textmap)};
|
|
||||||
#endif /* CTK_CONF_ICONS */
|
|
||||||
/*-----------------------------------------------------------------------------------*/
|
|
||||||
DSC(mttest_dsc,
|
|
||||||
"MultithreadTest",
|
|
||||||
"mt-test.prg",
|
|
||||||
mt_process,
|
|
||||||
&mttest_icon);
|
|
||||||
/*-----------------------------------------------------------------------------------*/
|
|
|
@ -1,7 +0,0 @@
|
||||||
#ifndef MTTESTDSC_H_
|
|
||||||
#define MTTESTDSC_H_
|
|
||||||
#include "sys/dsc.h"
|
|
||||||
|
|
||||||
DSC_HEADER(mttest_dsc);
|
|
||||||
|
|
||||||
#endif /*MTTESTDSC_H_*/
|
|
|
@ -1,147 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2007, 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 <ol.sc@web.de>
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \file
|
|
||||||
* A very simple Contiki application showing how to use the Contiki
|
|
||||||
* Multi-threading library
|
|
||||||
* \author
|
|
||||||
* Oliver Schmidt <ol.sc@web.de>
|
|
||||||
* \author for PC-6001 version
|
|
||||||
* Takahide Matsutsuka <markn@markn.org>
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#include "contiki.h"
|
|
||||||
#include "ctk.h"
|
|
||||||
#include "sys/mt.h"
|
|
||||||
#include "mtarch.h"
|
|
||||||
|
|
||||||
#define WIN_XSIZE 10
|
|
||||||
#define WIN_YSIZE 10
|
|
||||||
|
|
||||||
static char log[WIN_XSIZE * WIN_YSIZE];
|
|
||||||
static struct ctk_window window;
|
|
||||||
static struct ctk_label loglabel = {CTK_LABEL(0, 0, WIN_XSIZE, WIN_YSIZE, log)};
|
|
||||||
PROCESS(mt_process, "Multi-threading test");
|
|
||||||
|
|
||||||
static char buf[20];
|
|
||||||
|
|
||||||
void
|
|
||||||
println(char *str1)
|
|
||||||
{
|
|
||||||
unsigned int i;
|
|
||||||
|
|
||||||
for(i = 1; i < WIN_YSIZE; i++) {
|
|
||||||
memcpy(&log[(i - 1) * WIN_XSIZE], &log[i * WIN_XSIZE], WIN_XSIZE);
|
|
||||||
}
|
|
||||||
memset(&log[(WIN_YSIZE - 1) * WIN_XSIZE], 0, WIN_XSIZE);
|
|
||||||
|
|
||||||
strncpy(&log[(WIN_YSIZE - 1) * WIN_XSIZE], str1, WIN_XSIZE);
|
|
||||||
|
|
||||||
CTK_WIDGET_REDRAW(&loglabel);
|
|
||||||
}
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
static void
|
|
||||||
thread_func(char *str, int len)
|
|
||||||
{
|
|
||||||
println((char *) (str + len));
|
|
||||||
mt_yield();
|
|
||||||
|
|
||||||
if(len) {
|
|
||||||
thread_func(str, len - 1);
|
|
||||||
mt_yield();
|
|
||||||
}
|
|
||||||
|
|
||||||
println((char *) (str + len));
|
|
||||||
}
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
static void
|
|
||||||
thread_main(void *data)
|
|
||||||
{
|
|
||||||
while(1) {
|
|
||||||
thread_func((char *)data, 9);
|
|
||||||
}
|
|
||||||
mt_exit();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
PROCESS_THREAD(mt_process, ev, data)
|
|
||||||
{
|
|
||||||
|
|
||||||
static struct etimer timer;
|
|
||||||
static int toggle = 0;
|
|
||||||
static struct mt_thread th1;
|
|
||||||
static struct mt_thread th2;
|
|
||||||
|
|
||||||
PROCESS_BEGIN();
|
|
||||||
|
|
||||||
ctk_window_new(&window, WIN_XSIZE, WIN_YSIZE, "Multithread");
|
|
||||||
CTK_WIDGET_ADD(&window, &loglabel);
|
|
||||||
memset(log, 0, sizeof(log));
|
|
||||||
ctk_window_open(&window);
|
|
||||||
mt_init();
|
|
||||||
mt_start(&th1, thread_main, "JIHGFEDCBA");
|
|
||||||
mt_start(&th2, thread_main, "9876543210");
|
|
||||||
|
|
||||||
etimer_set(&timer, CLOCK_SECOND / 2);
|
|
||||||
while(1) {
|
|
||||||
PROCESS_WAIT_EVENT();
|
|
||||||
if(ev == PROCESS_EVENT_TIMER) {
|
|
||||||
if(toggle) {
|
|
||||||
mt_exec(&th1);
|
|
||||||
toggle--;
|
|
||||||
} else {
|
|
||||||
mt_exec(&th2);
|
|
||||||
toggle++;
|
|
||||||
}
|
|
||||||
etimer_set(&timer, CLOCK_SECOND / 2);
|
|
||||||
} else if(ev == ctk_signal_window_close || ev == PROCESS_EVENT_EXIT) {
|
|
||||||
ctk_window_close(&window);
|
|
||||||
process_exit(&mt_process);
|
|
||||||
LOADER_UNLOAD();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
mt_stop(&th1);
|
|
||||||
mt_stop(&th2);
|
|
||||||
mt_remove();
|
|
||||||
|
|
||||||
while(1) {
|
|
||||||
PROCESS_WAIT_EVENT();
|
|
||||||
}
|
|
||||||
PROCESS_END();
|
|
||||||
}
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
|
@ -1,2 +0,0 @@
|
||||||
tinysample_src = tinysample.c
|
|
||||||
tinysample_dsc = tinysample-dsc.c
|
|
|
@ -1,79 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2007, Takahide Matsutsuka.
|
|
||||||
* 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 <ol.sc@web.de>
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \file
|
|
||||||
* A very small sample Contiki application using console.
|
|
||||||
* \author
|
|
||||||
* Takahide Matsutsuka <markn@markn.org>
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "sys/dsc.h"
|
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------------------*/
|
|
||||||
#if CTK_CONF_ICON_BITMAPS
|
|
||||||
static unsigned char tiny_bitmap[3*3*8] = {
|
|
||||||
0x00, 0x7f, 0x43, 0x4c, 0x58, 0x53, 0x60, 0x6f,
|
|
||||||
0x00, 0xff, 0x00, 0x7e, 0x00, 0xff, 0x00, 0xff,
|
|
||||||
0x00, 0xfe, 0xc2, 0x32, 0x1a, 0xca, 0x06, 0xf6,
|
|
||||||
|
|
||||||
0x40, 0x5f, 0x40, 0x5f, 0x40, 0x5f, 0x40, 0x4f,
|
|
||||||
0x00, 0xff, 0x00, 0xff, 0x00, 0xfc, 0x01, 0xf3,
|
|
||||||
0x02, 0xfa, 0x02, 0x82, 0x3e, 0xfe, 0xfe, 0xfe,
|
|
||||||
|
|
||||||
0x60, 0x67, 0x50, 0x59, 0x4c, 0x43, 0x7f, 0x00,
|
|
||||||
0x07, 0xe7, 0x0f, 0xef, 0x0f, 0x0f, 0xff, 0x00,
|
|
||||||
0x8e, 0x06, 0x06, 0x06, 0x8e, 0xfe, 0xfe, 0x00
|
|
||||||
};
|
|
||||||
#endif /* CTK_CONF_ICON_BITMAPS */
|
|
||||||
|
|
||||||
#if CTK_CONF_ICON_TEXTMAPS
|
|
||||||
static char tiny_textmap[9] = {
|
|
||||||
'T', 'i', 'n',
|
|
||||||
'y', 'S', 'a',
|
|
||||||
'm', 'p', 'l'
|
|
||||||
};
|
|
||||||
#endif /* CTK_CONF_ICON_TEXTMAPS */
|
|
||||||
|
|
||||||
#if CTK_CONF_ICONS
|
|
||||||
static struct ctk_icon tiny_icon =
|
|
||||||
{CTK_ICON("Tiny sample", tiny_bitmap, tiny_textmap)};
|
|
||||||
#endif /* CTK_CONF_ICONS */
|
|
||||||
/*-----------------------------------------------------------------------------------*/
|
|
||||||
DSC(tiny_dsc,
|
|
||||||
"Tinysample",
|
|
||||||
"tinysmaple.prg",
|
|
||||||
tiny_process,
|
|
||||||
&tiny_icon);
|
|
||||||
/*-----------------------------------------------------------------------------------*/
|
|
|
@ -1,48 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2007, Takahide Matsutsuka.
|
|
||||||
* 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 <ol.sc@web.de>
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \file
|
|
||||||
* A very small sample Contiki application using console.
|
|
||||||
* \author
|
|
||||||
* Takahide Matsutsuka <markn@markn.org>
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef TINYSAMPLE_DSC_H_
|
|
||||||
#define TINYSAMPLE_DSC_H_
|
|
||||||
#include "sys/dsc.h"
|
|
||||||
|
|
||||||
DSC_HEADER(tiny_dsc);
|
|
||||||
|
|
||||||
#endif /*TINYSAMPLE_DSC_H_*/
|
|
|
@ -1,67 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2007, Takahide Matsutsuka.
|
|
||||||
* 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 <ol.sc@web.de>
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \file
|
|
||||||
* A very small sample Contiki application using console.
|
|
||||||
* \author
|
|
||||||
* Takahide Matsutsuka <markn@markn.org>
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "contiki.h"
|
|
||||||
#include "libconio_arch-small.h"
|
|
||||||
|
|
||||||
PROCESS(tiny_process, "Tiny Sample");
|
|
||||||
|
|
||||||
static char ch[] = "A";
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
PROCESS_THREAD(tiny_process, ev, data)
|
|
||||||
{
|
|
||||||
static struct etimer timer;
|
|
||||||
|
|
||||||
PROCESS_BEGIN();
|
|
||||||
|
|
||||||
clrscr_arch();
|
|
||||||
|
|
||||||
while(1) {
|
|
||||||
etimer_set(&timer, CLOCK_SECOND / 32);
|
|
||||||
PROCESS_WAIT_EVENT();
|
|
||||||
if(etimer_expired(&timer)) {
|
|
||||||
libputs_arch(ch);
|
|
||||||
ch[0]++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
PROCESS_END();
|
|
||||||
}
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
|
@ -1,2 +0,0 @@
|
||||||
webserver-mini_src = webserver-nogui.c httpd.c http-strings.c psock.c memb.c \
|
|
||||||
httpd-fs.c httpd-cgi.c
|
|
|
@ -1,34 +0,0 @@
|
||||||
http_http "http://"
|
|
||||||
http_200 "200 "
|
|
||||||
http_301 "301 "
|
|
||||||
http_302 "302 "
|
|
||||||
http_get "GET "
|
|
||||||
http_10 "HTTP/1.0"
|
|
||||||
http_11 "HTTP/1.1"
|
|
||||||
http_content_type "content-type: "
|
|
||||||
http_texthtml "text/html"
|
|
||||||
http_location "location: "
|
|
||||||
http_host "host: "
|
|
||||||
http_crnl "\n"
|
|
||||||
http_index_html "/index.html"
|
|
||||||
http_404_html "/404.html"
|
|
||||||
http_referer "Referer:"
|
|
||||||
http_header_200 "HTTP/1.0 200 OK\nServer: Contiki/2.0\nConnection: close\n"
|
|
||||||
http_header_404 "HTTP/1.0 404 Not found\nServer: Contiki/2.0\nConnection: close\n"
|
|
||||||
http_content_type_plain "Content-type: text/plain\n\n"
|
|
||||||
http_content_type_html "Content-type: text/html\n\n"
|
|
||||||
http_content_type_css "Content-type: text/css\n\n"
|
|
||||||
http_content_type_text "Content-type: text/text\n\n"
|
|
||||||
http_content_type_png "Content-type: image/png\n\n"
|
|
||||||
http_content_type_gif "Content-type: image/gif\n\n"
|
|
||||||
http_content_type_jpg "Content-type: image/jpeg\n\n"
|
|
||||||
http_content_type_binary "Content-type: application/octet-stream\n\n"
|
|
||||||
http_html ".html"
|
|
||||||
http_shtml ".shtml"
|
|
||||||
http_htm ".htm"
|
|
||||||
http_css ".css"
|
|
||||||
http_png ".png"
|
|
||||||
http_gif ".gif"
|
|
||||||
http_jpg ".jpg"
|
|
||||||
http_text ".text"
|
|
||||||
http_txt ".txt"
|
|
|
@ -1,36 +0,0 @@
|
||||||
const char http_200[5] =
|
|
||||||
/* "200 " */
|
|
||||||
{0x32, 0x30, 0x30, 0x20, };
|
|
||||||
const char http_get[5] =
|
|
||||||
/* "GET " */
|
|
||||||
{0x47, 0x45, 0x54, 0x20, };
|
|
||||||
const char http_index_html[12] =
|
|
||||||
/* "/index.html" */
|
|
||||||
{0x2f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, 0x6c, };
|
|
||||||
const char http_404_html[10] =
|
|
||||||
/* "/404.html" */
|
|
||||||
{0x2f, 0x34, 0x30, 0x34, 0x2e, 0x68, 0x74, 0x6d, 0x6c, };
|
|
||||||
const char http_referer[9] =
|
|
||||||
/* "Referer:" */
|
|
||||||
{0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x72, 0x3a, };
|
|
||||||
const char http_header_200[55] =
|
|
||||||
/* "HTTP/1.0 200 OK\nServer: Contiki/2.0\nConnection: close\n" */
|
|
||||||
{0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x32, 0x30, 0x30, 0x20, 0x4f, 0x4b, 0xa, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x3a, 0x20, 0x43, 0x6f, 0x6e, 0x74, 0x69, 0x6b, 0x69, 0x2f, 0x32, 0x2e, 0x30, 0xa, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x20, 0x63, 0x6c, 0x6f, 0x73, 0x65, 0xa, };
|
|
||||||
const char http_header_404[62] =
|
|
||||||
/* "HTTP/1.0 404 Not found\nServer: Contiki/2.0\nConnection: close\n" */
|
|
||||||
{0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x34, 0x30, 0x34, 0x20, 0x4e, 0x6f, 0x74, 0x20, 0x66, 0x6f, 0x75, 0x6e, 0x64, 0xa, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x3a, 0x20, 0x43, 0x6f, 0x6e, 0x74, 0x69, 0x6b, 0x69, 0x2f, 0x32, 0x2e, 0x30, 0xa, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x20, 0x63, 0x6c, 0x6f, 0x73, 0x65, 0xa, };
|
|
||||||
const char http_content_type_plain[27] =
|
|
||||||
/* "Content-type: text/plain\n\n" */
|
|
||||||
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x70, 0x6c, 0x61, 0x69, 0x6e, 0xa, 0xa, };
|
|
||||||
const char http_content_type_html[26] =
|
|
||||||
/* "Content-type: text/html\n\n" */
|
|
||||||
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0xa, 0xa, };
|
|
||||||
const char http_content_type_binary[41] =
|
|
||||||
/* "Content-type: application/octet-stream\n\n" */
|
|
||||||
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x6f, 0x63, 0x74, 0x65, 0x74, 0x2d, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0xa, 0xa, };
|
|
||||||
const char http_html[6] =
|
|
||||||
/* ".html" */
|
|
||||||
{0x2e, 0x68, 0x74, 0x6d, 0x6c, };
|
|
||||||
const char http_shtml[7] =
|
|
||||||
/* ".shtml" */
|
|
||||||
{0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, };
|
|
|
@ -1,34 +0,0 @@
|
||||||
extern const char http_http[8];
|
|
||||||
extern const char http_200[5];
|
|
||||||
extern const char http_301[5];
|
|
||||||
extern const char http_302[5];
|
|
||||||
extern const char http_get[5];
|
|
||||||
extern const char http_10[9];
|
|
||||||
extern const char http_11[9];
|
|
||||||
extern const char http_content_type[15];
|
|
||||||
extern const char http_texthtml[10];
|
|
||||||
extern const char http_location[11];
|
|
||||||
extern const char http_host[7];
|
|
||||||
extern const char http_crnl[2];
|
|
||||||
extern const char http_index_html[12];
|
|
||||||
extern const char http_404_html[10];
|
|
||||||
extern const char http_referer[9];
|
|
||||||
extern const char http_header_200[55];
|
|
||||||
extern const char http_header_404[62];
|
|
||||||
extern const char http_content_type_plain[27];
|
|
||||||
extern const char http_content_type_html[26];
|
|
||||||
extern const char http_content_type_css [25];
|
|
||||||
extern const char http_content_type_text[26];
|
|
||||||
extern const char http_content_type_png [26];
|
|
||||||
extern const char http_content_type_gif [26];
|
|
||||||
extern const char http_content_type_jpg [27];
|
|
||||||
extern const char http_content_type_binary[41];
|
|
||||||
extern const char http_html[6];
|
|
||||||
extern const char http_shtml[7];
|
|
||||||
extern const char http_htm[5];
|
|
||||||
extern const char http_css[5];
|
|
||||||
extern const char http_png[5];
|
|
||||||
extern const char http_gif[5];
|
|
||||||
extern const char http_jpg[5];
|
|
||||||
extern const char http_text[6];
|
|
||||||
extern const char http_txt[5];
|
|
|
@ -1,217 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2004, Adam Dunkels.
|
|
||||||
* 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: Adam Dunkels <adam@sics.se>
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include "contiki-net.h"
|
|
||||||
#include "cfs/cfs.h"
|
|
||||||
|
|
||||||
#include "webserver.h"
|
|
||||||
#include "libconio_arch-small.h"
|
|
||||||
|
|
||||||
#include "httpd-cfs.h"
|
|
||||||
|
|
||||||
#define STATE_WAITING 0
|
|
||||||
#define STATE_OUTPUT 1
|
|
||||||
|
|
||||||
#define SEND_STRING(s, str) PSOCK_SEND(s, str, strlen(str))
|
|
||||||
MEMB(conns, struct httpd_state, 2);
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
static
|
|
||||||
PT_THREAD(send_file(struct httpd_state *s))
|
|
||||||
{
|
|
||||||
PSOCK_BEGIN(&s->sout);
|
|
||||||
|
|
||||||
do {
|
|
||||||
/* Read data from file system into buffer */
|
|
||||||
s->len = cfs_read(s->fd, s->outputbuf, sizeof(s->outputbuf));
|
|
||||||
|
|
||||||
/* If there is data in the buffer, send it */
|
|
||||||
if(s->len > 0) {
|
|
||||||
PSOCK_SEND(&s->sout, s->outputbuf, s->len);
|
|
||||||
} else {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} while(s->len > 0);
|
|
||||||
|
|
||||||
PSOCK_END(&s->sout);
|
|
||||||
}
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
static
|
|
||||||
PT_THREAD(send_headers(struct httpd_state *s, char *statushdr))
|
|
||||||
{
|
|
||||||
char *ptr;
|
|
||||||
|
|
||||||
PSOCK_BEGIN(&s->sout);
|
|
||||||
|
|
||||||
SEND_STRING(&s->sout, statushdr);
|
|
||||||
SEND_STRING(&s->sout, "Server: " CONTIKI_VERSION_STRING "\r\n");
|
|
||||||
|
|
||||||
ptr = strrchr(s->filename, '.');
|
|
||||||
if(ptr == NULL) {
|
|
||||||
SEND_STRING(&s->sout, "Content-type: text/plain\r\n\r\n");
|
|
||||||
} else if(strncmp(".html", ptr, 5) == 0) {
|
|
||||||
SEND_STRING(&s->sout, "Content-type: text/html\r\n\r\n");
|
|
||||||
} else if(strncmp(".css", ptr, 4) == 0) {
|
|
||||||
SEND_STRING(&s->sout, "Content-type: text/css\r\n\r\n");
|
|
||||||
} else if(strncmp(".png", ptr, 4) == 0) {
|
|
||||||
SEND_STRING(&s->sout, "Content-type: image/png\r\n\r\n");
|
|
||||||
} else if(strncmp(".jpg", ptr, 4) == 0) {
|
|
||||||
SEND_STRING(&s->sout, "Content-type: image/jpeg\r\n\r\n");
|
|
||||||
} else {
|
|
||||||
SEND_STRING(&s->sout, "Content-type: application/octet-stream\r\n\r\n");
|
|
||||||
}
|
|
||||||
PSOCK_END(&s->sout);
|
|
||||||
}
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
static
|
|
||||||
PT_THREAD(handle_output(struct httpd_state *s))
|
|
||||||
{
|
|
||||||
PT_BEGIN(&s->outputpt);
|
|
||||||
|
|
||||||
s->fd = cfs_open(s->filename, CFS_READ);
|
|
||||||
if(s->fd < 0) {
|
|
||||||
s->fd = cfs_open("404.html", CFS_READ);
|
|
||||||
if(s->fd < 0) {
|
|
||||||
uip_abort();
|
|
||||||
PT_EXIT(&s->outputpt);
|
|
||||||
}
|
|
||||||
PT_WAIT_THREAD(&s->outputpt,
|
|
||||||
send_headers(s, "HTTP/1.0 404 Not found\r\n"));
|
|
||||||
PT_WAIT_THREAD(&s->outputpt,
|
|
||||||
send_file(s));
|
|
||||||
} else {
|
|
||||||
PT_WAIT_THREAD(&s->outputpt,
|
|
||||||
send_headers(s, "HTTP/1.0 200 OK\r\n"));
|
|
||||||
PT_WAIT_THREAD(&s->outputpt,
|
|
||||||
send_file(s));
|
|
||||||
cfs_close(s->fd);
|
|
||||||
}
|
|
||||||
PSOCK_CLOSE(&s->sout);
|
|
||||||
PT_END(&s->outputpt);
|
|
||||||
}
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
static
|
|
||||||
PT_THREAD(handle_input(struct httpd_state *s))
|
|
||||||
{
|
|
||||||
PSOCK_BEGIN(&s->sin);
|
|
||||||
|
|
||||||
PSOCK_READTO(&s->sin, ' ');
|
|
||||||
|
|
||||||
if(strncmp(s->inputbuf, "GET ", 4) != 0) {
|
|
||||||
PSOCK_CLOSE_EXIT(&s->sin);
|
|
||||||
}
|
|
||||||
PSOCK_READTO(&s->sin, ' ');
|
|
||||||
|
|
||||||
if(s->inputbuf[0] != '/') {
|
|
||||||
PSOCK_CLOSE_EXIT(&s->sin);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(s->inputbuf[1] == ' ') {
|
|
||||||
strncpy(s->filename, "index.html", sizeof(s->filename));
|
|
||||||
} else {
|
|
||||||
s->inputbuf[PSOCK_DATALEN(&s->sin) - 1] = 0;
|
|
||||||
strncpy(s->filename, &s->inputbuf[1], sizeof(s->filename));
|
|
||||||
}
|
|
||||||
|
|
||||||
// webserver_log_file(&uip_conn->ripaddr, s->filename);
|
|
||||||
libputs_arch(s->filename);
|
|
||||||
s->state = STATE_OUTPUT;
|
|
||||||
|
|
||||||
while(1) {
|
|
||||||
PSOCK_READTO(&s->sin, '\n');
|
|
||||||
|
|
||||||
if(strncmp(s->inputbuf, "Referer:", 8) == 0) {
|
|
||||||
s->inputbuf[PSOCK_DATALEN(&s->sin) - 2] = 0;
|
|
||||||
libputs_arch(&s->inputbuf[9]);
|
|
||||||
// webserver_log(&s->inputbuf[9]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
PSOCK_END(&s->sin);
|
|
||||||
}
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
static void
|
|
||||||
handle_connection(struct httpd_state *s)
|
|
||||||
{
|
|
||||||
handle_input(s);
|
|
||||||
if(s->state == STATE_OUTPUT) {
|
|
||||||
handle_output(s);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
void
|
|
||||||
httpd_appcall(void *state)
|
|
||||||
{
|
|
||||||
struct httpd_state *s = (struct httpd_state *)state;
|
|
||||||
|
|
||||||
if(uip_closed() || uip_aborted() || uip_timedout()) {
|
|
||||||
if(s != NULL) {
|
|
||||||
memb_free(&conns, s);
|
|
||||||
}
|
|
||||||
} else if(uip_connected()) {
|
|
||||||
s = (struct httpd_state *)memb_alloc(&conns);
|
|
||||||
if(s == NULL) {
|
|
||||||
uip_abort();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
tcp_markconn(uip_conn, s);
|
|
||||||
PSOCK_INIT(&s->sin, s->inputbuf, sizeof(s->inputbuf) - 1);
|
|
||||||
PSOCK_INIT(&s->sout, s->inputbuf, sizeof(s->inputbuf) - 1);
|
|
||||||
PT_INIT(&s->outputpt);
|
|
||||||
s->state = STATE_WAITING;
|
|
||||||
timer_set(&s->timer, CLOCK_SECOND * 10);
|
|
||||||
handle_connection(s);
|
|
||||||
} else if(s != NULL) {
|
|
||||||
if(uip_poll()) {
|
|
||||||
if(timer_expired(&s->timer)) {
|
|
||||||
uip_abort();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
timer_reset(&s->timer);
|
|
||||||
}
|
|
||||||
handle_connection(s);
|
|
||||||
} else {
|
|
||||||
uip_abort();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
void
|
|
||||||
httpd_init(void)
|
|
||||||
{
|
|
||||||
tcp_listen(UIP_HTONS(80));
|
|
||||||
memb_init(&conns);
|
|
||||||
}
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
|
@ -1,55 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2001, Adam Dunkels.
|
|
||||||
* 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. The name of the author may not be used to endorse or promote
|
|
||||||
* products derived from this software without specific prior
|
|
||||||
* written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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 uIP TCP/IP stack.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __HTTPD_CFS_H__
|
|
||||||
#define __HTTPD_CFS_H__
|
|
||||||
|
|
||||||
#include "contiki-net.h"
|
|
||||||
|
|
||||||
struct httpd_state {
|
|
||||||
struct timer timer;
|
|
||||||
struct psock sin, sout;
|
|
||||||
struct pt outputpt;
|
|
||||||
char inputbuf[50];
|
|
||||||
char outputbuf[UIP_TCP_MSS];
|
|
||||||
char filename[20];
|
|
||||||
char state;
|
|
||||||
int fd;
|
|
||||||
int len;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
void httpd_init(void);
|
|
||||||
void httpd_appcall(void *state);
|
|
||||||
|
|
||||||
#endif /* __HTTPD_CFS_H__ */
|
|
|
@ -1,245 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2001, Adam Dunkels.
|
|
||||||
* 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. The name of the author may not be used to endorse or promote
|
|
||||||
* products derived from this software without specific prior
|
|
||||||
* written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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 uIP TCP/IP stack.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file includes functions that are called by the web server
|
|
||||||
* scripts. The functions takes no argument, and the return value is
|
|
||||||
* interpreted as follows. A zero means that the function did not
|
|
||||||
* complete and should be invoked for the next packet as well. A
|
|
||||||
* non-zero value indicates that the function has completed and that
|
|
||||||
* the web server should move along to the next script line.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#include "contiki-net.h"
|
|
||||||
#include "httpd.h"
|
|
||||||
#include "httpd-cgi.h"
|
|
||||||
#include "httpd-fs.h"
|
|
||||||
|
|
||||||
#include "lib/petsciiconv.h"
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
|
|
||||||
static struct httpd_cgi_call *calls = NULL;
|
|
||||||
|
|
||||||
/*struct cgifunction {
|
|
||||||
char *name;
|
|
||||||
httpd_cgifunction function;
|
|
||||||
};
|
|
||||||
|
|
||||||
static struct cgifunction cgitab[] = {
|
|
||||||
{"file-stats", file_stats},
|
|
||||||
{"tcp-connections", tcp_stats},
|
|
||||||
{"processes", processes},
|
|
||||||
{NULL, NULL}
|
|
||||||
};*/
|
|
||||||
|
|
||||||
|
|
||||||
static const char closed[] = /* "CLOSED",*/
|
|
||||||
{0x43, 0x4c, 0x4f, 0x53, 0x45, 0x44, 0};
|
|
||||||
static const char syn_rcvd[] = /* "SYN-RCVD",*/
|
|
||||||
{0x53, 0x59, 0x4e, 0x2d, 0x52, 0x43, 0x56,
|
|
||||||
0x44, 0};
|
|
||||||
static const char syn_sent[] = /* "SYN-SENT",*/
|
|
||||||
{0x53, 0x59, 0x4e, 0x2d, 0x53, 0x45, 0x4e,
|
|
||||||
0x54, 0};
|
|
||||||
static const char established[] = /* "ESTABLISHED",*/
|
|
||||||
{0x45, 0x53, 0x54, 0x41, 0x42, 0x4c, 0x49, 0x53, 0x48,
|
|
||||||
0x45, 0x44, 0};
|
|
||||||
static const char fin_wait_1[] = /* "FIN-WAIT-1",*/
|
|
||||||
{0x46, 0x49, 0x4e, 0x2d, 0x57, 0x41, 0x49,
|
|
||||||
0x54, 0x2d, 0x31, 0};
|
|
||||||
static const char fin_wait_2[] = /* "FIN-WAIT-2",*/
|
|
||||||
{0x46, 0x49, 0x4e, 0x2d, 0x57, 0x41, 0x49,
|
|
||||||
0x54, 0x2d, 0x32, 0};
|
|
||||||
static const char closing[] = /* "CLOSING",*/
|
|
||||||
{0x43, 0x4c, 0x4f, 0x53, 0x49,
|
|
||||||
0x4e, 0x47, 0};
|
|
||||||
static const char time_wait[] = /* "TIME-WAIT,"*/
|
|
||||||
{0x54, 0x49, 0x4d, 0x45, 0x2d, 0x57, 0x41,
|
|
||||||
0x49, 0x54, 0};
|
|
||||||
static const char last_ack[] = /* "LAST-ACK"*/
|
|
||||||
{0x4c, 0x41, 0x53, 0x54, 0x2d, 0x41, 0x43,
|
|
||||||
0x4b, 0};
|
|
||||||
static const char none[] = "NONE";
|
|
||||||
static const char init[] = "INIT";
|
|
||||||
static const char running[] = "RUNNING";
|
|
||||||
static const char needs_poll[] = "NEEDS POLL";
|
|
||||||
|
|
||||||
static const char *states[] = {
|
|
||||||
closed,
|
|
||||||
syn_rcvd,
|
|
||||||
syn_sent,
|
|
||||||
established,
|
|
||||||
fin_wait_1,
|
|
||||||
fin_wait_2,
|
|
||||||
closing,
|
|
||||||
time_wait,
|
|
||||||
last_ack,
|
|
||||||
none,
|
|
||||||
init,
|
|
||||||
running,
|
|
||||||
needs_poll};
|
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
static
|
|
||||||
PT_THREAD(nullfunction(struct httpd_state *s, char *ptr))
|
|
||||||
{
|
|
||||||
PSOCK_BEGIN(&s->sout);
|
|
||||||
PSOCK_END(&s->sout);
|
|
||||||
}
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
httpd_cgifunction
|
|
||||||
httpd_cgi(char *name)
|
|
||||||
{
|
|
||||||
struct httpd_cgi_call *f;
|
|
||||||
|
|
||||||
/* Find the matching name in the table, return the function. */
|
|
||||||
for(f = calls; f != NULL; f = f->next) {
|
|
||||||
if(strncmp(f->name, name, strlen(f->name)) == 0) {
|
|
||||||
return f->function;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nullfunction;
|
|
||||||
}
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
static unsigned short
|
|
||||||
generate_file_stats(void *arg)
|
|
||||||
{
|
|
||||||
char *f = (char *)arg;
|
|
||||||
return sprintf((char *)uip_appdata, "%5u", httpd_fs_count(f));
|
|
||||||
}
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
static
|
|
||||||
PT_THREAD(file_stats(struct httpd_state *s, char *ptr))
|
|
||||||
{
|
|
||||||
PSOCK_BEGIN(&s->sout);
|
|
||||||
|
|
||||||
PSOCK_GENERATOR_SEND(&s->sout, generate_file_stats, (void *) (strchr(ptr, ' ') + 1));
|
|
||||||
|
|
||||||
PSOCK_END(&s->sout);
|
|
||||||
}
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
static unsigned short
|
|
||||||
make_tcp_stats(void *arg)
|
|
||||||
{
|
|
||||||
struct uip_conn *conn;
|
|
||||||
struct httpd_state *s = (struct httpd_state *)arg;
|
|
||||||
|
|
||||||
conn = &uip_conns[s->u.count];
|
|
||||||
return sprintf((char *)uip_appdata,
|
|
||||||
"<tr align=\"center\"><td>%d</td><td>%u.%u.%u.%u:%u</td><td>%s</td><td>%u</td><td>%u</td><td>%c %c</td></tr>\r\n",
|
|
||||||
uip_htons(conn->lport),
|
|
||||||
conn->ripaddr.u8[0],
|
|
||||||
conn->ripaddr.u8[1],
|
|
||||||
conn->ripaddr.u8[2],
|
|
||||||
conn->ripaddr.u8[3],
|
|
||||||
uip_htons(conn->rport),
|
|
||||||
states[conn->tcpstateflags & UIP_TS_MASK],
|
|
||||||
conn->nrtx,
|
|
||||||
conn->timer,
|
|
||||||
(uip_outstanding(conn))? '*':' ',
|
|
||||||
(uip_stopped(conn))? '!':' ');
|
|
||||||
}
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
static
|
|
||||||
PT_THREAD(tcp_stats(struct httpd_state *s, char *ptr))
|
|
||||||
{
|
|
||||||
|
|
||||||
PSOCK_BEGIN(&s->sout);
|
|
||||||
|
|
||||||
for(s->u.count = 0; s->u.count < UIP_CONNS; ++s->u.count) {
|
|
||||||
if((uip_conns[s->u.count].tcpstateflags & UIP_TS_MASK) != UIP_CLOSED) {
|
|
||||||
PSOCK_GENERATOR_SEND(&s->sout, make_tcp_stats, s);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
PSOCK_END(&s->sout);
|
|
||||||
}
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
static unsigned short
|
|
||||||
make_processes(void *p)
|
|
||||||
{
|
|
||||||
char name[40];
|
|
||||||
|
|
||||||
strncpy(name, PROCESS_NAME_STRING((struct process *)p), 40);
|
|
||||||
petsciiconv_toascii(name, 40);
|
|
||||||
|
|
||||||
return sprintf((char *)uip_appdata,
|
|
||||||
"<tr align=\"center\"><td>%p</td><td>%s</td><td>%p</td><td>%s</td></tr>\r\n",
|
|
||||||
p, name,
|
|
||||||
(char *)((struct process *)p)->thread,
|
|
||||||
states[9 + ((struct process *)p)->state]);
|
|
||||||
}
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
static
|
|
||||||
PT_THREAD(processes(struct httpd_state *s, char *ptr))
|
|
||||||
{
|
|
||||||
PSOCK_BEGIN(&s->sout);
|
|
||||||
for(s->u.ptr = PROCESS_LIST(); s->u.ptr != NULL; s->u.ptr = ((struct process *)s->u.ptr)->next) {
|
|
||||||
PSOCK_GENERATOR_SEND(&s->sout, make_processes, s->u.ptr);
|
|
||||||
}
|
|
||||||
PSOCK_END(&s->sout);
|
|
||||||
}
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
void
|
|
||||||
httpd_cgi_add(struct httpd_cgi_call *c)
|
|
||||||
{
|
|
||||||
struct httpd_cgi_call *l;
|
|
||||||
|
|
||||||
c->next = NULL;
|
|
||||||
if(calls == NULL) {
|
|
||||||
calls = c;
|
|
||||||
} else {
|
|
||||||
for(l = calls; l->next != NULL; l = l->next);
|
|
||||||
l->next = c;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
HTTPD_CGI_CALL(file, "file-stats", file_stats);
|
|
||||||
HTTPD_CGI_CALL(tcp, "tcp-connections", tcp_stats);
|
|
||||||
HTTPD_CGI_CALL(proc, "processes", processes);
|
|
||||||
|
|
||||||
void
|
|
||||||
httpd_cgi_init(void)
|
|
||||||
{
|
|
||||||
httpd_cgi_add(&file);
|
|
||||||
httpd_cgi_add(&tcp);
|
|
||||||
httpd_cgi_add(&proc);
|
|
||||||
}
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
|
@ -1,56 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2001, Adam Dunkels.
|
|
||||||
* 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. The name of the author may not be used to endorse or promote
|
|
||||||
* products derived from this software without specific prior
|
|
||||||
* written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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 uIP TCP/IP stack.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __HTTPD_CGI_H__
|
|
||||||
#define __HTTPD_CGI_H__
|
|
||||||
|
|
||||||
#include "contiki.h"
|
|
||||||
#include "httpd.h"
|
|
||||||
|
|
||||||
typedef PT_THREAD((* httpd_cgifunction)(struct httpd_state *, char *));
|
|
||||||
|
|
||||||
httpd_cgifunction httpd_cgi(char *name);
|
|
||||||
|
|
||||||
struct httpd_cgi_call {
|
|
||||||
struct httpd_cgi_call *next;
|
|
||||||
const char *name;
|
|
||||||
httpd_cgifunction function;
|
|
||||||
};
|
|
||||||
|
|
||||||
void httpd_cgi_add(struct httpd_cgi_call *c);
|
|
||||||
|
|
||||||
#define HTTPD_CGI_CALL(name, str, function) \
|
|
||||||
static struct httpd_cgi_call name = {NULL, str, function}
|
|
||||||
|
|
||||||
void httpd_cgi_init(void);
|
|
||||||
#endif /* __HTTPD_CGI_H__ */
|
|
|
@ -1,130 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2001, 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 lwIP TCP/IP stack.
|
|
||||||
*
|
|
||||||
* Author: Adam Dunkels <adam@sics.se>
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "contiki-net.h"
|
|
||||||
#include "httpd.h"
|
|
||||||
#include "httpd-fs.h"
|
|
||||||
#include "httpd-fsdata.h"
|
|
||||||
|
|
||||||
#include "httpd-fsdata.c"
|
|
||||||
#include "ctk/libconio_arch-small.h"
|
|
||||||
|
|
||||||
#if HTTPD_FS_STATISTICS
|
|
||||||
static uint16_t count[HTTPD_FS_NUMFILES];
|
|
||||||
#endif /* HTTPD_FS_STATISTICS */
|
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------------------*/
|
|
||||||
static uint8_t
|
|
||||||
httpd_fs_strcmp(const char *str1, const char *str2)
|
|
||||||
{
|
|
||||||
uint8_t i;
|
|
||||||
i = 0;
|
|
||||||
|
|
||||||
loop:
|
|
||||||
if(str2[i] == 0 ||
|
|
||||||
str1[i] == '\r' ||
|
|
||||||
str1[i] == '\n') {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(str1[i] != str2[i]) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
++i;
|
|
||||||
goto loop;
|
|
||||||
}
|
|
||||||
/*-----------------------------------------------------------------------------------*/
|
|
||||||
int
|
|
||||||
httpd_fs_open(const char *name, struct httpd_fs_file *file)
|
|
||||||
{
|
|
||||||
#if HTTPD_FS_STATISTICS
|
|
||||||
uint16_t i = 0;
|
|
||||||
#endif /* HTTPD_FS_STATISTICS */
|
|
||||||
char* ch;
|
|
||||||
struct httpd_fsdata_file_noconst *f;
|
|
||||||
|
|
||||||
libputs_arch(name);
|
|
||||||
for(f = (struct httpd_fsdata_file_noconst *)HTTPD_FS_ROOT;
|
|
||||||
f != NULL;
|
|
||||||
f = (struct httpd_fsdata_file_noconst *)f->next) {
|
|
||||||
|
|
||||||
if(httpd_fs_strcmp(name, f->name) == 0) {
|
|
||||||
file->data = f->data;
|
|
||||||
file->len = f->len;
|
|
||||||
#if HTTPD_FS_STATISTICS
|
|
||||||
++count[i];
|
|
||||||
#endif /* HTTPD_FS_STATISTICS */
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
#if HTTPD_FS_STATISTICS
|
|
||||||
++i;
|
|
||||||
#endif /* HTTPD_FS_STATISTICS */
|
|
||||||
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
/*-----------------------------------------------------------------------------------*/
|
|
||||||
void
|
|
||||||
httpd_fs_init(void)
|
|
||||||
{
|
|
||||||
#if HTTPD_FS_STATISTICS
|
|
||||||
uint16_t i;
|
|
||||||
for(i = 0; i < HTTPD_FS_NUMFILES; i++) {
|
|
||||||
count[i] = 0;
|
|
||||||
}
|
|
||||||
#endif /* HTTPD_FS_STATISTICS */
|
|
||||||
}
|
|
||||||
/*-----------------------------------------------------------------------------------*/
|
|
||||||
#if HTTPD_FS_STATISTICS
|
|
||||||
uint16_t
|
|
||||||
httpd_fs_count(char *name)
|
|
||||||
{
|
|
||||||
struct httpd_fsdata_file_noconst *f;
|
|
||||||
uint16_t i;
|
|
||||||
|
|
||||||
i = 0;
|
|
||||||
for(f = (struct httpd_fsdata_file_noconst *)HTTPD_FS_ROOT;
|
|
||||||
f != NULL;
|
|
||||||
f = (struct httpd_fsdata_file_noconst *)f->next) {
|
|
||||||
|
|
||||||
if(httpd_fs_strcmp(name, f->name) == 0) {
|
|
||||||
return count[i];
|
|
||||||
}
|
|
||||||
++i;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif /* HTTPD_FS_STATISTICS */
|
|
||||||
/*-----------------------------------------------------------------------------------*/
|
|
|
@ -1,58 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2001, 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 lwIP TCP/IP stack.
|
|
||||||
*
|
|
||||||
* Author: Adam Dunkels <adam@sics.se>
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
#ifndef __HTTPD_FS_H__
|
|
||||||
#define __HTTPD_FS_H__
|
|
||||||
|
|
||||||
#include "contiki-net.h"
|
|
||||||
|
|
||||||
#define HTTPD_FS_STATISTICS 1
|
|
||||||
|
|
||||||
struct httpd_fs_file {
|
|
||||||
char *data;
|
|
||||||
int len;
|
|
||||||
};
|
|
||||||
|
|
||||||
/* file must be allocated by caller and will be filled in
|
|
||||||
by the function. */
|
|
||||||
int httpd_fs_open(const char *name, struct httpd_fs_file *file);
|
|
||||||
|
|
||||||
#ifdef HTTPD_FS_STATISTICS
|
|
||||||
#if HTTPD_FS_STATISTICS == 1
|
|
||||||
uint16_t httpd_fs_count(char *name);
|
|
||||||
#endif /* HTTPD_FS_STATISTICS */
|
|
||||||
#endif /* HTTPD_FS_STATISTICS */
|
|
||||||
|
|
||||||
void httpd_fs_init(void);
|
|
||||||
|
|
||||||
#endif /* __HTTPD_FS_H__ */
|
|
|
@ -1 +0,0 @@
|
||||||
<html><body><h1>404 - file not found</h1><a href="/">Contiki PC-6001</a></body></html>
|
|
|
@ -1 +0,0 @@
|
||||||
<html><head><title>Contiki on PC-6001</title></head><body><h3>This website is being served by PC-6001 Contiki!</h3><a href="/">Front page</a><br><a href="tcp.shtml">Network connections</a><br><a href="processes.shtml">System processes</a><br></body></html>
|
|
|
@ -1,50 +0,0 @@
|
||||||
static const unsigned char data_404_html[] = {
|
|
||||||
/* /404.html */
|
|
||||||
0x2f, 0x34, 0x30, 0x34, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0,
|
|
||||||
0x3c, 0x68, 0x74, 0x6d, 0x6c, 0x3e, 0x3c, 0x62, 0x6f, 0x64,
|
|
||||||
0x79, 0x3e, 0x3c, 0x68, 0x31, 0x3e, 0x34, 0x30, 0x34, 0x20,
|
|
||||||
0x2d, 0x20, 0x66, 0x69, 0x6c, 0x65, 0x20, 0x6e, 0x6f, 0x74,
|
|
||||||
0x20, 0x66, 0x6f, 0x75, 0x6e, 0x64, 0x3c, 0x2f, 0x68, 0x31,
|
|
||||||
0x3e, 0x3c, 0x61, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22,
|
|
||||||
0x2f, 0x22, 0x3e, 0x43, 0x6f, 0x6e, 0x74, 0x69, 0x6b, 0x69,
|
|
||||||
0x20, 0x50, 0x43, 0x2d, 0x36, 0x30, 0x30, 0x31, 0x3c, 0x2f,
|
|
||||||
0x61, 0x3e, 0x3c, 0x2f, 0x62, 0x6f, 0x64, 0x79, 0x3e, 0x3c,
|
|
||||||
0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x3e, 0};
|
|
||||||
|
|
||||||
static const unsigned char data_index_html[] = {
|
|
||||||
/* /index.html */
|
|
||||||
0x2f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0,
|
|
||||||
0x3c, 0x68, 0x74, 0x6d, 0x6c, 0x3e, 0x3c, 0x68, 0x65, 0x61,
|
|
||||||
0x64, 0x3e, 0x3c, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0x43,
|
|
||||||
0x6f, 0x6e, 0x74, 0x69, 0x6b, 0x69, 0x20, 0x6f, 0x6e, 0x20,
|
|
||||||
0x50, 0x43, 0x2d, 0x36, 0x30, 0x30, 0x31, 0x3c, 0x2f, 0x74,
|
|
||||||
0x69, 0x74, 0x6c, 0x65, 0x3e, 0x3c, 0x2f, 0x68, 0x65, 0x61,
|
|
||||||
0x64, 0x3e, 0x3c, 0x62, 0x6f, 0x64, 0x79, 0x3e, 0x3c, 0x68,
|
|
||||||
0x33, 0x3e, 0x54, 0x68, 0x69, 0x73, 0x20, 0x77, 0x65, 0x62,
|
|
||||||
0x73, 0x69, 0x74, 0x65, 0x20, 0x69, 0x73, 0x20, 0x62, 0x65,
|
|
||||||
0x69, 0x6e, 0x67, 0x20, 0x73, 0x65, 0x72, 0x76, 0x65, 0x64,
|
|
||||||
0x20, 0x62, 0x79, 0x20, 0x50, 0x43, 0x2d, 0x36, 0x30, 0x30,
|
|
||||||
0x31, 0x20, 0x43, 0x6f, 0x6e, 0x74, 0x69, 0x6b, 0x69, 0x21,
|
|
||||||
0x3c, 0x2f, 0x68, 0x33, 0x3e, 0x3c, 0x61, 0x20, 0x68, 0x72,
|
|
||||||
0x65, 0x66, 0x3d, 0x22, 0x2f, 0x22, 0x3e, 0x46, 0x72, 0x6f,
|
|
||||||
0x6e, 0x74, 0x20, 0x70, 0x61, 0x67, 0x65, 0x3c, 0x2f, 0x61,
|
|
||||||
0x3e, 0x3c, 0x62, 0x72, 0x3e, 0x3c, 0x61, 0x20, 0x68, 0x72,
|
|
||||||
0x65, 0x66, 0x3d, 0x22, 0x74, 0x63, 0x70, 0x2e, 0x73, 0x68,
|
|
||||||
0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x4e, 0x65, 0x74, 0x77, 0x6f,
|
|
||||||
0x72, 0x6b, 0x20, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74,
|
|
||||||
0x69, 0x6f, 0x6e, 0x73, 0x3c, 0x2f, 0x61, 0x3e, 0x3c, 0x62,
|
|
||||||
0x72, 0x3e, 0x3c, 0x61, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d,
|
|
||||||
0x22, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x65, 0x73,
|
|
||||||
0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x53, 0x79,
|
|
||||||
0x73, 0x74, 0x65, 0x6d, 0x20, 0x70, 0x72, 0x6f, 0x63, 0x65,
|
|
||||||
0x73, 0x73, 0x65, 0x73, 0x3c, 0x2f, 0x61, 0x3e, 0x3c, 0x62,
|
|
||||||
0x72, 0x3e, 0x3c, 0x2f, 0x62, 0x6f, 0x64, 0x79, 0x3e, 0x3c,
|
|
||||||
0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x3e, 0};
|
|
||||||
|
|
||||||
const struct httpd_fsdata_file file_404_html[] = {{NULL, data_404_html, data_404_html + 10, sizeof(data_404_html) - 10}};
|
|
||||||
|
|
||||||
const struct httpd_fsdata_file file_index_html[] = {{file_404_html, data_index_html, data_index_html + 12, sizeof(data_index_html) - 12}};
|
|
||||||
|
|
||||||
#define HTTPD_FS_ROOT file_index_html
|
|
||||||
|
|
||||||
#define HTTPD_FS_NUMFILES 2
|
|
|
@ -1,63 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2001, 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 lwIP TCP/IP stack.
|
|
||||||
*
|
|
||||||
* Author: Adam Dunkels <adam@sics.se>
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
#ifndef __HTTPD_FSDATA_H__
|
|
||||||
#define __HTTPD_FSDATA_H__
|
|
||||||
|
|
||||||
#include "contiki-net.h"
|
|
||||||
|
|
||||||
struct httpd_fsdata_file {
|
|
||||||
const struct httpd_fsdata_file *next;
|
|
||||||
const char *name;
|
|
||||||
const char *data;
|
|
||||||
const int len;
|
|
||||||
#ifdef HTTPD_FS_STATISTICS
|
|
||||||
#if HTTPD_FS_STATISTICS == 1
|
|
||||||
uint16_t count;
|
|
||||||
#endif /* HTTPD_FS_STATISTICS */
|
|
||||||
#endif /* HTTPD_FS_STATISTICS */
|
|
||||||
};
|
|
||||||
|
|
||||||
struct httpd_fsdata_file_noconst {
|
|
||||||
struct httpd_fsdata_file *next;
|
|
||||||
char *name;
|
|
||||||
char *data;
|
|
||||||
int len;
|
|
||||||
#ifdef HTTPD_FS_STATISTICS
|
|
||||||
#if HTTPD_FS_STATISTICS == 1
|
|
||||||
uint16_t count;
|
|
||||||
#endif /* HTTPD_FS_STATISTICS */
|
|
||||||
#endif /* HTTPD_FS_STATISTICS */
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* __HTTPD_FSDATA_H__ */
|
|
|
@ -1,343 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2004, Adam Dunkels.
|
|
||||||
* 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: Adam Dunkels <adam@sics.se>
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include "contiki-net.h"
|
|
||||||
|
|
||||||
#include "webserver-nogui.h"
|
|
||||||
#include "httpd-fs.h"
|
|
||||||
#include "httpd-cgi.h"
|
|
||||||
#include "http-strings.h"
|
|
||||||
|
|
||||||
#include "httpd.h"
|
|
||||||
#include "ctk/libconio_arch-small.h"
|
|
||||||
|
|
||||||
#define STATE_WAITING 0
|
|
||||||
#define STATE_OUTPUT 1
|
|
||||||
|
|
||||||
#define SEND_STRING(s, str) PSOCK_SEND(s, str, (unsigned int)strlen(str))
|
|
||||||
MEMB(conns, struct httpd_state, 4);
|
|
||||||
|
|
||||||
#define ISO_nl 0x0a
|
|
||||||
#define ISO_space 0x20
|
|
||||||
#define ISO_bang 0x21
|
|
||||||
#define ISO_percent 0x25
|
|
||||||
#define ISO_period 0x2e
|
|
||||||
#define ISO_slash 0x2f
|
|
||||||
#define ISO_colon 0x3a
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
static unsigned short
|
|
||||||
generate(void *state)
|
|
||||||
{
|
|
||||||
struct httpd_state *s = (struct httpd_state *)state;
|
|
||||||
|
|
||||||
if(s->file.len > uip_mss()) {
|
|
||||||
s->len = uip_mss();
|
|
||||||
} else {
|
|
||||||
s->len = s->file.len;
|
|
||||||
}
|
|
||||||
memcpy(uip_appdata, s->file.data, s->len);
|
|
||||||
|
|
||||||
return s->len;
|
|
||||||
}
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
static
|
|
||||||
PT_THREAD(send_file(struct httpd_state *s))
|
|
||||||
{
|
|
||||||
PSOCK_BEGIN(&s->sout);
|
|
||||||
|
|
||||||
do {
|
|
||||||
PSOCK_GENERATOR_SEND(&s->sout, generate, s);
|
|
||||||
s->file.len -= s->len;
|
|
||||||
s->file.data += s->len;
|
|
||||||
} while(s->file.len > 0);
|
|
||||||
|
|
||||||
PSOCK_END(&s->sout);
|
|
||||||
}
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
static
|
|
||||||
PT_THREAD(send_part_of_file(struct httpd_state *s))
|
|
||||||
{
|
|
||||||
PSOCK_BEGIN(&s->sout);
|
|
||||||
|
|
||||||
PSOCK_SEND(&s->sout, s->file.data, s->len);
|
|
||||||
|
|
||||||
PSOCK_END(&s->sout);
|
|
||||||
}
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
#if HTTPD_CONF_SCRIPT
|
|
||||||
static void
|
|
||||||
next_scriptstate(struct httpd_state *s)
|
|
||||||
{
|
|
||||||
char *p;
|
|
||||||
|
|
||||||
if((p = strchr(s->scriptptr, ISO_nl)) != NULL) {
|
|
||||||
p += 1;
|
|
||||||
s->scriptlen -= (unsigned short)(p - s->scriptptr);
|
|
||||||
s->scriptptr = p;
|
|
||||||
} else {
|
|
||||||
s->scriptlen = 0;
|
|
||||||
}
|
|
||||||
/* char *p;
|
|
||||||
p = strchr(s->scriptptr, ISO_nl) + 1;
|
|
||||||
s->scriptlen -= (unsigned short)(p - s->scriptptr);
|
|
||||||
s->scriptptr = p;*/
|
|
||||||
}
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
static
|
|
||||||
PT_THREAD(handle_script(struct httpd_state *s))
|
|
||||||
{
|
|
||||||
char *ptr;
|
|
||||||
|
|
||||||
PT_BEGIN(&s->scriptpt);
|
|
||||||
|
|
||||||
while(s->file.len > 0) {
|
|
||||||
|
|
||||||
/* Check if we should start executing a script. */
|
|
||||||
if(*s->file.data == ISO_percent &&
|
|
||||||
*(s->file.data + 1) == ISO_bang) {
|
|
||||||
s->scriptptr = s->file.data + 3;
|
|
||||||
s->scriptlen = s->file.len - 3;
|
|
||||||
if(*(s->scriptptr - 1) == ISO_colon) {
|
|
||||||
httpd_fs_open(s->scriptptr + 1, &s->file);
|
|
||||||
PT_WAIT_THREAD(&s->scriptpt, send_file(s));
|
|
||||||
#if HTTPD_CONF_CGI
|
|
||||||
} else {
|
|
||||||
PT_WAIT_THREAD(&s->scriptpt,
|
|
||||||
httpd_cgi(s->scriptptr)(s, s->scriptptr));
|
|
||||||
#endif /* HTTPD_CONF_CGI */
|
|
||||||
}
|
|
||||||
next_scriptstate(s);
|
|
||||||
|
|
||||||
/* The script is over, so we reset the pointers and continue
|
|
||||||
sending the rest of the file. */
|
|
||||||
s->file.data = s->scriptptr;
|
|
||||||
s->file.len = s->scriptlen;
|
|
||||||
} else {
|
|
||||||
/* See if we find the start of script marker in the block of HTML
|
|
||||||
to be sent. */
|
|
||||||
|
|
||||||
if(s->file.len > uip_mss()) {
|
|
||||||
s->len = uip_mss();
|
|
||||||
} else {
|
|
||||||
s->len = s->file.len;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(*s->file.data == ISO_percent) {
|
|
||||||
ptr = strchr(s->file.data + 1, ISO_percent);
|
|
||||||
} else {
|
|
||||||
ptr = strchr(s->file.data, ISO_percent);
|
|
||||||
}
|
|
||||||
if(ptr != NULL &&
|
|
||||||
ptr != s->file.data) {
|
|
||||||
s->len = (int)(ptr - s->file.data);
|
|
||||||
if(s->len >= uip_mss()) {
|
|
||||||
s->len = uip_mss();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
PT_WAIT_THREAD(&s->scriptpt, send_part_of_file(s));
|
|
||||||
s->file.data += s->len;
|
|
||||||
s->file.len -= s->len;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
PT_END(&s->scriptpt);
|
|
||||||
}
|
|
||||||
#endif /* HTTPD_CONF_SCRIPT */
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
static
|
|
||||||
PT_THREAD(send_headers(struct httpd_state *s, const char *statushdr))
|
|
||||||
{
|
|
||||||
char *ptr;
|
|
||||||
|
|
||||||
PSOCK_BEGIN(&s->sout);
|
|
||||||
|
|
||||||
SEND_STRING(&s->sout, statushdr);
|
|
||||||
|
|
||||||
ptr = strrchr(s->filename, ISO_period);
|
|
||||||
if(ptr == NULL) {
|
|
||||||
SEND_STRING(&s->sout, http_content_type_binary);
|
|
||||||
} else if(strncmp(http_html, ptr, 5) == 0 ||
|
|
||||||
strncmp(http_shtml, ptr, 6) == 0) {
|
|
||||||
SEND_STRING(&s->sout, http_content_type_html);
|
|
||||||
#if 0
|
|
||||||
} else if(strncmp(http_css, ptr, 4) == 0) {
|
|
||||||
SEND_STRING(&s->sout, http_content_type_css);
|
|
||||||
} else if(strncmp(http_png, ptr, 4) == 0) {
|
|
||||||
SEND_STRING(&s->sout, http_content_type_png);
|
|
||||||
} else if(strncmp(http_gif, ptr, 4) == 0) {
|
|
||||||
SEND_STRING(&s->sout, http_content_type_gif);
|
|
||||||
} else if(strncmp(http_jpg, ptr, 4) == 0) {
|
|
||||||
SEND_STRING(&s->sout, http_content_type_jpg);
|
|
||||||
#endif
|
|
||||||
} else {
|
|
||||||
SEND_STRING(&s->sout, http_content_type_plain);
|
|
||||||
}
|
|
||||||
PSOCK_END(&s->sout);
|
|
||||||
}
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
static
|
|
||||||
PT_THREAD(handle_output(struct httpd_state *s))
|
|
||||||
{
|
|
||||||
char *ptr;
|
|
||||||
|
|
||||||
PT_BEGIN(&s->outputpt);
|
|
||||||
|
|
||||||
if(!httpd_fs_open(s->filename, &s->file)) {
|
|
||||||
httpd_fs_open(http_404_html, &s->file);
|
|
||||||
PT_WAIT_THREAD(&s->outputpt,
|
|
||||||
send_headers(s,
|
|
||||||
http_header_404));
|
|
||||||
PT_WAIT_THREAD(&s->outputpt,
|
|
||||||
send_file(s));
|
|
||||||
} else {
|
|
||||||
PT_WAIT_THREAD(&s->outputpt,
|
|
||||||
send_headers(s,
|
|
||||||
http_header_200));
|
|
||||||
ptr = strchr(s->filename, ISO_period);
|
|
||||||
#if HTTPD_CONF_SCRIPT
|
|
||||||
if(ptr != NULL && strncmp(ptr, http_shtml, 6) == 0) {
|
|
||||||
PT_INIT(&s->scriptpt);
|
|
||||||
PT_WAIT_THREAD(&s->outputpt, handle_script(s));
|
|
||||||
} else {
|
|
||||||
PT_WAIT_THREAD(&s->outputpt,
|
|
||||||
send_file(s));
|
|
||||||
}
|
|
||||||
#else /* HTTPD_CONF_SCRIPT */
|
|
||||||
PT_WAIT_THREAD(&s->outputpt,
|
|
||||||
send_file(s));
|
|
||||||
#endif /* HTTPD_CONF_SCRIPT */
|
|
||||||
}
|
|
||||||
PSOCK_CLOSE(&s->sout);
|
|
||||||
PT_END(&s->outputpt);
|
|
||||||
}
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
static
|
|
||||||
PT_THREAD(handle_input(struct httpd_state *s))
|
|
||||||
{
|
|
||||||
PSOCK_BEGIN(&s->sin);
|
|
||||||
|
|
||||||
PSOCK_READTO(&s->sin, ISO_space);
|
|
||||||
|
|
||||||
if(strncmp(s->inputbuf, http_get, 4) != 0) {
|
|
||||||
PSOCK_CLOSE_EXIT(&s->sin);
|
|
||||||
}
|
|
||||||
PSOCK_READTO(&s->sin, ISO_space);
|
|
||||||
|
|
||||||
if(s->inputbuf[0] != ISO_slash) {
|
|
||||||
PSOCK_CLOSE_EXIT(&s->sin);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(s->inputbuf[1] == ISO_space) {
|
|
||||||
strncpy(s->filename, http_index_html, sizeof(s->filename));
|
|
||||||
} else {
|
|
||||||
s->inputbuf[PSOCK_DATALEN(&s->sin) - 1] = 0;
|
|
||||||
strncpy(s->filename, &s->inputbuf[0], sizeof(s->filename));
|
|
||||||
}
|
|
||||||
|
|
||||||
libputs_arch(s->filename);
|
|
||||||
|
|
||||||
s->state = STATE_OUTPUT;
|
|
||||||
|
|
||||||
while(1) {
|
|
||||||
PSOCK_READTO(&s->sin, ISO_nl);
|
|
||||||
|
|
||||||
if(strncmp(s->inputbuf, http_referer, 8) == 0) {
|
|
||||||
s->inputbuf[PSOCK_DATALEN(&s->sin) - 2] = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
PSOCK_END(&s->sin);
|
|
||||||
}
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
static void
|
|
||||||
handle_connection(struct httpd_state *s)
|
|
||||||
{
|
|
||||||
handle_input(s);
|
|
||||||
if(s->state == STATE_OUTPUT) {
|
|
||||||
handle_output(s);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
void
|
|
||||||
httpd_appcall(void *state)
|
|
||||||
{
|
|
||||||
struct httpd_state *s = (struct httpd_state *)state;
|
|
||||||
|
|
||||||
if(uip_closed() || uip_aborted() || uip_timedout()) {
|
|
||||||
if(s != NULL) {
|
|
||||||
memb_free(&conns, s);
|
|
||||||
}
|
|
||||||
} else if(uip_connected()) {
|
|
||||||
s = (struct httpd_state *)memb_alloc(&conns);
|
|
||||||
if(s == NULL) {
|
|
||||||
uip_abort();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
tcp_markconn(uip_conn, s);
|
|
||||||
PSOCK_INIT(&s->sin, s->inputbuf, sizeof(s->inputbuf) - 1);
|
|
||||||
PSOCK_INIT(&s->sout, s->inputbuf, sizeof(s->inputbuf) - 1);
|
|
||||||
PT_INIT(&s->outputpt);
|
|
||||||
s->state = STATE_WAITING;
|
|
||||||
/* timer_set(&s->timer, CLOCK_SECOND * 100);*/
|
|
||||||
s->timer = 0;
|
|
||||||
handle_connection(s);
|
|
||||||
} else if(s != NULL) {
|
|
||||||
if(uip_poll()) {
|
|
||||||
++s->timer;
|
|
||||||
if(s->timer >= 20) {
|
|
||||||
uip_abort();
|
|
||||||
memb_free(&conns, s);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
s->timer = 0;
|
|
||||||
}
|
|
||||||
handle_connection(s);
|
|
||||||
} else {
|
|
||||||
uip_abort();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
void
|
|
||||||
httpd_init(void)
|
|
||||||
{
|
|
||||||
tcp_listen(UIP_HTONS(80));
|
|
||||||
memb_init(&conns);
|
|
||||||
#if HTTPD_CONF_CGI
|
|
||||||
httpd_cgi_init();
|
|
||||||
#endif /* HTTPD_CONF_CGI */
|
|
||||||
}
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
|
@ -1,76 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2001-2005, Adam Dunkels.
|
|
||||||
* 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. The name of the author may not be used to endorse or promote
|
|
||||||
* products derived from this software without specific prior
|
|
||||||
* written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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 uIP TCP/IP stack.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __HTTPD_H__
|
|
||||||
#define __HTTPD_H__
|
|
||||||
|
|
||||||
|
|
||||||
#include "contiki-net.h"
|
|
||||||
#include "httpd-fs.h"
|
|
||||||
|
|
||||||
#ifndef HTTPD_CONF_CGI
|
|
||||||
#define HTTPD_CONF_CGI 1
|
|
||||||
#endif
|
|
||||||
#ifndef HTTPD_CONF_SCRIPT
|
|
||||||
#define HTTPD_CONF_SCRIPT 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct httpd_state {
|
|
||||||
unsigned char timer;
|
|
||||||
struct psock sin, sout;
|
|
||||||
struct pt outputpt
|
|
||||||
#if HTTPD_CONF_SCRIPT
|
|
||||||
, scriptpt;
|
|
||||||
#else
|
|
||||||
;
|
|
||||||
#endif /* HTTPD_CONF_SCRIPT */
|
|
||||||
char inputbuf[50];
|
|
||||||
char filename[20];
|
|
||||||
char state;
|
|
||||||
struct httpd_fs_file file;
|
|
||||||
int len;
|
|
||||||
#if HTTPD_CONF_SCRIPT
|
|
||||||
char *scriptptr;
|
|
||||||
int scriptlen;
|
|
||||||
#endif /* HTTPD_CONF_SCRIPT */
|
|
||||||
union {
|
|
||||||
unsigned short count;
|
|
||||||
void *ptr;
|
|
||||||
} u;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
void httpd_init(void);
|
|
||||||
void httpd_appcall(void *state);
|
|
||||||
|
|
||||||
#endif /* __HTTPD_H__ */
|
|
|
@ -1,59 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2002, Adam Dunkels.
|
|
||||||
* 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. The name of the author may not be used to endorse or promote
|
|
||||||
* products derived from this software without specific prior
|
|
||||||
* written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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 OS.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#include "contiki.h"
|
|
||||||
|
|
||||||
#include "http-strings.h"
|
|
||||||
#include "webserver-nogui.h"
|
|
||||||
#include "httpd.h"
|
|
||||||
|
|
||||||
PROCESS(webserver_nogui_process, "Web server");
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
PROCESS_THREAD(webserver_nogui_process, ev, data)
|
|
||||||
{
|
|
||||||
PROCESS_BEGIN();
|
|
||||||
|
|
||||||
httpd_init();
|
|
||||||
|
|
||||||
while(1) {
|
|
||||||
PROCESS_WAIT_EVENT_UNTIL(ev == tcpip_event);
|
|
||||||
httpd_appcall(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
PROCESS_END();
|
|
||||||
}
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
|
@ -1,52 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2002, Adam Dunkels.
|
|
||||||
* 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. The name of the author may not be used to endorse or promote
|
|
||||||
* products derived from this software without specific prior
|
|
||||||
* written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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 OS
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
#ifndef __WEBSERVER_NOGUI_H__
|
|
||||||
#define __WEBSERVER_NOGUI_H__
|
|
||||||
|
|
||||||
#include "contiki-net.h"
|
|
||||||
|
|
||||||
PROCESS_NAME(webserver_nogui_process);
|
|
||||||
|
|
||||||
#ifdef WEBSERVER_CONF_LOG_ENABLED
|
|
||||||
#define webserver_log(msg) webserver_log(msg)
|
|
||||||
#define webserver_log_file(requester, file) \
|
|
||||||
webserver_log_file(requester, file)
|
|
||||||
void weblog_message(char *msg);
|
|
||||||
#else /* WEBSERVER_CONF_LOG_ENABLED */
|
|
||||||
void weblog_message(char *msg);
|
|
||||||
#define webserver_log(msg)
|
|
||||||
#define webserver_log_file(requester, file)
|
|
||||||
#endif /* WEBSERVER_CONF_LOG_ENABLED */
|
|
||||||
|
|
||||||
#endif /* __WEBSERVER_H__ */
|
|
|
@ -1,121 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2007, Takahide Matsutsuka.
|
|
||||||
* 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. The name of the author may not be used to endorse or promote
|
|
||||||
* products derived from this software without specific prior
|
|
||||||
* written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* \file
|
|
||||||
* This is a sample main file with slip network.
|
|
||||||
* \author
|
|
||||||
* Takahide Matsutsuka <markn@markn.org>
|
|
||||||
*/
|
|
||||||
|
|
||||||
//#define WITH_LOADER_ARCH 1
|
|
||||||
|
|
||||||
#include "contiki.h"
|
|
||||||
|
|
||||||
/* devices */
|
|
||||||
#include "net/uip.h"
|
|
||||||
#include "net/uip-fw-drv.h"
|
|
||||||
#include "dev/slip.h"
|
|
||||||
#include "dev/rs232.h"
|
|
||||||
#include "sys/process.h"
|
|
||||||
|
|
||||||
/* desktop programs */
|
|
||||||
#include "program-handler.h"
|
|
||||||
//#include "process-list-dsc.h"
|
|
||||||
|
|
||||||
/* network programs */
|
|
||||||
#include "netconf-dsc.h"
|
|
||||||
#include "www-dsc.h"
|
|
||||||
#include "telnet-dsc.h"
|
|
||||||
//#include "dhcp-dsc.h"
|
|
||||||
#include "email-dsc.h"
|
|
||||||
#include "ftp-dsc.h"
|
|
||||||
#include "irc-dsc.h"
|
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
/* inteface */
|
|
||||||
static struct uip_fw_netif slipif =
|
|
||||||
{UIP_FW_NETIF(0, 0, 0, 0, 0, 0, 0, 0, slip_send)};
|
|
||||||
|
|
||||||
/* ip address of contiki */
|
|
||||||
const uip_ipaddr_t hostaddr = { { 10, 0, 1, 10 } };
|
|
||||||
|
|
||||||
PROCESS_NAME(netconf_process);
|
|
||||||
PROCESS_NAME(email_process);
|
|
||||||
PROCESS_NAME(www_process);
|
|
||||||
PROCESS_NAME(simpletelnet_process);
|
|
||||||
PROCESS_NAME(ftp_process);
|
|
||||||
PROCESS_NAME(irc_process);
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
int
|
|
||||||
main(void)
|
|
||||||
{
|
|
||||||
/* initialize process manager. */
|
|
||||||
process_init();
|
|
||||||
|
|
||||||
uip_init();
|
|
||||||
uip_sethostaddr(&hostaddr);
|
|
||||||
uip_fw_default(&slipif);
|
|
||||||
|
|
||||||
/* start services */
|
|
||||||
process_start(&etimer_process, NULL);
|
|
||||||
process_start(&ctk_process, NULL);
|
|
||||||
// process_start(&program_handler_process, NULL);
|
|
||||||
process_start(&tcpip_process, NULL);
|
|
||||||
process_start(&slip_process, NULL);
|
|
||||||
process_start(&uip_fw_process, NULL);
|
|
||||||
process_start(&rs232_process, NULL);
|
|
||||||
|
|
||||||
// process_start(&email_process, NULL);
|
|
||||||
// process_start(&www_process, NULL);
|
|
||||||
// process_start(&ftp_process, NULL);
|
|
||||||
// process_start(&irc_process, NULL);
|
|
||||||
|
|
||||||
// process_start(&netconf_process, NULL);
|
|
||||||
process_start(&simpletelnet_process, NULL);
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
/* register programs to the program handler */
|
|
||||||
program_handler_add(&processes_dsc, "Processes", 1);
|
|
||||||
program_handler_add(&netconf_dsc, "Network conf", 1);
|
|
||||||
program_handler_add(&email_dsc, "E-mail", 1);
|
|
||||||
program_handler_add(&irc_dsc, "IRC", 1);
|
|
||||||
program_handler_add(&vnc_dsc, "VNC client", 1);
|
|
||||||
program_handler_add(&dhcp_dsc, "DHCP client", 1);
|
|
||||||
#endif
|
|
||||||
while(1) {
|
|
||||||
process_run();
|
|
||||||
etimer_request_poll();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,179 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2007, Takahide Matsutsuka.
|
|
||||||
* 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. The name of the author may not be used to endorse or promote
|
|
||||||
* products derived from this software without specific prior
|
|
||||||
* written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* \file
|
|
||||||
* contiki-conf.h
|
|
||||||
* A set of configurations of contiki for PC-6001 family.
|
|
||||||
* \author
|
|
||||||
* Takahide Matsutsuka <markn@markn.org>
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __CONTIKI_CONF_H__
|
|
||||||
#define __CONTIKI_CONF_H__
|
|
||||||
|
|
||||||
#include "z80def.h"
|
|
||||||
#include "sys/cc.h"
|
|
||||||
#include <ctype.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include "ctk/ctk_arch.h"
|
|
||||||
#include "strcasecmp.h"
|
|
||||||
#include "log.h"
|
|
||||||
|
|
||||||
/* Time type. */
|
|
||||||
typedef unsigned long clock_time_t;
|
|
||||||
|
|
||||||
/* Defines tick counts for a second. */
|
|
||||||
#define CLOCK_CONF_SECOND 1024
|
|
||||||
|
|
||||||
#define rtimer_arch_now() clock_time()
|
|
||||||
|
|
||||||
/* Memory filesystem RAM size. */
|
|
||||||
#define CFS_RAM_CONF_SIZE 512
|
|
||||||
|
|
||||||
/* Logging.. */
|
|
||||||
#define LOG_CONF_ENABLED 0
|
|
||||||
|
|
||||||
#undef MALLOC_TEST
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
/* screen properties */
|
|
||||||
#define LIBCONIO_CONF_ATTRIBUTES_ENABLED
|
|
||||||
#if defined(ARCH_PC6001MK2)
|
|
||||||
#define LIBCONIO_VRAM_ATTR 0x4000
|
|
||||||
#define LIBCONIO_VRAM_CHAR 0x4400
|
|
||||||
#define LIBCONIO_CONF_SCREEN_WIDTH 40
|
|
||||||
#define LIBCONIO_CONF_SCREEN_HEIGHT 20
|
|
||||||
#define LIBCONIO_COLOR_NORMAL 0x0f
|
|
||||||
#define LIBCONIO_COLOR_REVERSED 0x70
|
|
||||||
#elif (defined(ARCH_PC6001) || defined(ARCH_PC6001A)) && defined(MEMORY_16K)
|
|
||||||
#define LIBCONIO_VRAM_ATTR 0xc000
|
|
||||||
#define LIBCONIO_VRAM_CHAR 0xc200
|
|
||||||
#define LIBCONIO_CONF_SCREEN_WIDTH 32
|
|
||||||
#define LIBCONIO_CONF_SCREEN_HEIGHT 16
|
|
||||||
#define LIBCONIO_COLOR_NORMAL 0x20
|
|
||||||
#define LIBCONIO_COLOR_REVERSED 0x21
|
|
||||||
#elif (defined(ARCH_PC6001) || defined(ARCH_PC6001A)) && (defined(MEMORY_32K) || defined(MEMORY_ROM))
|
|
||||||
#define LIBCONIO_VRAM_ATTR 0x8000
|
|
||||||
#define LIBCONIO_VRAM_CHAR 0x8200
|
|
||||||
#define LIBCONIO_CONF_SCREEN_WIDTH 32
|
|
||||||
#define LIBCONIO_CONF_SCREEN_HEIGHT 16
|
|
||||||
#define LIBCONIO_COLOR_NORMAL 0x20
|
|
||||||
#define LIBCONIO_COLOR_REVERSED 0x21
|
|
||||||
#else
|
|
||||||
#error Specify appropriate ARCH & MEMORY combination
|
|
||||||
#endif /* ARCH_PC6001MK2 */
|
|
||||||
|
|
||||||
#if 0 /* ctk-conio case */
|
|
||||||
#define SCREENCOLOR 0x20
|
|
||||||
#define BORDERCOLOR 0x20
|
|
||||||
#define WIDGETCOLOR 0x20
|
|
||||||
#define WIDGETCOLOR_FWIN 0x20
|
|
||||||
#define BACKGROUNDCOLOR 0x20
|
|
||||||
#define DIALOGCOLOR 0x20
|
|
||||||
#define WINDOWCOLOR 0x20
|
|
||||||
#define WINDOWCOLOR_FOCUS 0x21
|
|
||||||
#define MENUCOLOR 0x21
|
|
||||||
#define MENUCOLOR 0x21
|
|
||||||
#define OPENMENUCOLOR 0x22
|
|
||||||
#define ACTIVEMENUITEMCOLOR 0x23
|
|
||||||
#define WIDGETCOLOR_HLINK 0x21
|
|
||||||
#define WIDGETCOLOR_FOCUS 0x20
|
|
||||||
#define WIDGETCOLOR_DIALOG 0x22
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* uIP configuration */
|
|
||||||
#define UIP_CONF_MAX_CONNECTIONS 4
|
|
||||||
#define UIP_CONF_MAX_LISTENPORTS 4
|
|
||||||
#define UIP_CONF_BUFFER_SIZE 400
|
|
||||||
#define UIP_CONF_BYTE_ORDER LITTLE_ENDIAN
|
|
||||||
#define UIP_CONF_TCP_SPLIT 0
|
|
||||||
#define UIP_CONF_LOGGING 0
|
|
||||||
|
|
||||||
/* uses SLIP */
|
|
||||||
#define UIP_CONF_UDP 0
|
|
||||||
#define UIP_CONF_UDP_CHECKSUMS 0
|
|
||||||
#define UIP_CONF_LLH_LEN 0
|
|
||||||
#undef UIP_CONF_BROADCAST
|
|
||||||
#undef RS232_CONF_CALLBACK
|
|
||||||
/* #define RS232_CONF_CALLBACK serial_input_byte */
|
|
||||||
#define slip_arch_init(ubr) rs232_arch_init(ubr)
|
|
||||||
#define slip_arch_writeb(c) rs232_arch_writeb(c)
|
|
||||||
|
|
||||||
#ifdef WITH_LOADER_ARCH
|
|
||||||
//#define AUTOSTART_ENABLE 1
|
|
||||||
#define LOADER_CONF_ARCH "loader_arch.h"
|
|
||||||
#endif /* WITH_LOADER_ARCH */
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
/* Application specific configurations. */
|
|
||||||
|
|
||||||
/* Command shell */
|
|
||||||
#define SHELL_GUI_CONF_XSIZE 26
|
|
||||||
#define SHELL_GUI_CONF_YSIZE 10
|
|
||||||
|
|
||||||
/* Text editor */
|
|
||||||
#define EDITOR_CONF_WIDTH 26
|
|
||||||
#define EDITOR_CONF_HEIGHT 8
|
|
||||||
|
|
||||||
/* Process list */
|
|
||||||
#define PROCESSLIST_CONF_HEIGHT 12
|
|
||||||
|
|
||||||
/* File dialog */
|
|
||||||
#define FILES_CONF_HEIGHT 6
|
|
||||||
|
|
||||||
/* Shell */
|
|
||||||
//#define SHELL_CONF_WITH_PROGRAM_HANDLER 1
|
|
||||||
|
|
||||||
/* Telnet */
|
|
||||||
#define TELNET_CONF_WINDOW_WIDTH 30
|
|
||||||
#define TELNET_CONF_WINDOW_HEIGHT 13
|
|
||||||
//#define TELNET_CONF_TEXTAREA_HEIGHT 5 // TELNET_WINDOW_HEIGHT - 8
|
|
||||||
//#define TELNET_CONF_ENTRY_WIDTH 22 // TELNET_WINDOW_WIDTH - 8
|
|
||||||
|
|
||||||
/* Telnetd */
|
|
||||||
#define TELNETD_CONF_GUI 0
|
|
||||||
#define SHELL_CONF_WITH_PROGRAM_HANDLER 0
|
|
||||||
|
|
||||||
/* Web server */
|
|
||||||
#undef WEBSERVER_CONF_LOG_ENABLED
|
|
||||||
#define HTTPD_CONF_CGI 0
|
|
||||||
#define HTTPD_CONF_SCRIPT 0
|
|
||||||
#define HTTPD_CONF_STATISTICS 0
|
|
||||||
|
|
||||||
/* unused yet */
|
|
||||||
#define VNC_CONF_REFRESH_ROWS 8
|
|
||||||
|
|
||||||
#define WWW_CONF_WEBPAGE_WIDTH 76
|
|
||||||
#define WWW_CONF_WEBPAGE_HEIGHT 30
|
|
||||||
|
|
||||||
#endif /* __CONTIKI_CONF_H__ */
|
|
|
@ -1,82 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2007, Takahide Matsutsuka.
|
|
||||||
* 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. The name of the author may not be used to endorse or promote
|
|
||||||
* products derived from this software without specific prior
|
|
||||||
* written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* \file
|
|
||||||
* This is a sample main file with desktop.
|
|
||||||
* \author
|
|
||||||
* Takahide Matsutsuka <markn@markn.org>
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "contiki.h"
|
|
||||||
|
|
||||||
#include "program-handler.h"
|
|
||||||
#include "about-dsc.h"
|
|
||||||
#include "calc-dsc.h"
|
|
||||||
#include "process-list-dsc.h"
|
|
||||||
#include "shell-dsc.h"
|
|
||||||
#include "mt-test-dsc.h"
|
|
||||||
|
|
||||||
#if WITH_LOADER_ARCH
|
|
||||||
#include "directory-dsc.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
int
|
|
||||||
main(void)
|
|
||||||
{
|
|
||||||
/* initialize process manager. */
|
|
||||||
process_init();
|
|
||||||
|
|
||||||
/* start services */
|
|
||||||
process_start(&ctk_process, NULL);
|
|
||||||
process_start(&program_handler_process, NULL);
|
|
||||||
process_start(&etimer_process, NULL);
|
|
||||||
|
|
||||||
/* register programs to the program handler */
|
|
||||||
#if WITH_LOADER_ARCH
|
|
||||||
program_handler_add(&directory_dsc, "Directory", 1);
|
|
||||||
program_handler_add(&processes_dsc, "Processes", 1);
|
|
||||||
// program_handler_add(&shell_dsc, "Command shell", 1);
|
|
||||||
#else
|
|
||||||
program_handler_add(&processes_dsc, "Processes", 1);
|
|
||||||
program_handler_add(&mttest_dsc, "Multithread", 1);
|
|
||||||
program_handler_add(&calc_dsc, "Calculator", 1);
|
|
||||||
program_handler_add(&about_dsc, "About", 1);
|
|
||||||
// program_handler_add(&shell_dsc, "Command shell", 1);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
while(1) {
|
|
||||||
process_run();
|
|
||||||
etimer_request_poll();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,69 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2007, Takahide Matsutsuka.
|
|
||||||
* 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. The name of the author may not be used to endorse or promote
|
|
||||||
* products derived from this software without specific prior
|
|
||||||
* written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* \file
|
|
||||||
* This is a main file with loader.
|
|
||||||
* \author
|
|
||||||
* Takahide Matsutsuka <markn@markn.org>
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "contiki.h"
|
|
||||||
|
|
||||||
#include "program-handler.h"
|
|
||||||
//#include "process-list-dsc.h"
|
|
||||||
//#include "shell-dsc.h"
|
|
||||||
//#include "directory-dsc.h"
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
int
|
|
||||||
main(void)
|
|
||||||
{
|
|
||||||
/* initialize process manager. */
|
|
||||||
process_init();
|
|
||||||
|
|
||||||
/* start services */
|
|
||||||
process_start(&ctk_process, NULL);
|
|
||||||
process_start(&program_handler_process, NULL);
|
|
||||||
process_start(&etimer_process, NULL);
|
|
||||||
|
|
||||||
/* register programs to the program handler */
|
|
||||||
/*
|
|
||||||
program_handler_add(&directory_dsc, "Directory", 1);
|
|
||||||
program_handler_add(&processes_dsc, "Processes", 1);
|
|
||||||
program_handler_add(&shell_dsc, "Command shell", 1);
|
|
||||||
*/
|
|
||||||
while(1) {
|
|
||||||
process_run();
|
|
||||||
etimer_request_poll();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,64 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2007, Takahide Matsutsuka.
|
|
||||||
* 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. The name of the author may not be used to endorse or promote
|
|
||||||
* products derived from this software without specific prior
|
|
||||||
* written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* \file
|
|
||||||
* This is a main file for standard configuration.
|
|
||||||
* \author
|
|
||||||
* Takahide Matsutsuka <markn@markn.org>
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "contiki.h"
|
|
||||||
#include "ctk/ctk.h"
|
|
||||||
|
|
||||||
#ifndef WITHOUT_GUI
|
|
||||||
#define CTK_PROCESS &ctk_process,
|
|
||||||
#else /* WITH_GUI */
|
|
||||||
#define CTK_PROCESS
|
|
||||||
#endif /* WITH_GUI */
|
|
||||||
|
|
||||||
PROCINIT(CTK_PROCESS
|
|
||||||
&etimer_process);
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
int
|
|
||||||
main(void)
|
|
||||||
{
|
|
||||||
/* initialize process manager. */
|
|
||||||
process_init();
|
|
||||||
autostart_start(autostart_processes);
|
|
||||||
|
|
||||||
while(1) {
|
|
||||||
process_run();
|
|
||||||
etimer_request_poll();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,65 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2007, Takahide Matsutsuka.
|
|
||||||
* 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. The name of the author may not be used to endorse or promote
|
|
||||||
* products derived from this software without specific prior
|
|
||||||
* written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* \file
|
|
||||||
* This is a minimal main file with desktop.
|
|
||||||
* \author
|
|
||||||
* Takahide Matsutsuka <markn@markn.org>
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "contiki.h"
|
|
||||||
|
|
||||||
#include "program-handler.h"
|
|
||||||
#include "tinysample-dsc.h"
|
|
||||||
|
|
||||||
PROCESS_NAME(tiny_process);
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
int
|
|
||||||
main(void)
|
|
||||||
{
|
|
||||||
/* initialize process manager. */
|
|
||||||
process_init();
|
|
||||||
|
|
||||||
/* start services */
|
|
||||||
// process_start(&ctk_process, NULL);
|
|
||||||
// process_start(&program_handler_process, NULL);
|
|
||||||
process_start(&etimer_process, NULL);
|
|
||||||
process_start(&tiny_process, NULL);
|
|
||||||
|
|
||||||
// program_handler_add(&tiny_dsc, "Tiny", 1);
|
|
||||||
|
|
||||||
while(1) {
|
|
||||||
process_run();
|
|
||||||
etimer_request_poll();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,118 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2007, Takahide Matsutsuka.
|
|
||||||
* 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. The name of the author may not be used to endorse or promote
|
|
||||||
* products derived from this software without specific prior
|
|
||||||
* written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* \file
|
|
||||||
* This is a sample main file with serial.
|
|
||||||
* \author
|
|
||||||
* Takahide Matsutsuka <markn@markn.org>
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "contiki.h"
|
|
||||||
|
|
||||||
/* devices */
|
|
||||||
#include "dev/serial-line.h"
|
|
||||||
#include "ctk/libconio_arch-small.h"
|
|
||||||
|
|
||||||
#undef RS232_INTR
|
|
||||||
#ifdef RS232_INTR
|
|
||||||
void rs232_arch_writeb(uint8_t ch);
|
|
||||||
void rs232_arch_init(int (* callback)(unsigned char), unsigned long ubr);
|
|
||||||
#else
|
|
||||||
#include "dev/rs232.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
PROCESS(stest_process, "Serial test process");
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
static void
|
|
||||||
rs232_print(char* str) {
|
|
||||||
while (*str != 0) {
|
|
||||||
rs232_arch_writeb(*str++);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
static void
|
|
||||||
log(char* str) {
|
|
||||||
while (*str != 0) {
|
|
||||||
libputc_arch(*str++);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
PROCESS_THREAD(stest_process, ev, data)
|
|
||||||
{
|
|
||||||
static struct etimer timer;
|
|
||||||
PROCESS_BEGIN();
|
|
||||||
|
|
||||||
clrscr_arch();
|
|
||||||
#ifdef RS232_INTR
|
|
||||||
rs232_arch_init(serial_line_input_byte, 0);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
etimer_set(&timer, CLOCK_SECOND);
|
|
||||||
|
|
||||||
log("Starting serial test process");
|
|
||||||
while(1) {
|
|
||||||
PROCESS_WAIT_EVENT();
|
|
||||||
|
|
||||||
if (etimer_expired(&timer)) {
|
|
||||||
log("Sending serial data now");
|
|
||||||
rs232_print("GNU's not Unix\n");
|
|
||||||
etimer_reset(&timer);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(ev == serial_line_event_message) {
|
|
||||||
log(data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
PROCESS_END();
|
|
||||||
}
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
void
|
|
||||||
main(void)
|
|
||||||
{
|
|
||||||
/* initialize process manager. */
|
|
||||||
process_init();
|
|
||||||
|
|
||||||
/* start services */
|
|
||||||
process_start(&etimer_process, NULL);
|
|
||||||
process_start(&serial_line_process, NULL);
|
|
||||||
#ifndef RS232_INTR
|
|
||||||
process_start(&rs232_process, NULL);
|
|
||||||
#endif
|
|
||||||
process_start(&stest_process, NULL);
|
|
||||||
|
|
||||||
while(1) {
|
|
||||||
process_run();
|
|
||||||
etimer_request_poll();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,88 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2007, Takahide Matsutsuka.
|
|
||||||
* 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. The name of the author may not be used to endorse or promote
|
|
||||||
* products derived from this software without specific prior
|
|
||||||
* written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* \file
|
|
||||||
* This is a sample main file with slip network.
|
|
||||||
* \author
|
|
||||||
* Takahide Matsutsuka <markn@markn.org>
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "contiki.h"
|
|
||||||
|
|
||||||
/* devices */
|
|
||||||
#include "uip.h"
|
|
||||||
#include "dev/slip.h"
|
|
||||||
#include "dev/rs232.h"
|
|
||||||
|
|
||||||
/* network server programs */
|
|
||||||
#include "webserver-nogui.h"
|
|
||||||
#include "cmdd.h"
|
|
||||||
#include "telnetd.h"
|
|
||||||
#include "ctk/libconio_arch-small.h"
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
/* inteface */
|
|
||||||
static struct uip_fw_netif slipif =
|
|
||||||
{UIP_FW_NETIF(0, 0, 0, 0, 0, 0, 0, 0, slip_send)};
|
|
||||||
|
|
||||||
/* ip address of contiki */
|
|
||||||
const uip_ipaddr_t hostaddr = { { 10, 0, 1, 10 } };
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
int
|
|
||||||
main(void)
|
|
||||||
{
|
|
||||||
/* initialize process manager. */
|
|
||||||
process_init();
|
|
||||||
|
|
||||||
clrscr_arch();
|
|
||||||
uip_init();
|
|
||||||
uip_sethostaddr(&hostaddr);
|
|
||||||
uip_fw_default(&slipif);
|
|
||||||
|
|
||||||
/* start services */
|
|
||||||
process_start(&etimer_process, NULL);
|
|
||||||
process_start(&tcpip_process, NULL);
|
|
||||||
process_start(&slip_process, NULL);
|
|
||||||
process_start(&uip_fw_process, NULL);
|
|
||||||
process_start(&rs232_process, NULL);
|
|
||||||
|
|
||||||
process_start(&webserver_nogui_process, NULL);
|
|
||||||
// process_start(&cmdd_process, NULL);
|
|
||||||
// process_start(&telnetd_process, NULL);
|
|
||||||
|
|
||||||
while(1) {
|
|
||||||
process_run();
|
|
||||||
etimer_request_poll();
|
|
||||||
}
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,395 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2007, Takahide Matsutsuka.
|
|
||||||
* 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. The name of the author may not be used to endorse or promote
|
|
||||||
* products derived from this software without specific prior
|
|
||||||
* written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* \file
|
|
||||||
* This is an original source file for
|
|
||||||
* ctk-conio_arch.c and ctk-conio_arch-asm.S
|
|
||||||
* \author
|
|
||||||
* Takahide Matsutsuka <markn@markn.org>
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#include "ctk/ctk.h"
|
|
||||||
#include "ctk/ctk-draw.h"
|
|
||||||
#include "contiki-conf.h"
|
|
||||||
#include "ctk/ctk_arch.h"
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#ifndef NULL
|
|
||||||
#define NULL (void *)0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
static char cursx, cursy;
|
|
||||||
static unsigned char reversed;
|
|
||||||
static char cy1, cy2;
|
|
||||||
|
|
||||||
unsigned char ctk_draw_windowtitle_height = 1;
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
#define revers(c) reversed = c
|
|
||||||
#define clip(y1, y2) cy1 = y1; cy2 = y2
|
|
||||||
#define OFFSET(x, y) y * SCREEN_WIDTH + x
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
void cputc(char c) {
|
|
||||||
if (cursy >= cy1 && cursy <= cy2
|
|
||||||
&& cursy >= 0 && cursy <= SCREEN_HEIGHT
|
|
||||||
&& cursx >= 0 && cursx < SCREEN_WIDTH) {
|
|
||||||
unsigned int offset = OFFSET(cursx, cursy);
|
|
||||||
*((char *) VRAM_CHAR + offset) = c;
|
|
||||||
*((char *) VRAM_ATTR + offset) = reversed ? COLOR_REVERSED : COLOR_NORMAL;
|
|
||||||
}
|
|
||||||
cursx++;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
void cputs(char *str) {
|
|
||||||
while (*str != 0) {
|
|
||||||
cputc(*str);
|
|
||||||
str++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
void cputsn(char *str, unsigned char len) {
|
|
||||||
while ((len > 0) && (*str != 0)) {
|
|
||||||
cputc(*str);
|
|
||||||
str++;
|
|
||||||
len--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
void chline(unsigned char length) {
|
|
||||||
while (length > 0) {
|
|
||||||
cputc(CH_HOLILINE);
|
|
||||||
length--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
/* #define cvline(l) while (l > 0) { cputc(CH_VERTLINE); */
|
|
||||||
/* ++cursy; --cursx; l--; } */
|
|
||||||
|
|
||||||
void cvline(unsigned char length) {
|
|
||||||
while (length > 0) {
|
|
||||||
cputc(CH_VERTLINE);
|
|
||||||
++cursy;
|
|
||||||
--cursx;
|
|
||||||
length--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
void gotoxy(unsigned char x, unsigned char y) {
|
|
||||||
cursx = x;
|
|
||||||
cursy = y;
|
|
||||||
}
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
void clearTo(char x) {
|
|
||||||
while (cursx < x) {
|
|
||||||
cputc(CH_SPACE);
|
|
||||||
}
|
|
||||||
cursx = x;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
void ctk_draw_clear(unsigned char clipy1, unsigned char clipy2) {
|
|
||||||
while (clipy1 < clipy2) {
|
|
||||||
gotoxy(0, clipy1);
|
|
||||||
clearTo(SCREEN_WIDTH);
|
|
||||||
clipy1++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
void ctk_draw_init(void) {
|
|
||||||
clip(0, SCREEN_HEIGHT);
|
|
||||||
ctk_draw_clear(0, SCREEN_HEIGHT);
|
|
||||||
}
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
/*
|
|
||||||
* w: widget
|
|
||||||
* x, y: screen position of client drawing area (left, top)
|
|
||||||
* clipx, clipy: screen position of client drawing area (right, bottom)
|
|
||||||
* clipy1, clipy2: min/max y position of screen
|
|
||||||
* focus: boolean
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
draw_widget(struct ctk_widget *w,
|
|
||||||
unsigned char x, unsigned char y,
|
|
||||||
unsigned char focus) {
|
|
||||||
unsigned char xpos, ypos, xscroll;
|
|
||||||
unsigned char i, j;
|
|
||||||
char c, *text;
|
|
||||||
#if CTK_CONF_ICONS
|
|
||||||
unsigned char len;
|
|
||||||
#endif /* CTK_CONF_ICONS */
|
|
||||||
|
|
||||||
xpos = x + w->x;
|
|
||||||
ypos = y + w->y;
|
|
||||||
|
|
||||||
revers(focus & CTK_FOCUS_WIDGET);
|
|
||||||
gotoxy(xpos, ypos);
|
|
||||||
|
|
||||||
if (w->type == CTK_WIDGET_SEPARATOR) {
|
|
||||||
chline(w->w);
|
|
||||||
} else if (w->type == CTK_WIDGET_LABEL) {
|
|
||||||
text = w->widget.label.text;
|
|
||||||
for(i = 0; i < w->h; ++i) {
|
|
||||||
gotoxy(xpos, ypos);
|
|
||||||
cputsn(text, w->w);
|
|
||||||
clearTo(xpos + w->w);
|
|
||||||
++ypos;
|
|
||||||
text += w->w;
|
|
||||||
}
|
|
||||||
} else if (w->type == CTK_WIDGET_BUTTON) {
|
|
||||||
cputc('[');
|
|
||||||
cputsn(w->widget.button.text, w->w);
|
|
||||||
cputc(']');
|
|
||||||
} else if (w->type == CTK_WIDGET_HYPERLINK) {
|
|
||||||
cputsn(w->widget.hyperlink.text, w->w);
|
|
||||||
} else if (w->type == CTK_WIDGET_TEXTENTRY) {
|
|
||||||
text = w->widget.textentry.text;
|
|
||||||
xscroll = 0;
|
|
||||||
if(w->widget.textentry.xpos >= w->w - 1) {
|
|
||||||
xscroll = w->widget.textentry.xpos - w->w + 1;
|
|
||||||
}
|
|
||||||
for(j = 0; j < w->h; ++j) {
|
|
||||||
gotoxy(xpos, ypos);
|
|
||||||
if(w->widget.textentry.state == CTK_TEXTENTRY_EDIT &&
|
|
||||||
w->widget.textentry.ypos == j) {
|
|
||||||
revers(0);
|
|
||||||
cputc('>');
|
|
||||||
for(i = 0; i < w->w; ++i) {
|
|
||||||
c = text[i + xscroll];
|
|
||||||
revers(i == w->widget.textentry.xpos - xscroll);
|
|
||||||
cputc((c == 0) ? CH_SPACE : c);
|
|
||||||
}
|
|
||||||
revers(0);
|
|
||||||
cputc('<');
|
|
||||||
} else {
|
|
||||||
cputc(CH_VERTLINE);
|
|
||||||
cputsn(text, w->w);
|
|
||||||
clearTo(xpos + w->w + 1);
|
|
||||||
cputc(CH_VERTLINE);
|
|
||||||
}
|
|
||||||
++ypos;
|
|
||||||
text += w->w;
|
|
||||||
}
|
|
||||||
#if CTK_CONF_ICONS
|
|
||||||
} else if (w->type == CTK_WIDGET_ICON) {
|
|
||||||
if(w->widget.icon.textmap != NULL) {
|
|
||||||
for(i = 0; i < 3; ++i) {
|
|
||||||
gotoxy(xpos, ypos);
|
|
||||||
cputc(w->widget.icon.textmap[0 + 3 * i]);
|
|
||||||
cputc(w->widget.icon.textmap[1 + 3 * i]);
|
|
||||||
cputc(w->widget.icon.textmap[2 + 3 * i]);
|
|
||||||
++ypos;
|
|
||||||
}
|
|
||||||
x = xpos;
|
|
||||||
|
|
||||||
len = strlen(w->widget.icon.title);
|
|
||||||
if(x + len >= SCREEN_WIDTH) {
|
|
||||||
x = SCREEN_WIDTH - len;
|
|
||||||
}
|
|
||||||
gotoxy(x, ypos);
|
|
||||||
cputs(w->widget.icon.title);
|
|
||||||
}
|
|
||||||
#endif /* CTK_CONF_ICONS */
|
|
||||||
}
|
|
||||||
revers(0);
|
|
||||||
|
|
||||||
}
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
void
|
|
||||||
ctk_draw_widget(struct ctk_widget *w,
|
|
||||||
unsigned char focus,
|
|
||||||
unsigned char clipy1,
|
|
||||||
unsigned char clipy2) {
|
|
||||||
|
|
||||||
struct ctk_window *win = w->window;
|
|
||||||
unsigned char posx, posy;
|
|
||||||
clip(clipy1, clipy2);
|
|
||||||
|
|
||||||
posx = win->x + 1;
|
|
||||||
posy = win->y + 2;
|
|
||||||
|
|
||||||
if(w == win->focused) {
|
|
||||||
focus |= CTK_FOCUS_WIDGET;
|
|
||||||
}
|
|
||||||
|
|
||||||
draw_widget(w, posx, posy, focus);
|
|
||||||
}
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
void
|
|
||||||
ctk_draw_clear_window(struct ctk_window *window,
|
|
||||||
unsigned char focus,
|
|
||||||
unsigned char clipy1,
|
|
||||||
unsigned char clipy2) {
|
|
||||||
|
|
||||||
unsigned char i;
|
|
||||||
unsigned char x1, x2, y1, y2;
|
|
||||||
x1 = window->x + 1;
|
|
||||||
x2 = x1 + window->w;
|
|
||||||
y1 = window->y + 2;
|
|
||||||
y2 = y1 + window->h;
|
|
||||||
|
|
||||||
for(i = y1; i < y2; ++i) {
|
|
||||||
gotoxy(x1, i);
|
|
||||||
clearTo(x2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
void draw_window_sub(struct ctk_window *window, unsigned char focus) {
|
|
||||||
|
|
||||||
unsigned char x, y;
|
|
||||||
unsigned char x1, y1, x2;
|
|
||||||
struct ctk_widget *w;
|
|
||||||
unsigned char wfocus;
|
|
||||||
|
|
||||||
x = window->x;
|
|
||||||
y = window->y + 1;
|
|
||||||
|
|
||||||
x1 = x + 1;
|
|
||||||
y1 = y + 1;
|
|
||||||
x2 = x1 + window->w;
|
|
||||||
|
|
||||||
// |_
|
|
||||||
gotoxy(x, y1);
|
|
||||||
cvline(window->h);
|
|
||||||
cputc(CH_LLCORNER);
|
|
||||||
chline(window->w);
|
|
||||||
cputc(CH_LRCORNER);
|
|
||||||
|
|
||||||
// -
|
|
||||||
gotoxy(x, y);
|
|
||||||
cputc(CH_ULCORNER);
|
|
||||||
chline(window->w);
|
|
||||||
cputc(CH_URCORNER);
|
|
||||||
// |
|
|
||||||
gotoxy(x2, y1);
|
|
||||||
cvline(window->h);
|
|
||||||
|
|
||||||
/* Draw inactive widgets. */
|
|
||||||
for(w = window->inactive; w != NULL; w = w->next) {
|
|
||||||
draw_widget(w, x1, y1, focus);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Draw active widgets. */
|
|
||||||
for(w = window->active; w != NULL; w = w->next) {
|
|
||||||
wfocus = focus;
|
|
||||||
if(w == window->focused) {
|
|
||||||
wfocus |= CTK_FOCUS_WIDGET;
|
|
||||||
}
|
|
||||||
draw_widget(w, x1, y1, wfocus);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
void
|
|
||||||
ctk_draw_window(struct ctk_window *window, unsigned char focus,
|
|
||||||
unsigned char clipy1, unsigned char clipy2, unsigned char draw_borders) {
|
|
||||||
clip(clipy1, clipy2);
|
|
||||||
|
|
||||||
focus = focus & CTK_FOCUS_WINDOW;
|
|
||||||
draw_window_sub(window, focus);
|
|
||||||
}
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
void ctk_draw_dialog(struct ctk_window *dialog) {
|
|
||||||
clip(0, SCREEN_HEIGHT);
|
|
||||||
|
|
||||||
ctk_draw_clear_window(dialog, 0, 0, SCREEN_HEIGHT);
|
|
||||||
draw_window_sub(dialog, CTK_FOCUS_DIALOG);
|
|
||||||
}
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
#if CTK_CONF_MENUS
|
|
||||||
void draw_menu(struct ctk_menu *m, struct ctk_menu *open) {
|
|
||||||
#if CC_CONF_UNSIGNED_CHAR_BUGS
|
|
||||||
unsigned char x2;
|
|
||||||
unsigned int x, y;
|
|
||||||
#else
|
|
||||||
unsigned char x2;
|
|
||||||
unsigned char x, y;
|
|
||||||
#endif
|
|
||||||
x = cursx;
|
|
||||||
cputs(m->title);
|
|
||||||
cputc(CH_SPACE);
|
|
||||||
|
|
||||||
if (m == open) {
|
|
||||||
x2 = cursx;
|
|
||||||
if(x + CTK_CONF_MENUWIDTH > SCREEN_WIDTH) {
|
|
||||||
x = SCREEN_WIDTH - CTK_CONF_MENUWIDTH;
|
|
||||||
}
|
|
||||||
|
|
||||||
for(y = 0; y < m->nitems; y++) {
|
|
||||||
if(y == m->active) {
|
|
||||||
revers(0);
|
|
||||||
}
|
|
||||||
gotoxy(x, y + 1);
|
|
||||||
if(m->items[y].title[0] == '-') {
|
|
||||||
chline(CTK_CONF_MENUWIDTH);
|
|
||||||
} else {
|
|
||||||
cputs(m->items[y].title);
|
|
||||||
}
|
|
||||||
clearTo(x + CTK_CONF_MENUWIDTH);
|
|
||||||
revers(1);
|
|
||||||
}
|
|
||||||
gotoxy(x2, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
void ctk_draw_menus(struct ctk_menus *menus) {
|
|
||||||
struct ctk_menu *m;
|
|
||||||
|
|
||||||
clip(0, SCREEN_HEIGHT);
|
|
||||||
/* Draw menus */
|
|
||||||
gotoxy(0, 0);
|
|
||||||
revers(1);
|
|
||||||
for(m = menus->menus->next; m != NULL; m = m->next) {
|
|
||||||
draw_menu(m, menus->open);
|
|
||||||
}
|
|
||||||
|
|
||||||
clearTo(SCREEN_WIDTH - strlen(menus->desktopmenu->title) - 1);
|
|
||||||
|
|
||||||
/* Draw desktopmenu */
|
|
||||||
draw_menu(menus->desktopmenu, menus->open);
|
|
||||||
|
|
||||||
revers(0);
|
|
||||||
}
|
|
||||||
#endif /* CTK_CONF_MENUS */
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
/* Returns width and height of screen. */
|
|
||||||
unsigned char ctk_draw_width(void) {
|
|
||||||
return SCREEN_WIDTH;
|
|
||||||
}
|
|
||||||
unsigned char ctk_draw_height(void) {
|
|
||||||
return SCREEN_HEIGHT;
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,104 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2007, Takahide Matsutsuka.
|
|
||||||
* 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. The name of the author may not be used to endorse or promote
|
|
||||||
* products derived from this software without specific prior
|
|
||||||
* written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* \file
|
|
||||||
* This is architecture-depend contiki toolkit for PC-6001 family.
|
|
||||||
* \author
|
|
||||||
* Takahide Matsutsuka <markn@markn.org>
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#include "ctk/ctk.h"
|
|
||||||
#include "ctk/ctk-draw.h"
|
|
||||||
#include "contiki-conf.h"
|
|
||||||
#include "ctk/ctk_arch.h"
|
|
||||||
#include <stddef.h>
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
/*
|
|
||||||
* Offset constants for assembler
|
|
||||||
*/
|
|
||||||
const uint8_t off_widget_x = offsetof(struct ctk_widget, x);
|
|
||||||
const uint8_t off_widget_y = offsetof(struct ctk_widget, y);
|
|
||||||
const uint8_t off_widget_w = offsetof(struct ctk_widget, w);
|
|
||||||
const uint8_t off_widget_h = offsetof(struct ctk_widget, h);
|
|
||||||
const uint8_t off_widget_type = offsetof(struct ctk_widget, type);
|
|
||||||
const uint8_t off_widget_window = offsetof(struct ctk_widget, window);
|
|
||||||
|
|
||||||
const uint8_t off_widget_label_text = offsetof(struct ctk_widget, widget) +
|
|
||||||
offsetof(struct ctk_widget_label, text);
|
|
||||||
const uint8_t off_widget_button_text = offsetof(struct ctk_widget, widget) +
|
|
||||||
offsetof(struct ctk_widget_button, text);
|
|
||||||
const uint8_t off_widget_textentry_text = offsetof(struct ctk_widget, widget) +
|
|
||||||
offsetof(struct ctk_widget_textentry, text);
|
|
||||||
const uint8_t off_widget_textentry_xpos = offsetof(struct ctk_widget, widget) +
|
|
||||||
offsetof(struct ctk_widget_textentry, xpos);
|
|
||||||
const uint8_t off_widget_textentry_ypos = offsetof(struct ctk_widget, widget) +
|
|
||||||
offsetof(struct ctk_widget_textentry, ypos);
|
|
||||||
const uint8_t off_widget_textentry_state = offsetof(struct ctk_widget, widget) +
|
|
||||||
offsetof(struct ctk_widget_textentry, state);
|
|
||||||
#if CTK_CONF_HYPERLINK
|
|
||||||
const uint8_t off_widget_hyperlink_text = offsetof(struct ctk_widget, widget) +
|
|
||||||
offsetof(struct ctk_widget_hyperlink, text);
|
|
||||||
#endif /* CTK_CONF_HYPERLINK */
|
|
||||||
|
|
||||||
#if CTK_CONF_ICONS
|
|
||||||
const uint8_t off_widget_icon_title = offsetof(struct ctk_widget, widget) +
|
|
||||||
offsetof(struct ctk_widget_icon, title);
|
|
||||||
const uint8_t off_widget_icon_textmap = offsetof(struct ctk_widget, widget) +
|
|
||||||
offsetof(struct ctk_widget_icon, textmap);
|
|
||||||
#endif /* CTK_CONF_ICONS */
|
|
||||||
|
|
||||||
const uint8_t off_window_x = offsetof(struct ctk_window, x);
|
|
||||||
const uint8_t off_window_y = offsetof(struct ctk_window, y);
|
|
||||||
const uint8_t off_window_h = offsetof(struct ctk_window, h);
|
|
||||||
const uint8_t off_window_w = offsetof(struct ctk_window, w);
|
|
||||||
const uint8_t off_window_inactive = offsetof(struct ctk_window, inactive);
|
|
||||||
const uint8_t off_window_active = offsetof(struct ctk_window, active);
|
|
||||||
const uint8_t off_window_next = offsetof(struct ctk_window, next);
|
|
||||||
const uint8_t off_window_focused = offsetof(struct ctk_window, focused);
|
|
||||||
|
|
||||||
#if CTK_CONF_MENUS
|
|
||||||
const uint8_t off_menu_title = offsetof(struct ctk_menu, title);
|
|
||||||
const uint8_t off_menu_active = offsetof(struct ctk_menu, active);
|
|
||||||
const uint8_t off_menu_nitems = offsetof(struct ctk_menu, nitems);
|
|
||||||
const uint8_t off_menu_items = offsetof(struct ctk_menu, items);
|
|
||||||
const uint8_t off_menu_next = offsetof(struct ctk_menu, next);
|
|
||||||
const uint8_t off_menuitem_title = offsetof(struct ctk_menuitem, title);
|
|
||||||
const uint8_t size_menuitem = sizeof(struct ctk_menuitem);
|
|
||||||
const uint8_t off_menus_open = offsetof(struct ctk_menus, open);
|
|
||||||
const uint8_t off_menus_menus = offsetof(struct ctk_menus, menus);
|
|
||||||
const uint8_t off_menus_desktopmenu = offsetof(struct ctk_menus, desktopmenu);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
|
@ -1,193 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2007, Takahide Matsutsuka.
|
|
||||||
* 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. The name of the author may not be used to endorse or promote
|
|
||||||
* products derived from this software without specific prior
|
|
||||||
* written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* \file
|
|
||||||
* ctk_arch-def.h
|
|
||||||
* Definitions of CTK for PC-6001 family, which consist of the following:
|
|
||||||
* - Configuraton for ctk main library.
|
|
||||||
* - Configuraton for ctk_arch library.
|
|
||||||
* This file is used in assembler file with precompilation, so
|
|
||||||
* NEVER include other than directives and comments.
|
|
||||||
* \author
|
|
||||||
* Takahide Matsutsuka <markn@markn.org>
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __CTK_ARCH_DEF_H__
|
|
||||||
#define __CTK_ARCH_DEF_H__
|
|
||||||
|
|
||||||
/* characters */
|
|
||||||
#if defined(ARCH_PC6001) || defined(ARCH_PC6001MK2)
|
|
||||||
#define CH_VERTLINE 0x16
|
|
||||||
#define CH_HOLILINE 0x17
|
|
||||||
#define CH_ULCORNER 0x18
|
|
||||||
#define CH_URCORNER 0x19
|
|
||||||
#define CH_LLCORNER 0x1a
|
|
||||||
#define CH_LRCORNER 0x1b
|
|
||||||
#elif defined(ARCH_PC6001A)
|
|
||||||
#define CH_VERTLINE '|'
|
|
||||||
#define CH_HOLILINE '-'
|
|
||||||
#define CH_ULCORNER '/'
|
|
||||||
#define CH_URCORNER '\\'
|
|
||||||
#define CH_LLCORNER '\\'
|
|
||||||
#define CH_LRCORNER '/'
|
|
||||||
#else
|
|
||||||
#error invalid ARCH
|
|
||||||
#endif
|
|
||||||
#define CH_SPACE 0x20
|
|
||||||
|
|
||||||
/* screen properties */
|
|
||||||
#if defined(ARCH_PC6001MK2)
|
|
||||||
#define VRAM_ATTR 0x4000
|
|
||||||
#define VRAM_CHAR 0x4400
|
|
||||||
#define SCREEN_WIDTH 40
|
|
||||||
#define SCREEN_HEIGHT 20
|
|
||||||
#define COLOR_NORMAL 0x0f
|
|
||||||
#define COLOR_REVERSED 0x70
|
|
||||||
#elif (defined(ARCH_PC6001) || defined(ARCH_PC6001A)) && defined(MEMORY_16K)
|
|
||||||
#define VRAM_ATTR 0xc000
|
|
||||||
#define VRAM_CHAR 0xc200
|
|
||||||
#define SCREEN_WIDTH 32
|
|
||||||
#define SCREEN_HEIGHT 16
|
|
||||||
#define COLOR_NORMAL 0x20
|
|
||||||
#define COLOR_REVERSED 0x21
|
|
||||||
#elif (defined(ARCH_PC6001) || defined(ARCH_PC6001A)) && (defined(MEMORY_32K) || defined(MEMORY_ROM))
|
|
||||||
#define VRAM_ATTR 0x8000
|
|
||||||
#define VRAM_CHAR 0x8200
|
|
||||||
#define SCREEN_WIDTH 32
|
|
||||||
#define SCREEN_HEIGHT 16
|
|
||||||
#define COLOR_NORMAL 0x20
|
|
||||||
#define COLOR_REVERSED 0x21
|
|
||||||
#else
|
|
||||||
#error Specify appropriate ARCH & MEMORY combination
|
|
||||||
#endif /* ARCH_PC6001MK2 */
|
|
||||||
|
|
||||||
/* key code */
|
|
||||||
#define CH_F1 -16//0xf0
|
|
||||||
#define CH_F2 -15//0xf1
|
|
||||||
#define CH_F3 -14//0xf2
|
|
||||||
#define CH_F4 -13//0xf3
|
|
||||||
#define CH_F5 -12//0xf4
|
|
||||||
#define CH_TAB 0x09
|
|
||||||
|
|
||||||
#define CH_CURS_UP 0x1e
|
|
||||||
#define CH_CURS_DOWN 0x1f
|
|
||||||
#define CH_CURS_LEFT 0x1d
|
|
||||||
#define CH_CURS_RIGHT 0x1c
|
|
||||||
#define CH_ENTER 0x0d
|
|
||||||
#define CH_ESC 0x1b
|
|
||||||
#define CH_STOP 0x03
|
|
||||||
#define CH_DEL 0x08
|
|
||||||
|
|
||||||
/* Contiki toolkit options */
|
|
||||||
|
|
||||||
#if defined(CTK_CLIENT) || defined(CTK_SERVER)
|
|
||||||
/* If network is available, turn all options off by the memory reason */
|
|
||||||
#define CTK_CONF_ICONS 0
|
|
||||||
#define CTK_CONF_ICON_TEXTMAPS 0
|
|
||||||
#define CTK_CONF_WINDOWS 1
|
|
||||||
#define CTK_CONF_WINDOWCLOSE 0
|
|
||||||
#define CTK_CONF_WINDOWMOVE 0
|
|
||||||
#define CTK_CONF_MENUS 0
|
|
||||||
#define CTK_CONF_HYPERLINK 0
|
|
||||||
#elif defined(CTK_NOICON)
|
|
||||||
/* In the case of loader arch, we omit the icons by the memory reason */
|
|
||||||
#define CTK_CONF_ICONS 0
|
|
||||||
#define CTK_CONF_ICON_TEXTMAPS 0
|
|
||||||
#define CTK_CONF_WINDOWS 1
|
|
||||||
#define CTK_CONF_WINDOWCLOSE 1
|
|
||||||
#define CTK_CONF_WINDOWMOVE 1
|
|
||||||
#define CTK_CONF_MENUS 1
|
|
||||||
#define CTK_CONF_HYPERLINK 1
|
|
||||||
#else /* CTK_MINIMUM */
|
|
||||||
/* Toggles support for desktop icons. */
|
|
||||||
#define CTK_CONF_ICONS 1
|
|
||||||
/* Define if text icon is used. */
|
|
||||||
#define CTK_CONF_ICON_TEXTMAPS 1
|
|
||||||
/* Toggles support for windows. */
|
|
||||||
#define CTK_CONF_WINDOWS 1
|
|
||||||
/* Toggles support for closable windows. */
|
|
||||||
#define CTK_CONF_WINDOWCLOSE 1
|
|
||||||
/* Toggles support for movable windows. */
|
|
||||||
#define CTK_CONF_WINDOWMOVE 1
|
|
||||||
/* Toggles support for menus. */
|
|
||||||
#define CTK_CONF_MENUS 1
|
|
||||||
/* Defines if hyperlink is supported. */
|
|
||||||
#define CTK_CONF_HYPERLINK 1
|
|
||||||
#endif /* CTK_MINIMUM */
|
|
||||||
|
|
||||||
/* Define if bitmap icon is used. */
|
|
||||||
#define CTK_CONF_ICON_BITMAPS 0
|
|
||||||
/* Defines the default width of a menu. */
|
|
||||||
#define CTK_CONF_MENUWIDTH 16
|
|
||||||
/* Defines if screen saver is supported. */
|
|
||||||
#define CTK_CONF_SCREENSAVER 0
|
|
||||||
/* Defines if mouse is supported. */
|
|
||||||
#define CTK_CONF_MOUSE_SUPPORT 0
|
|
||||||
|
|
||||||
/* The maximum number of menu items in each menu. */
|
|
||||||
#define CTK_CONF_MAXMENUITEMS 4
|
|
||||||
|
|
||||||
/* Key used to switch the frontmost window. */
|
|
||||||
#define CTK_CONF_WINDOWSWITCH_KEY CH_F3
|
|
||||||
/* Key used to move down a widget. */
|
|
||||||
#define CTK_CONF_WIDGETDOWN_KEY CH_TAB
|
|
||||||
/* Key used to move up a widget. */
|
|
||||||
#define CTK_CONF_WIDGETUP_KEY CH_F5
|
|
||||||
/* Defines which key that is to be used for activating the menus */
|
|
||||||
#define CTK_CONF_MENU_KEY CH_F1
|
|
||||||
|
|
||||||
#ifdef LIBCONIO_CONF_EXPORT
|
|
||||||
#define LIBCONIO_EXPORT LIBCONIO_CONF_EXPORT
|
|
||||||
#else /* LIBCONIO_CONF_EXPORT */
|
|
||||||
#define LIBCONIO_EXPORT 0
|
|
||||||
#endif /* LIBCONIO_CONF_EXPORT */
|
|
||||||
|
|
||||||
/* Imported symbols from ctk.h */
|
|
||||||
|
|
||||||
#define _CTK_FOCUS_NONE 0
|
|
||||||
#define _CTK_FOCUS_WIDGET 1
|
|
||||||
#define _CTK_FOCUS_WINDOW 2
|
|
||||||
#define _CTK_FOCUS_DIALOG 4
|
|
||||||
|
|
||||||
#define _CTK_WIDGET_SEPARATOR 1
|
|
||||||
#define _CTK_WIDGET_LABEL 2
|
|
||||||
#define _CTK_WIDGET_BUTTON 3
|
|
||||||
#define _CTK_WIDGET_HYPERLINK 4
|
|
||||||
#define _CTK_WIDGET_TEXTENTRY 5
|
|
||||||
#define _CTK_WIDGET_BITMAP 6
|
|
||||||
#define _CTK_WIDGET_ICON 7
|
|
||||||
|
|
||||||
#define _CTK_TEXTENTRY_NORMAL 0
|
|
||||||
#define _CTK_TEXTENTRY_EDIT 1
|
|
||||||
|
|
||||||
#endif /* __CTK_ARCH_DEF_H__ */
|
|
|
@ -1,48 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2007, Takahide Matsutsuka.
|
|
||||||
* 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. The name of the author may not be used to endorse or promote
|
|
||||||
* products derived from this software without specific prior
|
|
||||||
* written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* \file
|
|
||||||
* ctk_arch.h
|
|
||||||
* Archtecture specific definitions and library declarations.
|
|
||||||
* \author
|
|
||||||
* Takahide Matsutsuka <markn@markn.org>
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __CTK_ARCH_H__
|
|
||||||
#define __CTK_ARCH_H__
|
|
||||||
|
|
||||||
#include "ctk/ctk_arch-def.h"
|
|
||||||
#include "dev/getkey.h"
|
|
||||||
#include "dev/isprint_arch.h"
|
|
||||||
|
|
||||||
#endif /* __CTK_ARCH_H__ */
|
|
|
@ -1,382 +0,0 @@
|
||||||
;;;
|
|
||||||
;;;
|
|
||||||
;;; libconio_arch-asm.hS
|
|
||||||
;;;
|
|
||||||
;;; Architecture depend libconio implementation.
|
|
||||||
;;; This assembler source contributes basically saving for speed and memory.
|
|
||||||
;;;
|
|
||||||
;;; @author Takahide Matsutsuka <markn@markn.org>
|
|
||||||
;;;
|
|
||||||
;;; $Id: libconio_arch-asm.cS,v 1.2 2007/09/29 04:10:00 matsutsuka Exp $
|
|
||||||
;;;
|
|
||||||
|
|
||||||
;; uses preprocessor to enable definitions
|
|
||||||
#include "ctk_arch-def.h"
|
|
||||||
|
|
||||||
;; export symbols
|
|
||||||
.if LIBCONIO_EXPORT
|
|
||||||
.globl _cputc_arch
|
|
||||||
.globl _cputs_arch
|
|
||||||
.globl _cputsn_arch
|
|
||||||
.globl _chline_arch
|
|
||||||
.globl _cvline_arch
|
|
||||||
.globl _gotoxy_arch
|
|
||||||
.globl _clearto_arch
|
|
||||||
.globl _revers_arch
|
|
||||||
.globl _clip_arch
|
|
||||||
.endif
|
|
||||||
.globl _wherex_arch
|
|
||||||
.globl _wherey_arch
|
|
||||||
|
|
||||||
.area _DATA
|
|
||||||
_screen_cursor:
|
|
||||||
.ds 1 ; x
|
|
||||||
.ds 1 ; y
|
|
||||||
_screen_clips:
|
|
||||||
.ds 1 ; clip y1
|
|
||||||
.ds 1 ; clip y2
|
|
||||||
_screen_reversed:
|
|
||||||
.ds 1
|
|
||||||
|
|
||||||
.area _CODE
|
|
||||||
|
|
||||||
_libconio_arch_asm_start::
|
|
||||||
;; ---------------------------------
|
|
||||||
;; void cputc(char ch);
|
|
||||||
;; Stack; retl reth ch
|
|
||||||
;; AFBCDEHL____
|
|
||||||
;; return A=1 if output is succeeded, A=0 if not
|
|
||||||
;; ---------------------------------
|
|
||||||
.if LIBCONIO_EXPORT
|
|
||||||
_cputc_arch:
|
|
||||||
ld hl, #2
|
|
||||||
add hl, sp
|
|
||||||
ld a, (hl)
|
|
||||||
.endif ; LIBCONIO_EXPORT
|
|
||||||
;; ------------
|
|
||||||
;; A = char
|
|
||||||
;; AFBCDEHL____
|
|
||||||
;; ------------
|
|
||||||
_cputc_arch_asm::
|
|
||||||
push af
|
|
||||||
ld bc, (#_screen_cursor) ;B=y, C=x
|
|
||||||
ld de, (#_screen_clips) ;D=cy2, E=cy1
|
|
||||||
ld a, b
|
|
||||||
cp a, e
|
|
||||||
jr c, _cputc_arch_ret_false ; if (cursy < cy1)
|
|
||||||
cp a, d
|
|
||||||
jr z, _cputc_arch_next1
|
|
||||||
jr nc, _cputc_arch_ret_false ; if (cursy > cy2)
|
|
||||||
_cputc_arch_next1:
|
|
||||||
cp a, #SCREEN_HEIGHT ; cursy - SCREEN_HEIGHT
|
|
||||||
jr z, _cputc_arch_next2
|
|
||||||
jr nc, _cputc_arch_ret_false ; if (cursy > SCREEN_HEIGHT)
|
|
||||||
_cputc_arch_next2:
|
|
||||||
ld a, c
|
|
||||||
cp a, #SCREEN_WIDTH ; cursx - SCREEN_WIDTH
|
|
||||||
jr nc, _cputc_arch_ret_false ; if (cursx >= SCREEN_WIDTH)
|
|
||||||
;; calculate offset
|
|
||||||
ld a, b ; A=y
|
|
||||||
ld hl, #0
|
|
||||||
ld de, #SCREEN_WIDTH
|
|
||||||
_cputc_arch_loop:
|
|
||||||
or a
|
|
||||||
jr z, _cputc_arch_calcx
|
|
||||||
add hl, de
|
|
||||||
dec a
|
|
||||||
jr _cputc_arch_loop
|
|
||||||
_cputc_arch_calcx:
|
|
||||||
ld d, #0
|
|
||||||
ld e, c
|
|
||||||
add hl, de
|
|
||||||
|
|
||||||
;; putchar
|
|
||||||
pop af
|
|
||||||
ld de, #VRAM_CHAR
|
|
||||||
push hl
|
|
||||||
add hl, de
|
|
||||||
ld (hl), a
|
|
||||||
pop hl
|
|
||||||
;; putattr
|
|
||||||
ld de, #VRAM_ATTR
|
|
||||||
add hl, de
|
|
||||||
ld a, (#_screen_reversed)
|
|
||||||
or a
|
|
||||||
jr z, _cputc_arch_normal
|
|
||||||
ld (hl), #COLOR_REVERSED
|
|
||||||
jr _cputc_arch_ret
|
|
||||||
_cputc_arch_normal:
|
|
||||||
ld (hl), #COLOR_NORMAL
|
|
||||||
ld a, #0x01
|
|
||||||
_cputc_arch_ret:
|
|
||||||
ld hl, #_screen_cursor
|
|
||||||
inc (hl)
|
|
||||||
ret
|
|
||||||
_cputc_arch_ret_false:
|
|
||||||
pop af
|
|
||||||
xor a
|
|
||||||
jr _cputc_arch_ret
|
|
||||||
|
|
||||||
;; ---------------------------------
|
|
||||||
;; void cputs_arch(char *str);
|
|
||||||
;; Stack; retl reth strl strh
|
|
||||||
;; AFB_DEHL____
|
|
||||||
;; return void
|
|
||||||
;; ---------------------------------
|
|
||||||
.if 1
|
|
||||||
_cputs_arch::
|
|
||||||
ld hl, #2
|
|
||||||
add hl, sp
|
|
||||||
ld e, (hl)
|
|
||||||
inc hl
|
|
||||||
ld d, (hl)
|
|
||||||
.endif ; LIBCONIO_EXPORT
|
|
||||||
|
|
||||||
;; ------------
|
|
||||||
;; DE = str
|
|
||||||
;; AFB_DEHL____
|
|
||||||
;; ------------
|
|
||||||
_cputs_arch_asm::
|
|
||||||
ld b, #SCREEN_WIDTH ; max length
|
|
||||||
jr _cputsn_arch_asm ; take over B and DE
|
|
||||||
|
|
||||||
;; ---------------------------------
|
|
||||||
;; void cputsn(char *str, unsigned char length);
|
|
||||||
;; Stack; retl reth strl strh length
|
|
||||||
;; AFB_DEHL____
|
|
||||||
;; return void
|
|
||||||
;; ---------------------------------
|
|
||||||
.if LIBCONIO_EXPORT
|
|
||||||
_cputsn_arch:
|
|
||||||
ld hl, #2
|
|
||||||
add hl, sp
|
|
||||||
ld e, (hl)
|
|
||||||
inc hl
|
|
||||||
ld d, (hl)
|
|
||||||
inc hl
|
|
||||||
ld b, (hl)
|
|
||||||
.endif ; LIBCONIO_EXPORT
|
|
||||||
|
|
||||||
;; ------------
|
|
||||||
;; B = nchars
|
|
||||||
;; DE = str
|
|
||||||
;; AFB_DEHL____
|
|
||||||
;; ------------
|
|
||||||
_cputsn_arch_asm::
|
|
||||||
ld a, (de)
|
|
||||||
or a
|
|
||||||
ret z
|
|
||||||
push bc
|
|
||||||
push de
|
|
||||||
call _cputc_arch_asm
|
|
||||||
pop de
|
|
||||||
pop bc
|
|
||||||
inc de
|
|
||||||
djnz _cputsn_arch_asm
|
|
||||||
ret
|
|
||||||
|
|
||||||
;; ---------------------------------
|
|
||||||
;; void chline(unsigned char length);
|
|
||||||
;; Stack; retl reth length
|
|
||||||
;; AFB_DEHL____
|
|
||||||
;; return void
|
|
||||||
;; ---------------------------------
|
|
||||||
.if LIBCONIO_EXPORT
|
|
||||||
_chline_arch:
|
|
||||||
ld hl, #2
|
|
||||||
add hl, sp
|
|
||||||
ld b, (hl)
|
|
||||||
;; ------------
|
|
||||||
;; B = length
|
|
||||||
;; AFB_DEHL____
|
|
||||||
;; ------------
|
|
||||||
.endif
|
|
||||||
_chline_arch_asm::
|
|
||||||
ld a, #CH_HOLILINE
|
|
||||||
push bc
|
|
||||||
call _cputc_arch_asm
|
|
||||||
pop bc
|
|
||||||
djnz _chline_arch_asm
|
|
||||||
ret
|
|
||||||
|
|
||||||
;; ---------------------------------
|
|
||||||
;; void cvline(unsigned char length);
|
|
||||||
;; Stack; retl reth length
|
|
||||||
;; AFB_DEHL____
|
|
||||||
;; return void
|
|
||||||
;; ---------------------------------
|
|
||||||
.if LIBCONIO_EXPORT
|
|
||||||
_cvline_arch:
|
|
||||||
ld hl, #2
|
|
||||||
add hl, sp
|
|
||||||
ld b, (hl) ; length
|
|
||||||
.endif ; LIBCONIO_EXPORT
|
|
||||||
;; ------------
|
|
||||||
;; B = length
|
|
||||||
;; AFB_DEHL____
|
|
||||||
;; ------------
|
|
||||||
_cvline_arch_asm::
|
|
||||||
ld hl, (#_screen_cursor) ; H=y, L=x
|
|
||||||
_cvline_arch_loop:
|
|
||||||
ld a, #CH_VERTLINE
|
|
||||||
push hl
|
|
||||||
push bc
|
|
||||||
call _cputc_arch_asm
|
|
||||||
pop bc
|
|
||||||
pop hl
|
|
||||||
inc h
|
|
||||||
ld (#_screen_cursor), hl
|
|
||||||
djnz _cvline_arch_loop
|
|
||||||
ret
|
|
||||||
|
|
||||||
;; ---------------------------------
|
|
||||||
;; void gotoxy(unsigned char x, unsigned char y)
|
|
||||||
;; Stack; retl reth x y
|
|
||||||
;; _F__DEHL____
|
|
||||||
;; return void
|
|
||||||
;; ---------------------------------
|
|
||||||
.if 1
|
|
||||||
_gotoxy_arch::
|
|
||||||
ld hl, #2
|
|
||||||
add hl, sp
|
|
||||||
ld e, (hl) ; y
|
|
||||||
inc hl
|
|
||||||
ld d, (hl) ; x
|
|
||||||
ld l, e ; L=x
|
|
||||||
ld h, d ; H=y
|
|
||||||
.endif ; LIBCONIO_EXPORT
|
|
||||||
|
|
||||||
;; ------------
|
|
||||||
;; H = x, L = y
|
|
||||||
;; ____________
|
|
||||||
;; ------------
|
|
||||||
_gotoxy_arch_asm::
|
|
||||||
ld (#_screen_cursor), hl
|
|
||||||
ret
|
|
||||||
|
|
||||||
;; ---------------------------------
|
|
||||||
;; void clearto_arch(unsigned char to)
|
|
||||||
;; Stack; retl reth to
|
|
||||||
;; AFBCDEHL____
|
|
||||||
;; return void
|
|
||||||
;; ---------------------------------
|
|
||||||
.if LIBCONIO_EXPORT
|
|
||||||
_clearto_arch:
|
|
||||||
ld hl, #2
|
|
||||||
add hl, sp
|
|
||||||
ld a, (hl)
|
|
||||||
.endif ; LIBCONIO_EXPORT
|
|
||||||
;; ------------
|
|
||||||
;; A = to
|
|
||||||
;; AFBCDEHL____
|
|
||||||
;; ------------
|
|
||||||
_clearto_arch_asm::
|
|
||||||
ld hl, #_screen_cursor
|
|
||||||
cp (hl) ; to - cursx
|
|
||||||
ret z
|
|
||||||
ret c
|
|
||||||
push af
|
|
||||||
ld a, #CH_SPACE
|
|
||||||
call _cputc_arch_asm
|
|
||||||
or a
|
|
||||||
pop af
|
|
||||||
ret z
|
|
||||||
jr _clearto_arch_asm
|
|
||||||
|
|
||||||
;; ---------------------------------
|
|
||||||
;; void revers_arch(unsigned char reverse)
|
|
||||||
;; Stack; retl reth reverse
|
|
||||||
;; A_____HL____
|
|
||||||
;; return void
|
|
||||||
;; ---------------------------------
|
|
||||||
.if LIBCONIO_EXPORT
|
|
||||||
_revers_arch:
|
|
||||||
ld hl, #2
|
|
||||||
add hl, sp
|
|
||||||
ld a, (hl)
|
|
||||||
.endif ; LIBCONIO_EXPORT
|
|
||||||
;; A = reverse
|
|
||||||
;; ____________
|
|
||||||
_revers_arch_asm::
|
|
||||||
ld (#_screen_reversed), a
|
|
||||||
ret
|
|
||||||
|
|
||||||
;; ---------------------------------
|
|
||||||
;; void clip_arch(unsigned char clip1, unsigned char clip2)
|
|
||||||
;; Stack; retl reth clip1 clip2
|
|
||||||
;; ____________
|
|
||||||
;; return void
|
|
||||||
;; ---------------------------------
|
|
||||||
.if LIBCONIO_EXPORT
|
|
||||||
_clip_arch:
|
|
||||||
push af
|
|
||||||
push hl
|
|
||||||
push de
|
|
||||||
ld hl, #0x08
|
|
||||||
add hl, sp
|
|
||||||
ld de, #_screen_clips
|
|
||||||
ld a, (hl)
|
|
||||||
ld (de), a
|
|
||||||
inc hl
|
|
||||||
inc de
|
|
||||||
ld a, (hl)
|
|
||||||
ld (de), a
|
|
||||||
pop de
|
|
||||||
pop hl
|
|
||||||
pop af
|
|
||||||
ret
|
|
||||||
.endif
|
|
||||||
;; ---------------------------------
|
|
||||||
;; L = clipy1, H = clipy2
|
|
||||||
;; ____________
|
|
||||||
;; ---------------------------------
|
|
||||||
_clip_arch_asm::
|
|
||||||
ld (#_screen_clips), hl
|
|
||||||
ret
|
|
||||||
|
|
||||||
;; ---------------------------------
|
|
||||||
;; unsigned char wherex_arch()
|
|
||||||
;; Stack; retl reth
|
|
||||||
;; A______L____
|
|
||||||
;; return x
|
|
||||||
;; ---------------------------------
|
|
||||||
_wherex_arch:
|
|
||||||
ld a, (#_screen_cursor)
|
|
||||||
ld l, a
|
|
||||||
ret
|
|
||||||
|
|
||||||
;; ---------------------------------
|
|
||||||
;; unsigned char wherey_arch()
|
|
||||||
;; Stack; retl reth
|
|
||||||
;; A______L____
|
|
||||||
;; return y
|
|
||||||
;; ---------------------------------
|
|
||||||
_wherey_arch:
|
|
||||||
ld a, (#_screen_cursor + 1)
|
|
||||||
ld l, a
|
|
||||||
ret
|
|
||||||
|
|
||||||
.if 0
|
|
||||||
_newline_arch:
|
|
||||||
ld hl, #_screen_cursor
|
|
||||||
xor a
|
|
||||||
ld (hl), a
|
|
||||||
inc hl
|
|
||||||
ld a, (hl)
|
|
||||||
inc a
|
|
||||||
cp a, #SCREEN_HEIGHT
|
|
||||||
jr nc, _newline_arch_scroll
|
|
||||||
ld (hl), a
|
|
||||||
ret
|
|
||||||
_newline_arch_scroll:
|
|
||||||
;; TODO: attr and specific impl
|
|
||||||
dec a
|
|
||||||
ld (hl), a
|
|
||||||
ld hl, #VRAM_CHAR + #SCREEN_WIDTH
|
|
||||||
ld de, #VRAM_CHAR
|
|
||||||
ld bc, #SCREEN_HEIGHT * #SCREEN_WIDTH - #SCREEN_WIDTH
|
|
||||||
ldir
|
|
||||||
ret
|
|
||||||
.endif
|
|
||||||
|
|
||||||
_libconio_arch_asm_end::
|
|
|
@ -1,115 +0,0 @@
|
||||||
;;;
|
|
||||||
;;;
|
|
||||||
;;; libconio_arch-small.hS
|
|
||||||
;;;
|
|
||||||
;;; Architecture depend libconio implementation.
|
|
||||||
;;; This assembler source contributes basically saving for speed and memory.
|
|
||||||
;;;
|
|
||||||
;;; @author Takahide Matsutsuka <markn@markn.org>
|
|
||||||
;;;
|
|
||||||
;;; $Id: libconio_arch-small.cS,v 1.2 2007/11/28 09:38:21 matsutsuka Exp $
|
|
||||||
;;;
|
|
||||||
|
|
||||||
;; uses preprocessor to enable definitions
|
|
||||||
#include "ctk_arch-def.h"
|
|
||||||
|
|
||||||
;; export symbols
|
|
||||||
.globl _clrscr_arch
|
|
||||||
.globl _libputc_arch
|
|
||||||
.globl _libputs_arch
|
|
||||||
|
|
||||||
.area _DATA
|
|
||||||
_screen_offset::
|
|
||||||
.ds 2
|
|
||||||
|
|
||||||
.area _CODE
|
|
||||||
|
|
||||||
_libconio_arch_small_start::
|
|
||||||
|
|
||||||
_clrscr_arch:
|
|
||||||
ld hl, #0
|
|
||||||
ld (#_screen_offset), hl
|
|
||||||
ld hl, #VRAM_CHAR
|
|
||||||
ld bc, #VRAM_CHAR + #SCREEN_HEIGHT * #SCREEN_WIDTH
|
|
||||||
_clrscr_arch_loop1:
|
|
||||||
ld (hl), #CH_SPACE
|
|
||||||
inc hl
|
|
||||||
ld a, h
|
|
||||||
cp b
|
|
||||||
jr nz, _clrscr_arch_loop1
|
|
||||||
ld a, l
|
|
||||||
cp c
|
|
||||||
jr nz, _clrscr_arch_loop1
|
|
||||||
ld hl, #VRAM_ATTR
|
|
||||||
ld bc, #VRAM_ATTR + #SCREEN_HEIGHT * #SCREEN_WIDTH
|
|
||||||
_clrscr_arch_loop2:
|
|
||||||
ld (hl), #COLOR_NORMAL
|
|
||||||
inc hl
|
|
||||||
ld a, h
|
|
||||||
cp b
|
|
||||||
jr nz, _clrscr_arch_loop2
|
|
||||||
ld a, l
|
|
||||||
cp c
|
|
||||||
jr nz, _clrscr_arch_loop2
|
|
||||||
ret
|
|
||||||
|
|
||||||
_libputc_arch:
|
|
||||||
ld hl, #2
|
|
||||||
add hl, sp
|
|
||||||
ld a, (hl)
|
|
||||||
_libputc_asm::
|
|
||||||
push af
|
|
||||||
ld hl, (#_screen_offset)
|
|
||||||
ld bc, #SCREEN_HEIGHT * #SCREEN_WIDTH
|
|
||||||
ld a, b
|
|
||||||
cp h
|
|
||||||
jr nz, _libputc_arch_putc
|
|
||||||
ld a, c
|
|
||||||
cp l
|
|
||||||
jr z, _libputc_arch_scroll
|
|
||||||
_libputc_arch_putc:
|
|
||||||
ld bc, #VRAM_CHAR
|
|
||||||
add hl, bc
|
|
||||||
pop af
|
|
||||||
ld (hl), a
|
|
||||||
ld hl, #_screen_offset
|
|
||||||
inc (hl)
|
|
||||||
ret nz
|
|
||||||
inc hl
|
|
||||||
inc (hl)
|
|
||||||
ret
|
|
||||||
_libputc_arch_scroll:
|
|
||||||
push de
|
|
||||||
ld hl, #VRAM_CHAR + #SCREEN_WIDTH
|
|
||||||
ld de, #VRAM_CHAR
|
|
||||||
ld bc, #SCREEN_HEIGHT * #SCREEN_WIDTH - #SCREEN_WIDTH
|
|
||||||
push bc
|
|
||||||
push de
|
|
||||||
ldir
|
|
||||||
pop de
|
|
||||||
pop hl
|
|
||||||
push hl
|
|
||||||
ld (#_screen_offset), hl
|
|
||||||
ld b, #SCREEN_WIDTH
|
|
||||||
add hl, de
|
|
||||||
_libputc_arch_scroll_loop:
|
|
||||||
ld (hl), #CH_SPACE
|
|
||||||
inc hl
|
|
||||||
djnz _libputc_arch_scroll_loop
|
|
||||||
pop hl
|
|
||||||
pop de
|
|
||||||
jr _libputc_arch_putc
|
|
||||||
|
|
||||||
_libputs_arch:
|
|
||||||
ld hl, #2
|
|
||||||
add hl, sp
|
|
||||||
ld e, (hl)
|
|
||||||
inc hl
|
|
||||||
ld d, (hl)
|
|
||||||
_libputs_arch_loop:
|
|
||||||
ld a, (hl)
|
|
||||||
or a
|
|
||||||
ret z
|
|
||||||
call _libputc_asm
|
|
||||||
jr _libputs_arch_loop
|
|
||||||
_libconio_arch_small_end::
|
|
|
@ -1,14 +0,0 @@
|
||||||
#ifndef __LIBCONIO_ARCH_MSLL_H__
|
|
||||||
#define __LIBCONIO_ARCH_MSLL_H__
|
|
||||||
#include "contiki.h"
|
|
||||||
|
|
||||||
void clrscr_arch(void);
|
|
||||||
void libputc_arch(unsigned char ch);
|
|
||||||
void libputs_arch(char* str);
|
|
||||||
|
|
||||||
unsigned char wherex(void);
|
|
||||||
unsigned char wherey(void);
|
|
||||||
void gotoxy(unsigned char x, unsigned char y);
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* __LIBCONIO_ARCH_MSLL_H__ */
|
|
|
@ -1,58 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2007, Takahide Matsutsuka.
|
|
||||||
* 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. The name of the author may not be used to endorse or promote
|
|
||||||
* products derived from this software without specific prior
|
|
||||||
* written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* \file
|
|
||||||
* This is architecture-depend contiki toolkit for PC-6001 family.
|
|
||||||
* \author
|
|
||||||
* Takahide Matsutsuka <markn@markn.org>
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __LIBCONIO_ARCH_H__
|
|
||||||
#define __LIBCONIO_ARCH_H__
|
|
||||||
|
|
||||||
/* The following functions are used by assembler only */
|
|
||||||
#if LIBCONIO_EXPORT
|
|
||||||
void cputc_arch(char c);
|
|
||||||
void cputs_arch(char *str);
|
|
||||||
void cputsn_arch(char *str, unsigned char len);
|
|
||||||
void chline_arch(unsigned char length);
|
|
||||||
void cvline_arch(unsigned char length);
|
|
||||||
void clip_arch(unsigned char clip1, unsigned char clip2);
|
|
||||||
void clearto_arch(unsigned char to);
|
|
||||||
void revers_arch(unsigned char reversed);
|
|
||||||
void gotoxy_arch(unsigned char x, unsigned char y);
|
|
||||||
#endif /* LIBCONIO_CONF_EXPORT */
|
|
||||||
unsigned char wherex_arch();
|
|
||||||
unsigned char wherey_arch();
|
|
||||||
|
|
||||||
#endif /* __LIBCONIO_ARCH_H__ */
|
|
|
@ -1,34 +0,0 @@
|
||||||
;;;
|
|
||||||
;;;
|
|
||||||
;;; clock.S
|
|
||||||
;;;
|
|
||||||
;;; retrieve tickcount from PC-6001's internal timer
|
|
||||||
;;;
|
|
||||||
;;; @author Takahide Matsutsuka <markn@markn.org>
|
|
||||||
;;;
|
|
||||||
;;; $Id: clock.S,v 1.1 2007/09/11 12:12:59 matsutsuka Exp $
|
|
||||||
;;;
|
|
||||||
.globl _clock_time
|
|
||||||
|
|
||||||
.area _GSINIT
|
|
||||||
;; ---------------------------------
|
|
||||||
;; unsigned long clock_time();
|
|
||||||
;; __BCDEHL____
|
|
||||||
;; return long value as (DE, BC)
|
|
||||||
;; ---------------------------------
|
|
||||||
;; this function uses PC-6001's internal timer
|
|
||||||
;; which counts up 2 per 1/512 sec.
|
|
||||||
.area _CODE
|
|
||||||
_clock_time:
|
|
||||||
ld hl, #0xfa28
|
|
||||||
ld c, (hl)
|
|
||||||
inc hl
|
|
||||||
ld b, (hl)
|
|
||||||
inc hl
|
|
||||||
ld e, (hl)
|
|
||||||
inc hl
|
|
||||||
ld d, (hl)
|
|
||||||
ld l, c
|
|
||||||
ld h, b
|
|
||||||
|
|
||||||
ret
|
|
|
@ -1,74 +0,0 @@
|
||||||
;;;
|
|
||||||
;;;
|
|
||||||
;;; getkey.S
|
|
||||||
;;;
|
|
||||||
;;; PC-6001 architecture-depend key fetch module
|
|
||||||
;;;
|
|
||||||
;;; @author Takahide Matsutsuka <markn@markn.org>
|
|
||||||
;;;
|
|
||||||
|
|
||||||
.globl _keyavail_arch
|
|
||||||
.globl _getkey_arch
|
|
||||||
.area _GSINIT
|
|
||||||
|
|
||||||
.area _DATA
|
|
||||||
;; unsigned char key;
|
|
||||||
_key:
|
|
||||||
.ds 1
|
|
||||||
|
|
||||||
.area _GSINIT
|
|
||||||
.area _CODE
|
|
||||||
|
|
||||||
;; ---------------------------------
|
|
||||||
;; unsigned char keyavail_arch();
|
|
||||||
;; AFBC__HL____
|
|
||||||
;; a=getkey, l=getkey
|
|
||||||
;; ---------------------------------
|
|
||||||
_keyavail_arch:
|
|
||||||
ld hl, #_key
|
|
||||||
ld a, (hl)
|
|
||||||
;; if (key != 0) return 1; else goto _getch;
|
|
||||||
or a
|
|
||||||
jr z, _getch
|
|
||||||
ld l, #0x01
|
|
||||||
ret
|
|
||||||
|
|
||||||
_getch:
|
|
||||||
push hl
|
|
||||||
;; A = (keybuf)
|
|
||||||
call #0x103a
|
|
||||||
pop hl
|
|
||||||
;; if (keybuf != null) goto _getch_key
|
|
||||||
jr nz, _getch_key
|
|
||||||
;; we do not have a keyin
|
|
||||||
xor a
|
|
||||||
jr _getch_got
|
|
||||||
_getch_key:
|
|
||||||
cp a, #0x14
|
|
||||||
jr z, _getch
|
|
||||||
|
|
||||||
_getch_got:
|
|
||||||
;; key = getch()
|
|
||||||
ld (hl), a
|
|
||||||
ld l, a
|
|
||||||
ret
|
|
||||||
|
|
||||||
|
|
||||||
;; ---------------------------------
|
|
||||||
;; unsigned char getkey_arch();
|
|
||||||
;; AFBC__HL____
|
|
||||||
;; ---------------------------------
|
|
||||||
_getkey_arch:
|
|
||||||
;; if (key == 0) keyavail_arch();
|
|
||||||
ld hl, #_key
|
|
||||||
ld a, (hl)
|
|
||||||
or a
|
|
||||||
call z, _keyavail_arch
|
|
||||||
;; if (key == 0) goto _havekey
|
|
||||||
or a
|
|
||||||
jr z, _havekey
|
|
||||||
;; key = 0
|
|
||||||
ld (hl), #0x00
|
|
||||||
_havekey:
|
|
||||||
ld l, a
|
|
||||||
ret
|
|
|
@ -1,51 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2007, Takahide Matsutsuka.
|
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* \file
|
|
||||||
* A header file for machine depend key fetching functions.
|
|
||||||
* \author
|
|
||||||
* Takahide Matsutsuka <markn@markn.org>
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __GETKEY_H__
|
|
||||||
#define __GETKEY_H__
|
|
||||||
|
|
||||||
/* defined in getch.S */
|
|
||||||
typedef char ctk_arch_key_t;
|
|
||||||
ctk_arch_key_t keyavail_arch();
|
|
||||||
ctk_arch_key_t getkey_arch();
|
|
||||||
#define CTK_ARCH_KEY_T
|
|
||||||
#define ctk_arch_getkey() getkey_arch()
|
|
||||||
#define ctk_arch_keyavail() keyavail_arch()
|
|
||||||
|
|
||||||
#endif /* __GETKEY_H__ */
|
|
|
@ -1,38 +0,0 @@
|
||||||
;;;
|
|
||||||
;;;
|
|
||||||
;;; isprint-arch.S
|
|
||||||
;;;
|
|
||||||
;;; Architecture depend isprint function.
|
|
||||||
;;;
|
|
||||||
;;; @author Takahide Matsutsuka <markn@markn.org>
|
|
||||||
;;;
|
|
||||||
;;; $Id: isprint_arch.S,v 1.1 2007/09/11 12:12:59 matsutsuka Exp $
|
|
||||||
;;;
|
|
||||||
.globl _isprint_arch
|
|
||||||
.area _GSINIT
|
|
||||||
|
|
||||||
;; unsigned long clock_time();
|
|
||||||
;; return long value as (DE, BC)
|
|
||||||
|
|
||||||
;; this function is identify if a given
|
|
||||||
;; character is printable on PC-6001
|
|
||||||
.area _CODE
|
|
||||||
_isprint_arch:
|
|
||||||
;; ---------------------------------
|
|
||||||
;; char isprint (unsigned char ch);
|
|
||||||
;; Stack; retl reth ch
|
|
||||||
;; A_____HL____
|
|
||||||
;; return l
|
|
||||||
;; ---------------------------------
|
|
||||||
ld hl, #2
|
|
||||||
add hl, sp
|
|
||||||
ld a, (hl)
|
|
||||||
or a
|
|
||||||
jr z, #_isprint_arch_ret_false
|
|
||||||
cp #0xfe
|
|
||||||
jr nc, #_isprint_arch_ret_false
|
|
||||||
ld l, #1
|
|
||||||
ret
|
|
||||||
_isprint_arch_ret_false:
|
|
||||||
ld l, #0
|
|
||||||
ret
|
|
|
@ -1,47 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2007, Takahide Matsutsuka.
|
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* \file
|
|
||||||
* A header file for machine depend isprint function.
|
|
||||||
* \author
|
|
||||||
* Takahide Matsutsuka <markn@markn.org>
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __ISPRINT_ARCH_H__
|
|
||||||
#define __ISPRINT_ARCH_H__
|
|
||||||
|
|
||||||
/* defined in isprint_arch.S */
|
|
||||||
unsigned char isprint_arch(char ch);
|
|
||||||
#define ctk_arch_isprint(c) isprint_arch(c)
|
|
||||||
|
|
||||||
#endif /* __ISPRINT_ARCH_H__ */
|
|
|
@ -1,188 +0,0 @@
|
||||||
;;;
|
|
||||||
;;;
|
|
||||||
;;; rs232-asm.S
|
|
||||||
;;;
|
|
||||||
;;; PC-6001 Architecture depend RS-232C implementation,
|
|
||||||
;;; uses a bunch of BIOS functions.
|
|
||||||
;;;
|
|
||||||
;;; @author Takahide Matsutsuka <markn@markn.org>
|
|
||||||
;;;
|
|
||||||
;;; $Id: rs232-asm.S,v 1.3 2007/11/28 09:39:30 matsutsuka Exp $
|
|
||||||
;;;
|
|
||||||
|
|
||||||
;; definitions of PC-6001 BIOS routines
|
|
||||||
_rs232c_initialize = 0x19bf
|
|
||||||
_buffer_out = 0x2627
|
|
||||||
_char_input_sub = 0x2642
|
|
||||||
_count_buffer = 0x26a2
|
|
||||||
_rs232c_intr_vector = 0xfa04
|
|
||||||
_subcpu_handshake_out = 0x0e8f
|
|
||||||
LOG = 0
|
|
||||||
CTK = 0
|
|
||||||
;; export symbols
|
|
||||||
.globl _rs232_arch_writeb
|
|
||||||
.globl _rs232_arch_poll
|
|
||||||
.globl _rs232_arch_init
|
|
||||||
|
|
||||||
.area _CODE
|
|
||||||
|
|
||||||
.if LOG
|
|
||||||
_hex:
|
|
||||||
.ascii "0123456789ABCDEF"
|
|
||||||
.if CTK
|
|
||||||
.globl _cputc_arch_asm
|
|
||||||
.else
|
|
||||||
.globl _libputc_asm
|
|
||||||
.globl _screen_offset
|
|
||||||
.endif
|
|
||||||
_rs232_arch_putc: ; a = data
|
|
||||||
ld hl, #0
|
|
||||||
ld (#_screen_offset), hl
|
|
||||||
push af
|
|
||||||
srl a
|
|
||||||
srl a
|
|
||||||
srl a
|
|
||||||
srl a
|
|
||||||
call _rs232_arch_putc_next1
|
|
||||||
pop af
|
|
||||||
and a, #0x0f
|
|
||||||
_rs232_arch_putc_next1:
|
|
||||||
ld hl, #_hex
|
|
||||||
_rs232_arch_putc_loop:
|
|
||||||
or a
|
|
||||||
jr z, _rs232_arch_putc_next2
|
|
||||||
inc hl
|
|
||||||
dec a
|
|
||||||
jr _rs232_arch_putc_loop
|
|
||||||
_rs232_arch_putc_next2:
|
|
||||||
ld a, (hl)
|
|
||||||
.if CTK
|
|
||||||
call _cputc_arch_asm
|
|
||||||
.else
|
|
||||||
call _libputc_asm
|
|
||||||
.endif
|
|
||||||
ret
|
|
||||||
.endif
|
|
||||||
|
|
||||||
;; ---------------------------------
|
|
||||||
;; void rs232_writeb(uint8_t c)
|
|
||||||
;; Stack; retl reth c
|
|
||||||
;; AF__D_HL____
|
|
||||||
;; return void
|
|
||||||
;; ---------------------------------
|
|
||||||
_rs232_arch_writeb:
|
|
||||||
ld hl, #2
|
|
||||||
add hl, sp
|
|
||||||
ld d, (hl)
|
|
||||||
.if LOG
|
|
||||||
push de
|
|
||||||
ld a, #0x77 ; 'w'
|
|
||||||
.if CTK
|
|
||||||
call _cputc_arch_asm
|
|
||||||
.else
|
|
||||||
call _libputc_asm
|
|
||||||
.endif
|
|
||||||
pop de
|
|
||||||
;; ld a, d
|
|
||||||
;; push de
|
|
||||||
;; call _rs232_arch_putc
|
|
||||||
;; pop de
|
|
||||||
.endif
|
|
||||||
_rs232_arch_writeb_loop:
|
|
||||||
in a, (#0x81)
|
|
||||||
and a, #0x01
|
|
||||||
cp #0x01 ; TxRDY? 0x01/0x81/0x85
|
|
||||||
jr nz, _rs232_arch_writeb_loop
|
|
||||||
ld a, d
|
|
||||||
out (#0x80), a
|
|
||||||
ret
|
|
||||||
|
|
||||||
;; RS-232C interrupt routine
|
|
||||||
;; receive a byte and put it into the buffer
|
|
||||||
_rs232_arch_intr:
|
|
||||||
push bc
|
|
||||||
push af
|
|
||||||
push de
|
|
||||||
push hl
|
|
||||||
in a, (#0x81)
|
|
||||||
and a, #0x02 ; RxRDY?
|
|
||||||
jr z, _rs232_arch_intr_next ; no input
|
|
||||||
in a, (#0x80)
|
|
||||||
ld e, a
|
|
||||||
ld a, #0x01
|
|
||||||
call _buffer_out ; buffer output A=bufno, e=data
|
|
||||||
_rs232_arch_intr_next:
|
|
||||||
ld a, #0x0c
|
|
||||||
call _subcpu_handshake_out ; sub CPU handshake output A
|
|
||||||
call _rs232_arch_bufchk
|
|
||||||
pop hl
|
|
||||||
pop de
|
|
||||||
pop af
|
|
||||||
pop bc
|
|
||||||
ei
|
|
||||||
ret
|
|
||||||
|
|
||||||
_rs232_arch_bufchk:
|
|
||||||
ld a, #0x01
|
|
||||||
call _count_buffer ; count buffer available bytes -> A
|
|
||||||
cp #0x02 ; A >= 2?
|
|
||||||
ld a, #0x37 ; Rx enable
|
|
||||||
jr nc, _rs232_arch_bufchk_next ; buffer available bytes >= 2
|
|
||||||
ld a, #0x33 ; Rx disable
|
|
||||||
_rs232_arch_bufchk_next:
|
|
||||||
out (#0x81),a ; buf available=0x37, buf full=0x33
|
|
||||||
ret
|
|
||||||
|
|
||||||
;; ---------------------------------
|
|
||||||
;; unsigned char rs232_arch_poll(unsigned char *stat);
|
|
||||||
;; Stack; retl reth statl stath
|
|
||||||
;; AFBCDEHL____
|
|
||||||
;; return input byte (*stat == 0 if no input)
|
|
||||||
;; ---------------------------------
|
|
||||||
_rs232_arch_poll:
|
|
||||||
ld hl, #2
|
|
||||||
add hl, sp
|
|
||||||
ld e, (hl)
|
|
||||||
inc hl
|
|
||||||
ld d, (hl)
|
|
||||||
ld a, #0x01
|
|
||||||
ld (de), a
|
|
||||||
di
|
|
||||||
call _char_input_sub ; read from buffer
|
|
||||||
ei
|
|
||||||
push af
|
|
||||||
call _rs232_arch_bufchk ; buffer check
|
|
||||||
pop af
|
|
||||||
jr nz, _rs232_arch_poll_ret
|
|
||||||
xor a ; we have no data in the buffer
|
|
||||||
ld (de), a
|
|
||||||
jr _rs232_arch_poll_ret2
|
|
||||||
_rs232_arch_poll_ret:
|
|
||||||
.if LOG
|
|
||||||
call _libputc_asm
|
|
||||||
;; call _rs232_arch_putc
|
|
||||||
.endif
|
|
||||||
_rs232_arch_poll_ret2:
|
|
||||||
pop af
|
|
||||||
ld l, a
|
|
||||||
ret
|
|
||||||
|
|
||||||
;; ---------------------------------
|
|
||||||
;; void rs232_init(unsigned long ubr);
|
|
||||||
;; Stack; retl reth ubr1 ubr2 ubr3 ubr4
|
|
||||||
;; AFB_DEHL____
|
|
||||||
;; return void
|
|
||||||
;; ---------------------------------
|
|
||||||
_rs232_arch_init:
|
|
||||||
ld hl, #_rs232_arch_intr
|
|
||||||
di
|
|
||||||
ld (#_rs232c_intr_vector), hl
|
|
||||||
ei
|
|
||||||
;; S2 S1 PE P L2 L1 B2 B1
|
|
||||||
;; 0 1 0 0 1 1 1 1
|
|
||||||
;; 8-N-1 64x clock
|
|
||||||
ld b, #0x4f
|
|
||||||
call _rs232c_initialize
|
|
||||||
ld a, #0x37
|
|
||||||
out (#0x81), a
|
|
||||||
ret
|
|
|
@ -1,46 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2007, 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.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* \file
|
|
||||||
* A configuration file of machine depend rtimer.
|
|
||||||
* \authort
|
|
||||||
* Takahide Matsutsuka <markn@markn.org>
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef __RTIMER_ARCH_H__
|
|
||||||
#define __RTIMER_ARCH_H__
|
|
||||||
|
|
||||||
#define RTIMER_ARCH_SECOND 1024
|
|
||||||
|
|
||||||
#endif /* __RTIMER_ARCH_H__ */
|
|
|
@ -1,72 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2007, Takahide Matsutsuka.
|
|
||||||
* 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. The name of the author may not be used to endorse or promote
|
|
||||||
* products derived from this software without specific prior
|
|
||||||
* written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* \file
|
|
||||||
* loader-arch.c
|
|
||||||
* A machine-dependent implementation of program loader for PC-6001 family.
|
|
||||||
* \author
|
|
||||||
* Takahide Matsutsuka <markn@markn.org>
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef WITH_LOADER_ARCH
|
|
||||||
#include "contiki.h"
|
|
||||||
#include "loader.h"
|
|
||||||
#include "loader/mef.h"
|
|
||||||
#include "loader/loader_arch.h"
|
|
||||||
|
|
||||||
unsigned char load_byte() { return 0; }
|
|
||||||
|
|
||||||
struct dsc*
|
|
||||||
loader_arch_load_dsc(char *name)
|
|
||||||
{
|
|
||||||
mef_load((unsigned char *) 0xc800);
|
|
||||||
log_message("loader_arch_load_dsc", name);
|
|
||||||
}
|
|
||||||
unsigned char
|
|
||||||
loader_arch_load(char *name, char *arg)
|
|
||||||
{
|
|
||||||
log_message("loader_arch_load", name);
|
|
||||||
return LOADER_ERR_NOLOADER;
|
|
||||||
}
|
|
||||||
void
|
|
||||||
loader_arch_unload()
|
|
||||||
{
|
|
||||||
log_message("loader_arch_unload", name);
|
|
||||||
}
|
|
||||||
void
|
|
||||||
loader_arch_unload_dsc(struct dsc *dsc)
|
|
||||||
{
|
|
||||||
log_message("loader_arch_unload_dsc", name);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* WITH_LOADER_ARCH */
|
|
|
@ -1,58 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2007, Takahide Matsutsuka.
|
|
||||||
* 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. The name of the author may not be used to endorse or promote
|
|
||||||
* products derived from this software without specific prior
|
|
||||||
* written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* \file
|
|
||||||
* loader-arch.h
|
|
||||||
* Definitions of machine-dependent loader for PC-6001 family.
|
|
||||||
* \author
|
|
||||||
* Takahide Matsutsuka <markn@markn.org>
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __LOADER_ARCH_H__
|
|
||||||
#define __LOADER_ARCH_H__
|
|
||||||
|
|
||||||
#ifdef WITH_LOADER_ARCH
|
|
||||||
#define LOADER_LOAD(name, arg) loader_arch_load(name, arg)
|
|
||||||
#define LOADER_UNLOAD() loader_arch_unload()
|
|
||||||
#define LOADER_LOAD_DSC(name) loader_arch_load_dsc(name)
|
|
||||||
#define LOADER_UNLOAD_DSC(dsc) loader_arch_unload_dsc(dsc)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
struct dsc *loader_arch_load_dsc(char *name);
|
|
||||||
unsigned char loader_arch_load(char *name, char *arg);
|
|
||||||
void loader_arch_unload();
|
|
||||||
void loader_arch_unload_dsc(struct dsc *dsc);
|
|
||||||
#endif /* WITH_LOADER_ARCH */
|
|
||||||
|
|
||||||
#endif /* __LOADER_ARCH_H__ */
|
|
Loading…
Reference in a new issue